Skip to content

Commit dd31acd

Browse files
add docs for cdk integration #14
1 parent d047d25 commit dd31acd

File tree

1 file changed

+85
-1
lines changed
  • content/en/docs/Integrations/aws-cdk

1 file changed

+85
-1
lines changed

Diff for: content/en/docs/Integrations/aws-cdk/index.md

+85-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,89 @@ description: >
88
---
99

1010
![AWS CDK](aws-cdk-logo.svg)
11+
## Overview
12+
13+
The AWS Cloud Development Kit (CDK) is an IaC (Infrastructure-as-Code) tool using general-purpose programming languages such as TypeScript/JavaScript, Python, Java and .NET to programmatically define your cloud architecture on AWS.
14+
15+
## AWS CDK CLI for LocalStack
16+
17+
`cdklocal` is a thin wrapper script for using the [AWS CDK](https://github.com/aws/aws-cdk) library against local APIs provided by [LocalStack](https://github.com/localstack/localstack).
18+
19+
### Installation
20+
21+
The `cdklocal` command line is published as an [npm library](https://www.npmjs.com/package/aws-cdk-local):
22+
23+
```bash
24+
# Install globally
25+
npm install -g aws-cdk-local aws-cdk
26+
27+
# Verify it installed correctly
28+
cdklocal --version
29+
# e.g. 1.65.5
30+
```
31+
32+
{{% alert title="Local node_modules" color=" ing" %}}
33+
Using `cdklocal` locally (e.g. within the `node_modules` of your repo instead of globally installed) does not work at the moment for some setups, so make sure you install both `aws-cdk` and `aws-cdk-local` with the `-G` flag.
34+
{{% /alert %}}
35+
36+
### Usage
37+
38+
`cdklocal` can be used as a drop-in replacement of where you would otherwise use `cdk` when targeting the AWS Cloud.
39+
40+
```bash
41+
cdklocal --help
42+
```
43+
### Configuration
44+
45+
46+
The following environment variables can be configured:
47+
48+
* `EDGE_PORT`: Port under which LocalStack edge service is accessible (default: `4566`)
49+
* `LOCALSTACK_HOSTNAME`: Target host under which LocalStack edge service is accessible (default: `localhost`)
50+
* `LAMBDA_MOUNT_CODE`: Whether to use local Lambda code mounting (via setting `__local__` S3 bucket name)
51+
52+
53+
### Example
54+
55+
Make sure that LocalStack is installed and successfully started with the required services before running the example
56+
57+
```bash
58+
curl http://localhost:4566/health
59+
```
60+
61+
The CDK command line ships with a sample app generator to run a quick test for getting started.
62+
63+
```bash
64+
# create sample app
65+
mkdir /tmp/test; cd /tmp/test
66+
cdklocal init sample-app --language=javascript
67+
68+
# deploy the sample app
69+
cdklocal deploy
70+
> Do you wish to deploy these changes (y/n)? y
71+
```
72+
73+
Once the deployment is done, you can inspect the created resources via the [`awslocal`](https://github.com/localstack/awscli-local) command line
74+
75+
```bash
76+
awslocal sns list-topics
77+
# {
78+
# "Topics": [
79+
# {
80+
# "TopicArn": "arn:aws:sns:us-east-1:000000000000:TestStack-TestTopic339EC197-79F43WWCCS4Z"
81+
# }
82+
# ]
83+
# }
84+
```
85+
## External resources
86+
87+
- [aws-cdk-local](https://github.com/localstack/aws-cdk-local)
88+
- [AWS CDK API reference](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-construct-library.html)
89+
- [AWS CDK Developer Guide](https://docs.aws.amazon.com/cdk/latest/guide/home.html)
90+
91+
## Community resources
92+
93+
- https://blog.dennisokeeffe.com/blog/2021-08-07-using-the-aws-cdk-with-localstack-and-aws-cdk-local
94+
- https://www.youtube.com/watch?v=3_sqr0G9zb0
95+
1196

12-
TODO

0 commit comments

Comments
 (0)