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
24
votes
1 answer

Write S3 objects with CDK

I am trying to code a CDK doing the job of writing some empty objects inside some folders that I need to be visible in my bucket. I have found this answer…
Nicola Ben
  • 10,615
  • 8
  • 41
  • 65
23
votes
2 answers

When to use AWS CloudfrontWebDistribution and when to use AWS Cloudfront Distribution

I see in aws-cdk there are two constructs: CloudFrontWebDistribution Distribution Each have different props that do not look compatible with each other. I'm wondering which one to use?
Stoyan Georgiev
  • 345
  • 2
  • 8
23
votes
2 answers

Unexpected token { ../node_modules/fs-extra/lib/mkdirs/make-dir.js:85 } catch {

I am facing this issue while building my application- 2020-07-12 16:48:39 ....: ^ SyntaxError: Unexpected token { at createScript (vm.js:80:10) at Object.runInThisContext (vm.js:139:10) at Module._compile…
tg_anon
  • 231
  • 1
  • 3
  • 6
23
votes
3 answers

How to get logical ID of resource with CDK?

I'm attempting to write some tests for a CDK Construct that validates security group rules defined as part of the construct. The Construct looks something like the following. export interface SampleConstructProps extends StackProps { …
jaredready
  • 2,398
  • 4
  • 23
  • 50
23
votes
1 answer

Purpose and scope of AWS CDK bootstrap stack?

The docs on AWS CDK boostrapping state of the cdk bootstrap command: cdk bootstrap Deploys a CDKToolkit CloudFormation stack into the specified environment(s), that provides an S3 bucket that cdk deploy will use to store synthesized templates and…
John
  • 10,837
  • 17
  • 78
  • 141
22
votes
6 answers

How to install external modules in a Python Lambda Function created by AWS CDK?

I'm using the Python AWS CDK in Cloud9 and I'm deploying a simple Lambda function that is supposed to send an API request to Atlassian's API when an Object is uploaded to an S3 Bucket (also created by the CDK). Here is my code for CDK Stack: from…
Jamie
  • 1,530
  • 1
  • 19
  • 35
22
votes
5 answers

How to add a tag to an AWS-CDK construct

How to add a tag to an AWS-CDK specific construct or even better one tag definition to all ressources created within the stack?
Sma Ma
  • 3,343
  • 2
  • 31
  • 39
22
votes
9 answers

AWS CDK user pool authorizer

I'm trying to create an API gateway using the AWS-CDK and protect the REST endpoints with a Cognito user pool authorizer. I cannot find any examples how one would do this. I thought it should look something like this but maybe the methods I need…
Ivan Kluzak
  • 655
  • 2
  • 7
  • 11
20
votes
10 answers

ModuleNotFoundError: No module named aws_cdk

When I run cdk deploy, I get the following error: Traceback (most recent call last): File "app.py", line 3, in from aws_cdk import core ModuleNotFoundError: No module named 'aws_cdk' I installed cdk with npm npm install -g aws-cdk I…
MoneyBall
  • 2,343
  • 5
  • 26
  • 59
19
votes
4 answers

Error: Cannot find module 'aws-sdk' in NodeJS AWS Lambda Function

I am trying to access S3 via aws-sdk in my lambda function. import S3 from 'aws-sdk/clients/s3'; const s3 = new S3(); const { Contents: results } = await s3.listObjects({ Bucket: process.env.DOCUMENTS_BUCKET_NAME! }).promise() I have also deployed…
daydreamer
  • 87,243
  • 191
  • 450
  • 722
19
votes
3 answers

The difference between a Stack and Construct in AWS CDK

I'm new to CDK and confused about the difference between a Construct and a Stack. With CDK, we can define reusable cloud components known as Construct, and we can further compose these together into a Stack or Apps. See the diagram from AWS website…
Yunhan Zou
  • 369
  • 3
  • 14
18
votes
1 answer

How to manage multiple environments using aws cdk?

I am moving our infra code from Terraform to AWS cdk. And I am trying to find an optimal way to manage multiple environments that have multiple stacks to be deployed. If I go by the recommendation in the documentation, I would have to define…
Keshav Potluri
  • 479
  • 5
  • 15
17
votes
3 answers

aws cdk appsync Schema Creation Status is FAILED with details: Internal Failure while saving the schema

Given the following graphql schema # graphql/schema.graphql type AppUser { userId: String fullName: String } type Query { getUser(userId: String): AppUser getUsers(): [AppUser] } type Mutation { addUser(user: AppUser!): AppUser } And…
55 Cancri
  • 1,075
  • 11
  • 23
17
votes
3 answers

AWS CDK passing API Gateway URL to static site in same Stack

I'm trying to deploy an S3 static website and API gateway/lambda in a single stack. The javascript in the S3 static site calls the lambda to populate an HTML list but it needs to know the API Gateway URL for the lambda integration. Currently, I…
Tim
  • 435
  • 1
  • 4
  • 12
17
votes
5 answers

AWS CDK -- Cannot find module '@aws-cdk/aws-ec2'

I just started playing around with AWS CDK yesterday and I found something very weird. First of all, I'm using TypeScript for my CDK app (I used cdk init --language typescript to generate the project files and I tried to import aws-ec2 module so…
blue2609
  • 841
  • 2
  • 10
  • 25