Is it possible to deploy to localstack with the aws-cdk? Thought about switching from serverless to the cdk, but could not find any ohter local testing option except aws SAM..
You can use the AWS SAM CLI to locally test your AWS CDK applications by running the following commands from the project root directory of your AWS CDK application: sam local invoke. sam local start-api. sam local start-lambda.
AWS CDK is available to define and deploy AWS resources in all public regions. Since AWS CDK leverages the CloudFormation service, refer to Regional Products and Services for details about specific resource availability per AWS Region.
Terraform deploys resources using the AWS SDK, whereas the CDK code is first converted to CloudFormation templates and then applied. Terraform would work slightly faster than AWS CDK, particularly because of the time CDK takes to convert code to CloudFormation Template.
The AWS Cloud Development Kit (AWS CDK) is an open-source software development framework to define your cloud application resources using familiar programming languages.
I'm working through the same challenges right now. The way I'm getting by is taking the synthesized CloudFormation template from CDK and loading that into my LocalStack CloudFormation:
$ cdk synth my-stack > my-stack.template.json
$ awslocal cloudformation create-stack --stack-name my-stack --template-body file://./my-stack.template.json
This is working for me with very simple stacks that do not require artifacts/assets. What I'm still working on here is transposing what CDK does internally with S3 bucket based assets as CloudFormation parameters (e.g. Lambda functions, etc.).
Hopefully this gets you down the road a bit. I feel it's the first part of the solution, given what CDK can do today.
I would point you towards the aws-cdk-local package. This allows you to deploy CDK IaC to your localstack. See aws-cdk-local link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With