aws-cdk | AWS Cloud Development Kit is a framework for defining cloud | Continuous Deployment library
kandi X-RAY | aws-cdk Summary
kandi X-RAY | aws-cdk Summary
The AWS Cloud Development Kit (AWS CDK) is an open-source software development framework to define cloud infrastructure in code and provision it through AWS CloudFormation. It offers a high-level object-oriented abstraction to define AWS resources imperatively using the power of modern programming languages. Using the CDK’s library of infrastructure constructs, you can easily encapsulate AWS best practices in your infrastructure definition and share it without worrying about boilerplate logic.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of aws-cdk
aws-cdk Key Features
aws-cdk Examples and Code Snippets
[research]
aws_access_key_id = AS...SF
aws_secret_access_key = DNS...ebXs
aws_session_token = IQo...OM=
region=us-west-2
[master]
aws_access_key_id = A...LH
aws_secret_access_key = G...8vO2
aws_session_token = IQ...Qo=
region=us-we
mkdir aws-quick-start-eks && cd aws-quick-start-eks
npx cdk init sample-eks --language typescript
npx cdk bootstrap
npm install @smallcase/cdk-eks-cluster-module
yarn add @smallcase/cdk-eks-cluster-module
import {
EKSCluster,
VpcCni
import { Stack, StackProps } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { MicroService } from '@smallcase/aws-cdk-microservice';
import { App } from '@aws-cdk/core';
export class UnknownAPIStackDev extends Stack {
construc
d3.selectAll("svg polygon")
d3.selectAll("svg polygon, svg path")
d3.event.target.id
const data = [
{ "id": "polygon5256", "value": 39.5 }, // roof
{ "id": "pol
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.example.de;
set $forward_scheme https;
# Logging
access_log /var/log/nginx/alllectra.access.log;
error_log
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.example.de;
set $forward_scheme https;
# Logging
access_log /var/log/nginx/alllectra.access.log;
error_log
open System
open System.Threading.Tasks
open Quartz
open Quartz.Impl
type Job() =
interface IJob with
member _.Execute(_context) =
Console.Out.WriteLineAsync(DateTime.Now.ToString())
task {
// Grab the Schedu
"Role" : {"Fn::GetAtt" : ["NFTCalculateCIDLambdaRole", "Arn"] }
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Lambda Function + IAM role Resources",
"Resources": {
"NFTCalculateCID
catchAsyncExceptions({
membersClient.getUserLocation(
GetUserLocationRequest(userId)
)
.thenApply({ response ->
val (success, error) = parseSuccessAndError(response.result!!)
error?.let({
// App.jsx
} />
} />
// App.jsx
} />
} />
// HomePage.jsx
export function HomePage(props) {
useEffect(() => document.title = props.title, [])
return ...
}
Community Discussions
Trending Discussions on aws-cdk
QUESTION
I have installed js-yaml
with this command
ANSWER
Answered 2022-Apr-11 at 07:49The @types/js-yaml
contains only type definitions used by TypeScript compiler to verify your code. However, it doesn't contain the actual implementation required at runtime.
You should install npm install js-yaml --save
.
QUESTION
I am having some trouble getting all items from a DynamoDB table. I am following the example from the AWS GitHub repo. Here is the code I have
...ANSWER
Answered 2022-Mar-26 at 15:34You missed .promise()
, so it don't await until the request is completed.
QUESTION
I'm trying to use CDK and CodePipeline to build and deploy a React application to S3. After the CodePipeline
phase, in my own stack, I defined the S3 bucket like this:
ANSWER
Answered 2022-Jan-28 at 07:51For the first question:
And if I change to Source.asset("./build") I get the error: ... Why is it searching for the build directory on my machine?
This is happening when you run cdk synth
locally. Remember, cdk synth
will always reference the file system where this command is run. Locally it will be your machine, in the pipeline it will be in the container or environment that is being used by AWS CodePipeline.
Dig a little deeper into BucketDeployment
But also, there is some interesting things that happen here that could be helpful. BucketDeployment
doesn't just pull from the source you reference in BucketDeployment.sources
and upload it to the bucket you specify in BucketDeployment.destinationBucket
. According to the BucketDeployment docs the assets are uploaded to an intermediary bucket and then later merged to your bucket. This matters because it will explain your error received Error: Cannot find asset at C:\Users\pupeno\Code\ww3fe\build
because when you run cdk synth
it will expect the dir ./build
as stated in Source.asset("./build")
to exist.
This gets really interesting when trying to use a CodePipeline
to build and deploy a single page app like React in your case. By default, CodePipeline will execute a Source
step, followed a Synth
step, then any of the waves or stages you add after. Adding a wave that builds your react app won't work right away because we now see that the output directory of building you react app is needed during the Synth
step because of how BucketDeployment
works. We need to be able to have the order be Source -> Build -> Synth -> Deploy. As found in this question, we can control the order of the steps by using inputs and outputs. CodePipeline will order the steps to ensure input/output dependencies are met. So we need the have our Synth step use the Build's output as its input.
Concerns with the currently defined pipeline
I believe that your current pipeline is missing a CodeBuildStep
that would bundle your react app and output it to the directory that you specified in BucketDeployment.sources
. We also need to set the inputs to order these actions correctly. Below are some updates to the pipeline definition, though some changes may need to be made to have the correct file paths. Also, set BucketDeployment.sources
to the dir where your app bundle is written to.
QUESTION
I'd like to secure my webapp running in an ECS Fargate container with Cognito. Using the convenient ecspatterns.ApplicationLoadBalancedFargateService
with the Cognito example given at AuthenticateCognitoAction
shown at https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-elasticloadbalancingv2-actions.AuthenticateCognitoAction.html is giving me a headache.
I've tried to first create the LoadBalancer
shown in the Cognito example and then pass it as the loadBalancer
parameter in ApplicationLoadBalancedFargateService
constructor. And I've also tried first creating the ApplicationLoadBalancedFargateService
and then doing fargateService.loadBalancer.addListener
to add the Cognito Listener. Both solutions fail with:
ANSWER
Answered 2022-Feb-15 at 11:41Thanks to this demo stack I found that you:
- create the Cognito User Pool and Client
- create
ApplicationLoadBalancedFargateService
- add a
AuthenticateCognitoAction
to the fargateService listener like this:
QUESTION
I recently set up an application on AWS via CDK. The application consists of a Dockerized nodejs application, which connects to an RDS instance, and has a Redis caching layer as well. After having the application deployed for a few days, the costs are much higher than I had anticipated, even with minimal traffic. After looking through the cost explorer, it looks like half of the cost is coming from the NAT gateways.
In my current setup, I have created two VPCs. One is used for the application stack, and the other is for the CodePipeline. I needed to add one for the pipeline because without it I was hitting rate limits when trying to pull Docker images during the CodeBuildAction steps.
I'm not very comfortable with the networking bits, but I feel like there are extra resources involved. The pipeline VPC has three NAT gateways and three EIPs. These end up just sitting there waiting for the next deployment, which seems like a huge waste. It seems like a new gateway + EIP is allocated for each construct the VPC is attached to in CDK. Can I just make it reuse the same one? Is there an alternative to adding a VPC at all and not getting rate limited by Docker?
I also find it very surprising (I might just be naive) that the NAT gateway is so far equally as expensive as my current Fargate task costs. Is there an alternative that would serve my purposes, but come at a little lower cost?
Anyways, here are my two stacks:
...ANSWER
Answered 2022-Feb-11 at 11:08I would strongly advise moving from the Docker directory to ECR public gallery to avoid ratelimit issues: https://gallery.ecr.aws/
That said, to answer the question about the number of NATs created. As you can see in the CDK docs, what you're seeing reflects the default behavior (emphasis mine):
A VPC consists of one or more subnets that instances can be placed into. CDK distinguishes three different subnet types:
Public (SubnetType.PUBLIC) - public subnets connect directly to the Internet using an Internet Gateway. If you want your instances to have a public IP address and be directly reachable from the Internet, you must place them in a public subnet.
Private with Internet Access (SubnetType.PRIVATE_WITH_NAT) - instances in private subnets are not directly routable from the Internet, and connect out to the Internet via a NAT gateway. By default, a NAT gateway is created in every public subnet for maximum availability. Be aware that you will be charged for NAT gateways.
Isolated (SubnetType.PRIVATE_ISOLATED) - isolated subnets do not route from or to the Internet, and as such do not require NAT gateways. They can only connect to or be connected to from other instances in the same VPC. A default VPC configuration will not include isolated subnets,
A default VPC configuration will create public and private subnets. However, if natGateways:0 and subnetConfiguration is undefined, default VPC configuration will create public and isolated subnets.
So a separate NAT is created for every Public subnet.
Also, the docs for the natGateways
parameter mentioned above also describe the default behavior:
(default: One NAT gateway/instance per Availability Zone)
To limit the number of AZs used by the VPC, specify the maxAzs
parameter. Set it to 1 to only have a single NAT per VPC.
If you're fine with making the resources in the VPC publicly reachable from the internet, you can place them in Public subnets and avoid the creation of NATs altogether.
QUESTION
I use CDK to deploy a codepipeline. It works fine until I try to add notification for codepipeline success/fail events. It gives CREATE_FAILED
error with message Resource handler returned message: "Invalid request provided: AWS::CodeStarNotifications::NotificationRule" (RequestToken: bb566fd0-1ac9-5d61-03fe-f9c27b4196fa, HandlerErrorCode: InvalidRequest)
. What could be the reason? Thanks.
ANSWER
Answered 2022-Feb-09 at 09:02This is because imported resources cannot be modified. As you pointed out in the comments, setting up the notification involves modifying the Topic resource, specifically its access policy.
Reference: https://docs.aws.amazon.com/cdk/v2/guide/resources.html#resources_importing
QUESTION
I am trying to understand how cdk bootstrap works. I have read the doc: https://github.com/aws/aws-cdk/blob/master/design/cdk-bootstrap.md and tried to run the command in my AWS account. I can see a new cf stack is created CDKToolkit
which includes s3 bucket, iam roles etc.
My question is whether I need to run this command for every cdk project I have? Or is it just one time execution? If I have projects using different cdk version v1 and v2, do I use the same cf stack? Will it cause version conflicts?
...ANSWER
Answered 2022-Feb-07 at 07:04It's typically a one time thing per account per region. The infrastructure in that stack is shared among your CDK apps.
There was a change in format a while ago that required an update of the stack, but since then it has remained largely unchanged.
The docs on bootstrap are probably more helpful than the Github Link: CDK Bootstrapping.
Each CloudFormation stack created by a CDK app only belongs to one CDK app, they shouldn't be shared. The outputs can be referenced from other apps, but each stack should belong to one app.
That's why you can mix and match CDK versions across different stacks. Usually each CDK app maps to one or more CloudFormation stacks.
QUESTION
I have the following AWS CDK pipeline which works. It basically takes source from 2 different GitHub repositories (one for the application code, one for the cdk code) and builds the application code and the cdk code :
...ANSWER
Answered 2022-Feb-04 at 15:36So I found a solution. Maybe not the solution. Indeed, this seems quite convoluted ... and I am sure there is a better way.
So the solution lies in the fact that the ShellStep in the CodePipeline construct attaches the output of additionalInputs
(so the result of the previous CodeBuildStep i.e. lambdaBuildStep
) in a specific directory which is dynamically generated but stored in an environment variable called CODEBUILD_SRC_DIR_BuildLambda_lambda_repo
so you can see it's a combination of the name of the CodeBuildStep and the repo (with the dash changed to underscores).
So my solution was to use this environment variables as my Lambda code asset.
QUESTION
I'm using CDK to deploy a CodePipeline that builds and deploys a React application to S3. All of that is working, but I want the deployment to update a domain name to point that S3 bucket.
I already have the Zone defined in Route53 but it is defined by a different cloud formation stack because there are a lot of details that are not relevant for this app (MX, TXT, etc). What's the right way for my Pipeline/Stacks to set those domain names?
I could think of two solutions:
- Delegate the domain to another zone, so zone
example.com
delegatesstaging.example.com
. - Have my pipeline inject records into the existing zone.
I didn't try the delegation zone method. I was slightly concerned about manually maintaining the generated nameservers from staging.example.com
into my CloudFormation for zone example.com
.
I did try injecting the records into the existing zone, but I run into some issues. I'm open to either solving these issues or doing this whichever way is correct.
In my stack (full pipeline at the bottom) I first define and deploy to the bucket:
...ANSWER
Answered 2022-Jan-31 at 16:31You cannot depend on CDK pipeline to fix itself if the synth stage is failing, since the Pipeline CloudFormation Stack is changed in the SelfMutate stage which uses the output of the synth stage. You will need to do one of the following options to fix your pipeline:
Run
cdk synth
andcdk deploy PipelineStack
locally (or anywhere outside the pipeline, where you have the required AWS IAM permissions). Edit: You will need to temporarily set selfMutatation tofalse
for this to work (Reference)Temporarily remove
route53.HostedZone.fromLookup
androute53.CnameRecord
from your MainStack while still keeping therolePolicyStatements
change. Commit and push your code, let CodePipeline run once, making sure that the Pipeline self mutates and the IAM role has the required additional permissions. Add back the route53 constructs, commit, push again and check whether your code works with the new changes.
QUESTION
I'm fairly new (today its the first day) with Amazon CDK. I have been currently following the initial tutorial in Amazon's CDK page.
I have installed aws
and cdk
:
ANSWER
Answered 2022-Jan-05 at 19:25This is extremely stupid mistake. I currently have 2 users in my machine setup and I was using the wrong one to deploy.
After performing aws configure
with the credentials of the correct account I was able to deploy
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install aws-cdk
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page