Stacktape
Stacktape


AWS CDK Constructs



The AWS Cloud Development Kit (CDK) allows you to model your application infrastructure using familiar programming languages.

A fundamental building block of the CDK is the construct. A construct is a reusable cloud component that encapsulates everything AWS needs to create the component. It can represent a single AWS resource, such as an S3 bucket, or be a higher-level abstraction composed of multiple related AWS resources.

Stacktape allows you to extend your infrastructure by adding AWS CDK constructs to your stack. The AWS resources that are part of the construct are then deployed alongside the other resources created by Stacktape.

To learn more about constructs, see the AWS documentation. You can also discover additional constructs from AWS, third parties, and the open-source community on the Construct Hub.

How to use CDK constructs

Stacktape currently supports constructs written in Javascript or Typescript. You can create your own construct by extending the Construct class.

import { Duration } from 'aws-cdk-lib';
import * as sns from 'aws-cdk-lib/aws-sns';
import * as subs from 'aws-cdk-lib/aws-sns-subscriptions';
import * as sqs from 'aws-cdk-lib/aws-sqs';
import { Construct } from 'constructs';
export class MyConstruct extends Construct {
constructor(scope: Construct, id: string, props?: { visibilityTimeout: number }) {
super(scope, id);
const queue = new sqs.Queue(this, 'Queue', {
visibilityTimeout: Duration.seconds(props?.visibilityTimeout || 300)
});
const topic = new sns.Topic(this, 'Topic');
topic.addSubscription(new subs.SqsSubscription(queue));
}
}

You can then reference the construct in your stacktape.yml file:

resources:
myConstruct:
type: aws-cdk-construct
properties:
entryfilePath: my-construct.ts
exportName: MyConstruct
constructProperties:
visibilityTimeout: 50

Contents

  •  How to use CDK constructs