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
17
votes
6 answers

How to install dependencies of lambda functions upon cdk build with AWS CDK

When using AWS SAM I used to run build command which would go through all of my Lambda function packages and install their dependencies (run npm install on them). How can I achieve the same behavior with AWS CDK? It doesn't seem to do it…
Milan
  • 1,780
  • 1
  • 16
  • 29
16
votes
2 answers

How to resolve AWS CDK error "Argument of type 'Function' is not assignable to parameter of type 'IFunction'"

I want to get the following example code from https://docs.aws.amazon.com/cdk/latest/guide/serverless_example.html working, but I get a "Argument of type 'Function' is not assignable to parameter of type 'IFunction'" error. import * as cdk from…
Andy Balham
  • 163
  • 1
  • 1
  • 4
16
votes
4 answers

How do you assign a VPC and security group to a Lambda in AWS CDK?

I have an AWS CDK stack with a lambda function that needs to insert into an RDS database. When the stack is deployed, the lambda function cannot access the database and gives an error: getaddrinfo ENOTFOUND [RDS endpoint as defined by me]. After…
Robin
  • 612
  • 1
  • 5
  • 12
16
votes
11 answers

AWS CDK - How to add an event notification to an existing S3 Bucket

I'm trying to modify this AWS-provided CDK example to instead use an existing bucket. Additional documentation indicates that importing existing resources is supported. So far I am unable to add an event notification to the existing bucket using…
cyber-samurai
  • 161
  • 1
  • 1
  • 4
16
votes
3 answers

How to get the account id with cdk

I wrote a simple typescript with AWS CDK and try to get the account id import cdk = require("@aws-cdk/core"); const app = new cdk.Stack(); console.log(app.account); But get below output $ tsc index.ts $ node index.js…
Bill
  • 2,494
  • 5
  • 26
  • 61
15
votes
2 answers

Subscribe a sqs queue to a sns topic that is in a different account, using aws cdk(typescript)

I would like to connect an sqs queue to an sns topic that is in a different account, using cdk (typescript). Below is the code (this code is in a stack) that I think should work but I have some doubts listed below the code (I have not deployed this…
15
votes
3 answers

Add Ingress Rule to Security Groups using AWS CDK

I'm trying to add an ingress rule to a Security Group via the AWS CDK using Python. As per the documentation here - there's a method add_ingress_rule() on the Class aws_cdk.aws_ec2. However - when I try to deploy the stack, I get the following…
SwapnilJak
  • 171
  • 1
  • 1
  • 7
15
votes
3 answers

AWS CDK: fixed logical ids

Currently logical ID of a resource is formed by concatenating the names of all of the constructs in the resource’s path and appending an eight-character MD5 hash. This produces garbage like VpcPrivateSubnet1DefaultRouteBE02A9ED and unfortunatelly…
Łukasz
  • 1,980
  • 6
  • 32
  • 52
15
votes
1 answer

AWS-CDK Unit-Testing and Integration Testing

What is the proper way to unit-test and integration-test my newly built constructs? What should be actually tested? How should it be tested? Thanks!
Romande
  • 561
  • 2
  • 4
  • 16
14
votes
1 answer

How to authorize lambda to perform ses:SendEmail with CDK?

I'm getting runtime exception: AccessDenied: User arn:aws:sts::431535252:assumed-role/...some-lambda' is not authorized to perform 'ses:SendEmail' on resource `arn:aws:ses:us-east-1:52452465462:identity/contact@somedomain.com Looking at the docs…
Daniel Birowsky Popeski
  • 8,752
  • 12
  • 60
  • 125
14
votes
1 answer

AWS CDK: Is there a way to create database schema using CDK?

I have created a RDS Aurora Postgres Database Cluster and Database Instance through CDK (using java as a language). Now I am trying to achieve creating a database schema through CDK. I tried but did not find any documentation or help anywhere which…
14
votes
1 answer

AWS CDK - role and policy creation

How can I translate this CloudFormation to CDK (JavaScript or Java)? I was trying to do it, but this is the first time that I work with CDK and I'm not sure how to do it. FargateTaskExecutionServiceRole: Type: AWS::IAM::Role Properties: …
juan
  • 358
  • 1
  • 4
  • 12
14
votes
4 answers

How to add S3 BucketPolicy with AWS CDK?

I wanna translate this CloudFormation piece into CDK: Type: AWS::S3::BucketPolicy Properties: Bucket: Ref: S3BucketImageUploadBuffer PolicyDocument: Version: "2012-10-17" Statement: Action: - s3:PutObject -…
14
votes
3 answers

How to create Cognito IdentityPool with Cognito UserPool as one of the Authentication provider using aws cdk?

I am trying to create a Cognito FederatedIdentityPool with CognitoUserPool as one Authentication Provider. Creating UserPool was easy enough: const userPool = new cognito.CfnUserPool(this, 'MyCognitoUserPool') const userPoolClient = new…
c2tarun
  • 776
  • 2
  • 9
  • 27
14
votes
4 answers

enabling CORS for AWS API gateway with the AWS CDK

I'm trying to build an application with the AWS CDK and if I were to build an application by hand using the AWS Console, I normally would enable CORS in API gateway. Even though I can export the swagger out of API Gateway and have found numerous…
Ivan Kluzak
  • 655
  • 2
  • 7
  • 11