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
52
votes
5 answers

What IAM permissions are needed to use CDK Deploy?

My team has a pipeline which runs under an execution IAM role. We want to deploy code to AWS through CloudFormation or the CDK. In the past, we would upload some artifacts to S3 buckets before creating/updating our CloudFormation stack, using the…
Alan Kay
  • 655
  • 1
  • 5
  • 7
44
votes
27 answers

How to resolve: 'Unable to resolve AWS account to use. It must be either configured when you define your CDK or through the environment'

I am trying to run CDK commands to check the diff of my local and remote stack. I am using the following command. cdk diff --profile saml I am getting the following error message Unable to resolve AWS account to use. It must be either configured…
36
votes
3 answers

How to import existing VPC in aws cdk?

Hi I am working on aws cdk. I am trying to get existing non-default vpc. I tried below options. vpc = ec2.Vpc.from_lookup(self, id = "VPC", vpc_id='vpcid', vpc_name='vpc-dev') This results in below error [Error at /LocationCdkStack-cdkstack]…
Niranjan
  • 1,881
  • 6
  • 44
  • 71
31
votes
1 answer

AWS CDK: How to create an IAM role that can be assumed by multiple principals?

I'm deploying a Lambda function that will be used by CloudFront. The execution role for the function therefore needs to be assumed by edgelambda.amazonaws.com and lambda.amazonaws.com. If I was doing this by hand, the policy would look like this: { …
Philip Colmer
  • 1,426
  • 2
  • 17
  • 30
28
votes
3 answers

How to resolve "The maximum number of addresses has been reached" for AWS VPC Elastic IP addresses?

I'm working with CDK/CloudFormation and recently started getting this error when attempting to create a new stack: The maximum number of addresses has been reached. Looking in the AWS Management Console, there is a limit of 40 VPC IP addresses and…
28
votes
1 answer

Deploy multiple API Gateway stages with AWS CDK

API Gateway has the concept of stages (e.g: dev, test, prod), and deploying multiple stages via the AWS Console is very straightforward. Is it possible to define and deploy multiple stages with AWS CDK? I've tried but so far it does not seem…
Darragh Enright
  • 13,676
  • 7
  • 41
  • 48
27
votes
10 answers

Need to perform AWS calls for account xxx, but no credentials have been configured

I'm trying to deploy my stack to aws using cdk deploy my-stack. When doing it in my terminal window it works perfectly, but when im doing it in my pipeline i get this error: Need to perform AWS calls for account xxx, but no credentials have been…
gospecomid12
  • 712
  • 3
  • 11
  • 25
27
votes
7 answers

Argument of type 'this' not assignable to parameter 'Construct'

I am trying to call a lambda function into a 'sample app' stack and it is giving me an error because I am trying to pass it a parameter of 'this'. Here is my lambda function export async function handler(event) { console.log("request:",…
aroe
  • 499
  • 1
  • 6
  • 15
26
votes
10 answers

How to solve CDK CLI version mismatch

I'm getting following error: This CDK CLI is not compatible with the CDK library used by your application. Please upgrade the CLI to the latest version. (Cloud assembly schema version mismatch: Maximum schema version supported is 8.0.0, but found…
Maciej
  • 1,209
  • 4
  • 16
  • 26
26
votes
5 answers

AWS CDK: how do I reference cross-stack resources in same app?

I have an App that has two stacks, both within the same region/account. One of those stacks requires the ARN of a lambda that exists in the other stack. How do I reference this? // within stackA constructor public StackA(Construct scope, String id,…
John
  • 10,837
  • 17
  • 78
  • 141
26
votes
2 answers

How can I create a DependsOn relation between EC2 and RDS using aws-cdk

I am currently using the aws-cdk (TypeScript) to create a stack that consists of an EC2 instance and a RDS databaseInstance. The RDS instance needs to be setup before the EC2 instance can be started and userdata will be executed. The problem I have…
F. Werkmeister
  • 263
  • 1
  • 3
  • 5
26
votes
6 answers

Specifying a custom role for lambda with the AWS CDK

I realize it's pretty new but I don't see any examples in any language how you would specify a role for the lambda created with the AWS CDK. I was attempting to do this const cdk = require('@aws-cdk/cdk'); const lambda =…
Ivan Kluzak
  • 655
  • 2
  • 7
  • 11
25
votes
9 answers

Default credentials can not be used to assume new style deployment roles

Following pipelines readme to set up a deployment pipeline, I ran $ env CDK_NEW_BOOTSTRAP=1 npx cdk bootstrap \ --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess \ aws://[ACCOUNT_ID]/us-west-2 to create the…
heckeop
  • 387
  • 1
  • 3
  • 6
25
votes
1 answer

AWS CDK - Vague error while creating an AWS ECS service

I have the following CDK code to create an ECS service. Note: The stack is not fully configured as yet, specifically I don't have the docker image asset or any capacity attached to the cluster. My intention is to what minimum code is needed to set…
nija
  • 455
  • 1
  • 5
  • 8
24
votes
2 answers

AWS CDK generated resource identifiers are horrible and not readable. Any way to fix this?

Anyone, that has used AWS CDK suffers from horrible resource identifiers. Examples of Stacks/Nested Stacks names: Or examples of resource names: These identifiers are horrible to read. Is there any work-around to override these identifiers? I…
Laimonas Sutkus
  • 3,247
  • 2
  • 26
  • 47
1
2 3
99 100