Questions tagged [aws-cdk]

The AWS CDK is an infrastructure modeling framework that allows you to define your cloud resources using an imperative programming interface.

The AWS CDK is an infrastructure modeling framework that allows you to define your cloud resources using an imperative programming interface, currently TypeScript/JavaScript, Python, Java, C# and (beta) Go.

Developers can use one of the supported programming languages to define reusable cloud components called Constructs, which are composed together into Stacks and Apps.

The AWS CDK Toolkit is a command-line tool for interacting with CDK apps. It allows developers to synthesize artifacts such as AWS CloudFormation Templates, deploy stacks to development AWS accounts and “diff” against a deployed stack to understand the impact of a code change.

The AWS Construct Library includes a module for each AWS service with constructs that offer rich APIs that encapsulate the details of how to use AWS. The AWS Construct Library aims to reduce the complexity and glue-logic required when integrating various AWS services to achieve your goals on AWS.

3488 questions
9
votes
4 answers

AWS CDK - post deployment actions

is anyone aware of a method to execute post-deploy functionality. Follwing is a sample of a casual CDK app. app = core.App() Stack(app, ...) app.synth() What I am looking for is a way to apply some logic after template is deployed. The thing is the…
Łukasz
  • 1,980
  • 6
  • 32
  • 52
9
votes
5 answers

'cdk destroy' is not working as intended or I am not understanding it correctly?

Here is my demo stack, export class HelloCdkStack extends cdk.Stack { constructor(parent: cdk.App, id: string, props?: cdk.StackProps) { super(parent, id, props); new s3.Bucket(this, 'MyFirstBucket', { versioned: true, …
9
votes
2 answers

use existing vpc and security group when adding an ec2 instance

There is lots of example code, but the rapidly improving cdk package isn't helping me find working examples of some (I thought) simple things. eg., even an import I found in an example fails: import { VpcNetworkRef } from '@aws-cdk/aws-ec2'; error…
Jim Fondren
  • 150
  • 1
  • 1
  • 7
8
votes
2 answers

Adding integration response to AWS websocket API with @aws-cdk/aws-apigatewayv2

Is there a way to add an integration response to the AWS WebSocket API using AWS CDK with the aws-apigatewayv2 package? This answer shows a great way to achieve just that using CloudFormation. But I haven't been able to translate it into the AWS…
8
votes
2 answers

What is the purpose of app.synth() in AWS CDK?

What is the purpose of the app.synth() line in AWS CDK applications? For example it can be seen here on line 29: https://github.com/aws-samples/aws-cdk-examples/blob/master/typescript/ecs/fargate-application-load-balanced-service/index.ts I have…
8
votes
1 answer

A PolicyStatement used in an identity-based policy cannot specify any IAM principals error

let servicePrincipal: any = new iam.ServicePrincipal("lambda.amazonaws.com"); let policyDoc = new iam.PolicyDocument({ statements: [ new iam.PolicyStatement({ actions: ["sts:AssumeRole"], principals:…
walter
  • 537
  • 1
  • 6
  • 22
8
votes
3 answers

How to add a security group to an existing RDS with CDK without cyclic-dependency

I have a multi-stack application where I want to deploy an RDS in one stack and then in a later stack deploy a Fargate cluster that connects to the RDS. Here is how the rds gets defined: this.rdsSG = new ec2.SecurityGroup(this, `ecsSG`, { …
Coherent
  • 1,933
  • 5
  • 24
  • 33
8
votes
1 answer

How to provide a custom domain name for a Lambda-based APIGateway in CDK?

For the purposes of this question, assume that I already have an example.org Hosted Zone in Route53 (my actual zone is, of course, different) With the following CDK app: export class MyExampleStack extends cdk.Stack { constructor(scope:…
scubbo
  • 4,969
  • 7
  • 40
  • 71
8
votes
2 answers

CloudWatch log group is not deleted on cdk destroy

I have this CDK code: const logGroup = new LogGroup(this, 'MyAppLogGroup', { logGroupName: 'myapp', retention: RetentionDays.ONE_DAY }); When I run cdk deploy, log group is created in CloudWatch, but when I run cdk destroy, it's not deleted. Is…
Héctor
  • 24,444
  • 35
  • 132
  • 243
8
votes
1 answer

AWS CDK Working with Existing DynamoDB and Streams

I'm migrating my cloud solution to cdk. I can see how to add a stream to a new DynamoDB in the constructor through the TableProps: const newTable = new dynamodb.Table(this, 'new Table', { tableName: 'streaming', partitionKey: { name : 'id',…
monkey
  • 1,213
  • 2
  • 13
  • 35
8
votes
1 answer

CDK to enable DNS resolution for VPCPeering

I have VPC peering to connect to a lambda in one aws account to a RDS instance in another aws account. This works fine but required the VPC peering to have DNS resolution option enabled. By default DNS resolution is set to : DNS resolution from…
trooper31
  • 182
  • 1
  • 2
  • 9
8
votes
1 answer

AWS-CDK: Single stack vs. Multiple stacks?

I keep seeing different implementations on aws-cdk, and I want to know if there is a preferred convention. Single stack. This makes sense if all the resources are related (i.e., a Lambda and an IAM role should be in the same stack, not in different…
josmolin
  • 81
  • 3
8
votes
3 answers

How to retrieve SecretsManager secret in AWS CDK

I'm setting up a Fargate service in AWS using CDK const albFargateService = new ecs_patterns.ApplicationLoadBalancedFargateService( this, 'FargateService', { vpc: ..., taskImageOptions: { image: ..., …
MEMark
  • 1,493
  • 2
  • 22
  • 32
8
votes
2 answers

Can I replicate the DependsOn behavior in AWS CDK?

Using AWS CDK (python), I'm creating a VPC with isolated subnets, and a number of Interface endpoints. I'm also launching a Sagemaker notebook with an associated Codecommit repo I create the Interface endpoint for Codecommit as well as Git…
maafk
  • 6,176
  • 5
  • 35
  • 58
8
votes
1 answer

How to import existing ec2 instance in aws cdk

Does anyone know how to import an existing ec2 instance in aws account using aws CDK? I searched on the net , also went through the docs. no luck there! All helps would be greatly appreciated.
sanketh s
  • 345
  • 1
  • 5
  • 14