Categorygithub.com/condensetech/cdk-constructs/condensetechcdkconstructs
modulepackage
0.1.0
Repository: https://github.com/condensetech/cdk-constructs.git
Documentation: pkg.go.dev

# README

Condense's CDK Constructs

This library contains constructs and stacks we use across our projects.

Setup

Node.js Install the package:
npm install @condensetech/cdk-constructs # or
yarn add @condensetech/cdk-constructs # or
pnpm add @condensetech/cdk-constructs

Import it:

import * as condense from '@condensetech/cdk-constructs';
Python Install the package:
pip install condensetech.cdk-constructs

Import it:

from condensetech import cdk_constructs
.NET Install the package:
dotnet add package CondenseTech.CdkConstructs

Import it:

using CondenseTech.CdkConstructs;
Go Install the package:
go get github.com/condensetech/cdk-constructs

Import it:

import "github.com/condensetech/cdk-constructs"

Usage

All API docs can be found in the API.md.

Composable Infrastructure Constructs and Stacks

Readability and maintainability are key factors when writing IaC. By defining some high level interfaces, we can easily write constructs which don't need to be tied to the specific implementation of a resource.

For example, the INetworking, defines some high level methods to interact with a VPC. Often a VPC contains a bastion host, which should be whitelisted to databases, so the interface has a bastionHost property which can return the bastion host. This allows to write code like the following:

interface MyDatabaseStackProps extends cdk.StackProps {
  networking: INetworking;
}
class MyDatabaseStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props: MyDatabaseStackProps) {
    super(scope, id, props);

    const db = new rds.DatabaseInstance(this, 'Database', {
      vpc: props.networking.vpc,
      ...
    });
    if (props.networking.bastionHost) {
      db.connections.allowDefaultPortFrom(props.networking.bastionHost);
    }
  }
}

If a certain point we want to add a bastion host, we just need to flip one single switch in the networking props, to have the bastion host able to connect to all the resources in the VPC.

Constructs and Stacks in this area:

Entrypoint

A typical scenario is to have one single Application Load Balancer in a VPC, which routes traffic to different services. The Entrypoint Construct and the Entrypoint Stack allow to easily define this entrypoint load balancer.

TODO: Add a method to allow consumers to add rules without having to know the right priority order in advance.

Cloudwatch Alarms Topic

The CloudwatchAlarmsTopicStack creates an SNS Topic which can be used as a target for Cloudwatch Alarms. In addition to link the topic to HTTPS endpoints, it can also create a Lambda function which can be used to send messages to Discord.

Naive BasicAuth Cloudfront Function

NaiveBasicAuthCloudfrontFunction is useful when a basic protection layer must be added to Cloudfront (for SPAs or static sites) and you just need to avoid crawlers and unwanted visitors.

Monitoring

By instantiating a MonitoringFacade in your stack, you can easily add monitoring to your resources. The facade will create a Cloudwatch Dashboard, and will add alarms to the resources you want to monitor.

# Packages

Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

# Functions

Checks if `x` is a construct.
Returns the minimum instance type supported by the Aurora cluster based on the engine type.
Checks if `x` is a construct.
Return whether the given object is a Stack.
Looks up the first stack scope in which `construct` is defined.
Checks if `x` is a construct.
Return whether the given object is a Stack.
Looks up the first stack scope in which `construct` is defined.
Checks if `x` is a construct.
Checks if `x` is a construct.
Return whether the given object is a Stack.
Looks up the first stack scope in which `construct` is defined.
Checks if `x` is a construct.
Checks if `x` is a construct.
Return whether the given object is a Stack.
Looks up the first stack scope in which `construct` is defined.
Experimental.
Imports a function by its name and ARN.
Checks if `x` is a construct.
Returns true if the construct was created by CDK, and false otherwise.
Check whether the given construct is a Resource.
Checks if `x` is a construct.
Checks if `x` is a construct.
Return whether the given object is a Stack.
Looks up the first stack scope in which `construct` is defined.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.
Experimental.

# Structs

Experimental.
The ApplicationLoadBalancerMonitoringConfig defines the thresholds for the Application Load Balancer monitoring.
Properties for the AuroraCluster construct.
Properties for the AuroraClusterStack.
Experimental.
The CacheClusterMonitoringConfig defines the thresholds for the cache cluster monitoring.
Discord configuration for the Cloudwatch Alarms Topic.
Properties for the CloudwatchAlarmsTopicStack.
Properties for the DatabaseInstance construct.
Properties for the DatabaseInstanceStack.
Properties for the Entrypoint construct.
Properties for the EntrypointStack.
The FargateServiceMonitoringConfig defines the thresholds for the Fargate service monitoring.
Properties for the MonitoringFacade.
Exclusion path for the NaiveBasicAuthCloudfrontFunction.
Props for the NaiveBasicAuthCloudfrontFunction construct.
Properties for the Networking construct.
Properties for the NetworkingStack.
The RdsClusterMonitoringConfig defines the thresholds for the RDS cluster monitoring.
The RdsInstanceMonitoringConfig defines the thresholds for the RDS instance monitoring.
The TargetGroupMonitoringConfig defines the thresholds for the target group monitoring.
Experimental.

# Interfaces

The ApplicationLoadBalancerMonitoringAspect iterates over the Application Load Balancers and adds monitoring widgets and alarms.
The AuroraCluster Construct creates an opinionated Aurora Cluster.
The AuroraClusterStack creates an [AuroraCluster](#@condensetech/cdk-constructs.AuroraCluster) construct and optionally defines the monitoring configuration.
The CacheClusterMonitoringAspect iterates over the Elasticache clusters and adds monitoring widgets and alarms.
The CloudwatchAlarmsTopicStack creates an SNS topic for Cloudwatch alarms.
The DatabaseInstance construct creates an RDS database instance.
The DatabaseInstanceStack creates a [DatabaseInstance](#@condensetech/cdk-constructs.DatabaseInstance) construct and optionally defines the monitoring configuration.
The Entrypoint construct creates an Application Load Balancer (ALB) that serves as the centralized entry point for all applications.
The EntrypointStack creates an [Entrypoint](#@condensetech/cdk-constructs.Entrypoint) construct and optionally defines the monitoring configuration.
The FargateServiceMonitoringAspect iterates over the Fargate services and adds monitoring widgets and alarms.
The ICondenseMonitoringFacade interface defines the methods that the monitoring facade must implement.
The IDatabase interface allows to write stacks and constructs that depend on a database without being tied to the specific database implementation.
The Entrypoint LoadBalancer is an Application Load Balancer (ALB) that serves as the centralized entry point for all applications.
The INetworking interface allows to write stacks and constructs that depend on networking without being tied to the specific networking implementation.
The MonitoringFacade creates a Cloudwatch dashboard and applies monitoring aspects to resources.
A CloudFront function that implements a naive basic auth mechanism.
The Networking construct creates a VPC which can have public, private, and isolated subnets.
The NetworkingStack creates a [Networking](#@condensetech/cdk-constructs.Networking) construct.
The RdsClusterMonitoringAspect iterates over the RDS clusters and adds monitoring widgets and alarms.
The RdsInstanceMonitoringAspect iterates over the RDS instances and adds monitoring widgets and alarms.
The TargetGroupMonitoringAspect iterates over the target groups and adds monitoring widgets and alarms.