Skip to main content

Condense's opinionated constructs and stacks for AWS CDK

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

condensetech.cdk-constructs-0.1.2.tar.gz (201.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

condensetech.cdk_constructs-0.1.2-py3-none-any.whl (199.5 kB view details)

Uploaded Python 3

File details

Details for the file condensetech.cdk-constructs-0.1.2.tar.gz.

File metadata

File hashes

Hashes for condensetech.cdk-constructs-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0f847266c718f80dffdb08a96917ee50bea31e8494faab22e9162ad936b9dcfe
MD5 c923eccc518ed1135dedb9c264fc7c3f
BLAKE2b-256 4bbb54d4437fd8d6d71280c0e7a08dd49d5f14fab4bccfbc61f7415d6e5f2925

See more details on using hashes here.

File details

Details for the file condensetech.cdk_constructs-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for condensetech.cdk_constructs-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ca400f7913fe8a051feb00ceb43bd325632f717c4b467eb93b6c7d7f1bc3a7d3
MD5 f81f447dfd6b42f43c40c4f1cb8b601b
BLAKE2b-256 e6cc9f456864aa25bef328b9821e5b0a717dff2bc6ac0483be5e92c9daf37bda

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page