aws-cdk

CDK override bind when using LambdaIntegration

孤人 提交于 2020-02-03 10:21:31
问题 When using LambdaIntegration class the bind function add permission to the lambda automatically: bind(method) { super.bind(method); const principal = new iam.ServicePrincipal('apigateway.amazonaws.com'); const desc = `${method.restApi.node.uniqueId}.${method.httpMethod}.${method.resource.path.replace(/\//g, '.')}`; this.handler.addPermission(`ApiPermission.${desc}`, { principal, scope: method, sourceArn: method.methodArn, }); // add permission to invoke from the console if (this.enableTest) {

CDK split API Gateway stack into 2 small stacks

不问归期 提交于 2020-01-24 10:50:50
问题 I'm trying to create a CDK stack in order to create API Gateway. Everything working as excepted if I create the stack in "small pieces" (comment part of the resources), But when I'm trying to create the completed stack I'm getting this exception: Number of resources, 224, is greater than maximum allowed, 200 Therefore, I tried to split my big stack into 2 smaller stacks, One stack creates the resource and create half of the resources and the other one fill relevant data. My structure is like

CDK split API Gateway stack into 2 small stacks

两盒软妹~` 提交于 2020-01-24 10:50:08
问题 I'm trying to create a CDK stack in order to create API Gateway. Everything working as excepted if I create the stack in "small pieces" (comment part of the resources), But when I'm trying to create the completed stack I'm getting this exception: Number of resources, 224, is greater than maximum allowed, 200 Therefore, I tried to split my big stack into 2 smaller stacks, One stack creates the resource and create half of the resources and the other one fill relevant data. My structure is like

What IAM permissions are needed to use CDK Deploy?

血红的双手。 提交于 2020-01-22 16:18:29
问题 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 execution IAM role. We recently switched to the CDK, and are trying to get as much automated with using CDK Deploy as possible, but are running into a lot of permission items we need to add which we didn't have prior (for instance, cloudformation

What IAM permissions are needed to use CDK Deploy?

天涯浪子 提交于 2020-01-22 16:18:05
问题 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 execution IAM role. We recently switched to the CDK, and are trying to get as much automated with using CDK Deploy as possible, but are running into a lot of permission items we need to add which we didn't have prior (for instance, cloudformation

Unable to write policy document in aws cdk using python

给你一囗甜甜゛ 提交于 2020-01-05 07:16:12
问题 Hi I am working on AWS CDK. I am trying to create policy. Below is my code. MWSECSServiceRole = iam.Role(self, 'MWSECSServiceRole', assumed_by=iam.ServicePrincipal('ecs.amazonaws.com')) MWSECSServiceRole.add_to_policy(iam.PolicyStatement( effect=iam.Effect.ALLOW, resources=["arn:aws:elasticloadbalancing:*:{AccountId}:loadbalancer/app/mws-*","arn:aws:elasticloadbalancing:*:{AccountId}:listener-rule/app/mws-*","arn:aws:elasticloadbalancing:*:{AccountId}:listener/app/mws-*","arn:aws

How to add a tag to an AWS-CDK construct

左心房为你撑大大i 提交于 2019-12-24 10:57:16
问题 How to add a tag to an AWS-CDK specific construct or even better one tag definition to all ressources created within the stack? 回答1: According to aws-cdk doc you can add a tag to all constructs/ressources. Tags will inherits to constructs within same "tree". That's pretty cool. Example using aws-cdk based on java: MyStack stack = new MyStack(app, "nameOfStack"); stack.apply(new Tag("tag_foo", "value_bar")); AWS-Doc CDK Tagging Tags can be applied to any construct. Tags are inherited, based on

Adding eventSource to Lambda by ARN in CDK

时光总嘲笑我的痴心妄想 提交于 2019-12-13 20:09:11
问题 I have a lambda function which reads from Dynamodb stream. I have the Dynamodb stream ARN exported from another stack in the same AWS account. Now, while adding eventSource in Lambda, it asks from Table construct. const function = new lambda.Function(...); function.addEventSource(new DynamoEventSource(table, { startingPosition: lambda.StartingPosition.TrimHorizon })); Ref: https://awslabs.github.io/aws-cdk/refs/_aws-cdk_aws-lambda-event-sources.html#dynamodb-streams But I have the stream ARN.

ENOENT error - Installing aws-cdk node module

て烟熏妆下的殇ゞ 提交于 2019-12-11 07:49:42
问题 After running command: sudo npm i -g aws-cdk gives error: npm ERR! Linux 4.4.0-151-generic npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "i" "-g" "aws-cdk" npm ERR! node v4.2.6 npm ERR! npm v3.5.2 npm ERR! path /usr/local/lib/node_modules/.staging/semver-096e2ca7 npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall rename npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/semver-096e2ca7' -> '/usr/local/lib/node_modules/aws-cdk/node_modules/

Does AWS CDK create default stack name in CloudFormation?

人盡茶涼 提交于 2019-12-11 05:57:23
问题 Using CloudFormation template, CloudFormation service ask for a stack name( AWS::StackName ) before applying the template. Using AWS CDK, we run cdk synth to create cfn template & cdk deploy to deploy services based on the template. Does AWS CDK create default stack name in Cloudformation service? after running cdk deploy 回答1: In order to create a stack you have to instantiate an object for that stack. When you do, you pass the stack name as a parameter. Example in Python: class MyStackClass: