aws-cdk

On aws-rds on aws-cdk, where is the setting to make database publicly accessible?

此生再无相见时 提交于 2020-06-14 06:28:08
问题 With AWS RDS, the console and the CLI/API both have a switch to make the database publicly accessible, but I cannot find a way to do this with the new aws-cdk using the constructs provided. There is a boolean for this in the Cloud Formation classes (e.g. CfnDBInstance), but I can't find documentation on how to use that in combination with the constructs. The CDK is pretty amazing, and it set up everything perfectly with just a few lines of code, except for this one piece. 回答1: Whether the

Specifying a custom role for lambda with the AWS CDK

一世执手 提交于 2020-06-13 20:23:08
问题 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 = require('@aws-cdk/aws-lambda'); const iam = require('@aws-cdk/aws-iam'); const path = require('path'); class MyStack extends cdk.Stack { constructor (parent, id, props) { super(parent, id, props); // // Create a lambda... const fn = new lambda.Function(this, 'MyFunction

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

拜拜、爱过 提交于 2020-06-01 07:39:31
问题 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, StackProps props) { SingletonFunction myLambda = SingletonFunction.Builder.create(this, "myLambda") // some code here .build() CfnOutput myLambdaArn = CfnOutput.Builder.create(this, "myLambdaArn") .exportName("myLambdaArn") .description("ARN of the

AWS CDK user pool authorizer

别等时光非礼了梦想. 提交于 2020-05-25 17:52:45
问题 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 do not exist? const cdk = require('@aws-cdk/cdk'); const lambda = require('@aws-cdk/aws-lambda'); const apigw = require('@aws-cdk/aws-apigateway'); const path = require('path'); // // Define the stack: class MyStack extends cdk.Stack { constructor

AWS CDK user pool authorizer

半城伤御伤魂 提交于 2020-05-25 17:49:37
问题 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 do not exist? const cdk = require('@aws-cdk/cdk'); const lambda = require('@aws-cdk/aws-lambda'); const apigw = require('@aws-cdk/aws-apigateway'); const path = require('path'); // // Define the stack: class MyStack extends cdk.Stack { constructor

Cloudfront give Access denied response created through AWS CDK Python for S3 bucket origin without public Access

谁说我不能喝 提交于 2020-05-16 07:52:06
问题 Created Cloud Front web distribution with AWS CDK for S3 bucket without public access. Able to create Origin access identity, and deploy but on successful deploy i get access denied response on browser. Grant Read Permissions on Bucket from Origin settings will be set to No, setting this to Yes manually everything will work fine, but this setting needs to be achieved through AWS CDK and python. Below is my code. from aws_cdk import aws_cloudfront as front, aws_s3 as s3 class CloudFrontStack

Add Conditions to Resources in CDK

大兔子大兔子 提交于 2020-04-14 08:44:34
问题 I have created a CDK stack that will be deployed in multiple regions. One of the constructs shall only be deployed in one region. In Cloudformation I'd simply add a Condition to the resource, but I haven't found a way to do something similar with CDK constructs. It is possible to define a CfnCondition and add it to CfnResource s, but I how do I add conditions to constructs like lambda functions? 回答1: Here is a example on how to achieve this for a iam.User : // Create a CloudFormation

How to package AWS CDK into Lambda layer?

我们两清 提交于 2020-03-24 09:43:08
问题 What is the best way to bundle up the AWS CDK as a Lambda layer please? I need to call the CDK from a Java process, so wish to use the Java 11 runtime and then install Nodejs and the CDK as 2 separate layers. Currently I download the Nodejs binaries and then use something like the following: LayerVersion nodeLayer = LayerVersion.Builder.create(this, "node-layer") .description("Layer containing Node.js") .code( Code.fromAsset(somePathToNodejs) ) .build(); then refer to the layer within the

How to automatically put environment variable to all lambdas created in my CDK project

只谈情不闲聊 提交于 2020-03-04 19:39:50
问题 We implement almost all our lambda's in Chalice and then consume them in CDK project as described here. I need to add same environment variable to all lambda's in stack (different per developer). I would like to do it automatically, and not count on every developer adding variable to Chalice stage configuration. I can't use AWS Systems Manager Parameter Store, because it's the same for all dev stacks - we share the same AWS account. I can parse final cloudformation template before deploy and

Hash in the Logical Id of the resources in CDK/Cloudformation

狂风中的少年 提交于 2020-02-25 03:58:28
问题 Whenever I generate cloudformation template from CDK, I see that in logical ids, it adds some kind of Hash. What does that Hash mean? Eg. Test4FCEEF4A How does this Hash 4FCEEF4A gets generated? 回答1: The logical IDs for resources are set using the allocateLogicalId method which you can find here. It calls the makeUniqueId method which you can find here. In the makeUniqueId method, it creates a hash component of the logical ID and a human -readable component of the logical ID. It uses the