Skip to content

Commit 5500b5b

Browse files
Merge pull request #3402 from anupras-mohapatra-arm/aws-cdk
AWS CDK CLI install guide + learning path to deploy containers on Arm-based compute using Amazon ECS + AWS CDK
2 parents 80142a6 + 7a6cd1b commit 5500b5b

7 files changed

Lines changed: 356 additions & 0 deletions

File tree

assets/contributors.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,5 @@ Akash Malik,Arm,akashmalik19973,akash-malik-a65bab219,,
125125
Matt Cossins,Arm,matt-cossins,,,
126126
Sue Wu,Arm,,,,
127127
Sabika Tasneem,Memgraph,,,,
128+
Anupras Mohapatra,Arm,,,,
128129
Tomas Agustin Gonzalez Orlando,Arm,tgonzalezorlandoarm,tgorlando,,

content/install-guides/aws-cdk.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
additional_search_terms:
3+
- cloud
4+
- deploy
5+
layout: installtoolsall
6+
minutes_to_complete: 15
7+
author: Anupras Mohapatra
8+
multi_install: false
9+
multitool_install_part: false
10+
official_docs: https://docs.aws.amazon.com/cdk/v2/guide/home.html
11+
test_images:
12+
- ubuntu:latest
13+
test_maintenance: true
14+
draft: true
15+
title: AWS CDK CLI
16+
description: Install the AWS CDK CLI on Arm Linux and macOS using npm, then verify the setup with the `cdk` command.
17+
tool_install: true
18+
weight: 1
19+
---
20+
21+
The AWS Cloud Development Kit (CDK) is an open-source infrastructure as code (IaC) software development framework. You can use the AWS CDK to define and deploy applications on Arm-based cloud infrastructure powered by AWS Graviton.
22+
23+
With the CDK, you can write applications in a supported programming language of your choice. You can then use the AWS CDK CLI to translate the code into an AWS CloudFormation template and deploy the application.
24+
25+
In this guide, you'll learn how to install the CDK CLI and verify that the CLI installation was successful.
26+
27+
## Before you begin
28+
29+
Make sure that you have the AWS CLI installed:
30+
31+
```bash
32+
aws --version
33+
```
34+
35+
The output is similar to:
36+
37+
```output
38+
aws-cli/2.34.56 Python/3.14.5 Darwin/25.5.0 exe/arm64
39+
```
40+
For more information about setting up AWS credentials and installing the AWS CLI, see the [AWS Credentials](/install-guides/aws_access_keys/) and [AWS CLI](/install-guides/aws-cli/) install guides.
41+
42+
Make sure you have Node.js 22 or later installed:
43+
44+
```bash
45+
node --version
46+
```
47+
48+
The output is similar to:
49+
50+
```output
51+
v26.2.0
52+
```
53+
If you don't have Node.js installed, or if the installed version is earlier than Node.js 22, download a suitable version from the [Node.js website](https://nodejs.org/en/download).
54+
55+
You'll also need to install prerequisites specific to the programming languages that you want to use. For more information about language-specific prerequisites, see [Install Node.js and programming language prerequisites](https://docs.aws.amazon.com/cdk/v2/guide/prerequisites.html#prerequisites-node) in the AWS CDK documentation.
56+
57+
## Install the AWS CDK CLI
58+
59+
Use `npm` to install the AWS CDK CLI:
60+
61+
```bash
62+
npm install -g aws-cdk
63+
```
64+
65+
## Verify the installation
66+
67+
After installing the AWS CDK CLI, check the version of the CLI:
68+
69+
```bash
70+
cdk --version
71+
```
72+
73+
The output is similar to:
74+
75+
```output
76+
2.1125.0 (build 71fd29e)
77+
```
78+
## Next steps
79+
80+
You've now installed the AWS CDK CLI and verified that the installation was successful.
81+
82+
Next, you can use the AWS CDK to create and deploy applications on Arm-based compute powered by AWS Graviton. To learn how you can use the CDK and Amazon Elastic Container Service (ECS) to run containers on Arm-based compute, see [Deploy containers on Arm-based compute using Amazon ECS and the AWS CDK](/learning-paths/servers-and-cloud-computing/aws-cdk/).
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: Deploy containers on Arm-based compute using Amazon ECS and the AWS CDK
3+
description: Learn how to define and deploy a containerized application on Arm-based compute using the AWS Cloud Development Kit.
4+
5+
draft: true
6+
cascade:
7+
draft: true
8+
9+
minutes_to_complete: 45
10+
11+
who_is_this_for: This is an introductory topic for software developers who want to use the AWS Cloud Development Kit (AWS CDK) to deploy applications on Arm-based AWS infrastructure.
12+
13+
learning_objectives:
14+
- Create an example AWS CDK application in JavaScript
15+
- Define AWS infrastructure using the AWS CDK
16+
- Deploy application resources on Arm-based AWS compute using Amazon ECS and the AWS CDK
17+
18+
prerequisites:
19+
- An Amazon Web Services (AWS) account
20+
- A local computer with the AWS CLI, AWS CDK CLI, and Node.js installed
21+
- Familiarity with the Linux command line and JavaScript
22+
23+
author: Anupras Mohapatra
24+
25+
### Tags
26+
skilllevels: Introductory
27+
subjects: Containers and Virtualization
28+
cloud_service_providers:
29+
- AWS
30+
armips:
31+
- Neoverse
32+
operatingsystems:
33+
- Linux
34+
tools_software_languages:
35+
- AWS CDK CLI
36+
- Amazon Elastic Container Service (Amazon ECS)
37+
- AWS CLI
38+
- Node.js
39+
- JavaScript
40+
41+
further_reading:
42+
- resource:
43+
title: AWS CDK Developer Guide
44+
link: https://docs.aws.amazon.com/cdk/v2/guide/home.html
45+
type: documentation
46+
- resource:
47+
title: AWS CDK CLI install guide
48+
link: /install-guides/aws-cdk/
49+
type: install-guide
50+
- resource:
51+
title: AWS CLI install guide
52+
link: /install-guides/aws-cli/
53+
type: install-guide
54+
55+
### FIXED, DO NOT MODIFY
56+
# ================================================================================
57+
weight: 1 # _index.md always has weight of 1 to order correctly
58+
layout: "learningpathall" # All files under learning paths have this same wrapper
59+
learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content.
60+
---
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# ================================================================================
3+
# FIXED, DO NOT MODIFY THIS FILE
4+
# ================================================================================
5+
weight: 21 # Set to always be larger than the content in this path to be at the end of the navigation.
6+
title: "Next Steps" # Always the same, html page title.
7+
layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing.
8+
---
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
title: "Create a sample AWS CDK application"
3+
description: Create a JavaScript AWS CDK application that defines an Amazon ECS service running on Arm-based AWS Fargate compute.
4+
weight: 2
5+
6+
layout: "learningpathall"
7+
---
8+
9+
## Set up a sample AWS CDK application
10+
11+
The AWS Cloud Development Kit (CDK) is an open-source infrastructure as code (IaC) software development framework.
12+
13+
In this section, you'll create a JavaScript CDK application that defines an Amazon Elastic Container Service (ECS) service running on Arm-based AWS Fargate compute.
14+
15+
Arm-based AWS compute is powered by AWS Graviton processors. For more information about AWS Graviton, see [Level up your compute with AWS Graviton](https://aws.amazon.com/ec2/graviton/level-up-with-graviton/).
16+
17+
### Before you begin
18+
19+
Make sure that you've installed the AWS CDK CLI:
20+
21+
```bash
22+
cdk --version
23+
```
24+
25+
The output is similar to:
26+
27+
```output
28+
2.1125.0 (build 71fd29e)
29+
```
30+
31+
For instructions to set up and install the AWS CDK CLI, see the [AWS CDK install guide](/install-guides/aws-cdk).
32+
33+
Make sure you've installed Node.js:
34+
35+
```bash
36+
node --version
37+
```
38+
39+
The output is similar to:
40+
```output
41+
v26.2.0
42+
```
43+
44+
### Initialize a CDK project
45+
46+
Create a directory for your CDK project and navigate to it:
47+
48+
```bash
49+
mkdir arm-cdk-app
50+
cd arm-cdk-app/
51+
```
52+
53+
After navigating into the project directory, initialize a JavaScript CDK project:
54+
55+
```bash
56+
cdk init --language javascript
57+
```
58+
59+
The output is similar to:
60+
61+
```output
62+
Applying project template app for javascript
63+
# Welcome to your CDK JavaScript project
64+
65+
This is a blank project for CDK development with JavaScript.
66+
67+
The `cdk.json` file tells the CDK Toolkit how to execute your app. The build step is not required when using JavaScript.
68+
69+
## Useful commands
70+
71+
* `npm run test` perform the jest unit tests
72+
* `npx cdk deploy` deploy this stack to your default AWS account/region
73+
* `npx cdk diff` compare deployed stack with current state
74+
* `npx cdk synth` emits the synthesized CloudFormation template
75+
76+
...
77+
```
78+
79+
### Use the AWS CDK with JavaScript to define a sample application
80+
81+
In the project, you'll find a file called `arm-cdk-app-stack.js` in the `lib` directory. AWS CDK uses this stack definition to deploy all necessary AWS resources.
82+
83+
Update `lib/arm-cdk-app-stack.js` to define a load-balanced Amazon ECS service that runs an NGINX web server on an Arm-based AWS Fargate runtime platform:
84+
85+
```javascript
86+
const cdk = require('aws-cdk-lib');
87+
const ecs = require('aws-cdk-lib/aws-ecs');
88+
const ecsPatterns = require('aws-cdk-lib/aws-ecs-patterns');
89+
90+
class ArmCdkAppStack extends cdk.Stack {
91+
constructor(scope, id, props) {
92+
super(scope, id, props);
93+
94+
new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'Service', {
95+
taskImageOptions: {
96+
image: ecs.ContainerImage.fromRegistry("nginx:latest"),
97+
containerPort: 80,
98+
},
99+
runtimePlatform: {
100+
cpuArchitecture: ecs.CpuArchitecture.ARM64,
101+
operatingSystemFamily: ecs.OperatingSystemFamily.LINUX,
102+
},
103+
publicLoadBalancer: true,
104+
});
105+
}
106+
}
107+
108+
module.exports = { ArmCdkAppStack };
109+
```
110+
111+
## What you've accomplished and what's next
112+
113+
You've now set up a sample application using AWS CDK.
114+
115+
Next, you'll use AWS CDK to synthesize and deploy the application.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: "Synthesize and deploy the sample AWS CDK application"
3+
description: Synthesize, deploy, verify, and clean up a sample AWS CDK application running on Arm-based AWS Fargate compute.
4+
weight: 3
5+
6+
layout: "learningpathall"
7+
---
8+
9+
## Synthesize the AWS CDK application
10+
11+
Before you can deploy an application using the AWS CDK, you need to synthesize it. During synthesis, the AWS CDK checks for errors in the application code and then translates the code into an AWS CloudFormation template.
12+
13+
Within the project directory, synthesize the application:
14+
15+
```bash
16+
cdk synth
17+
```
18+
You can find the generated JSON template at `cdk.out/ArmCdkAppStack.template.json`.
19+
20+
## Bootstrap the AWS CDK application environment
21+
22+
After synthesizing your application, you need to bootstrap the environment. In this step, the AWS CDK creates resources such as AWS Identity and Access Management (IAM) roles.
23+
24+
Within the project directory, bootstrap the environment:
25+
26+
```bash
27+
cdk bootstrap
28+
```
29+
30+
## Deploy the AWS CDK application
31+
32+
After bootstrapping the environment, you're ready to deploy the application. AWS CDK deploys the application using the AWS CloudFormation stack generated during synthesis and IAM roles created during bootstrap.
33+
34+
Deploy the application:
35+
36+
```bash
37+
cdk deploy
38+
```
39+
By default, the AWS CDK CLI will prompt you to approve IAM-related changes during deployment.
40+
41+
For the AWS CDK CLI to deploy the application without the need for approval, set the `--require-approval` flag to `never` during deployment:
42+
43+
```bash
44+
cdk deploy --require-approval never
45+
```
46+
47+
{{% notice Note %}}
48+
The deployment can take a couple minutes to complete.
49+
{{% /notice %}}
50+
51+
When the deployment completes, the last couple lines of the output will include a URL to the web server and the load balancer's DNS name:
52+
53+
```output
54+
Outputs:
55+
ArmCdkAppStack.MyWebServerLoadBalancerDNSXXXXXXX = Hello-MyWeb-ZZZZZZZZZZZZZ-ZZZZZZZZZZ.us-east-1.elb.amazonaws.com
56+
ArmCdkAppStack.MyWebServerServiceURLYYYYYYYY = http://Hello-MyWeb-ZZZZZZZZZZZZZ-ZZZZZZZZZZ.us-east-1.elb.amazonaws.com
57+
```
58+
59+
## Verify application deployment
60+
61+
Open the URL from the deployment output in a web browser of your choice.
62+
63+
You'll see the following welcome message:
64+
65+
![Screenshot of the application showing the NGINX welcome page and confirming the web server was deployed on Arm-based compute successfully.#center](nginx-output.png "NGINX welcome page indicating successful deployment")
66+
67+
## Clean up AWS resources
68+
69+
After you've validated the deployment, clean up the AWS resources that you created with AWS CDK to avoid incurring costs:
70+
71+
```bash
72+
cdk destroy
73+
```
74+
By default, the AWS CDK CLI will prompt you to approve the deletion of `ArmCDKAppStack`.
75+
76+
For the AWS CDK CLI to clean up resources without the need for approval, use the `--force` or `-f` flag:
77+
78+
```bash
79+
cdk destroy -f
80+
```
81+
82+
{{% notice Note %}}
83+
The cleanup process can take a couple minutes to complete.
84+
{{% /notice %}}
85+
86+
## What you've accomplished
87+
88+
You've now synthesized and deployed a sample containerized application on Arm-based compute using Amazon ECS and the AWS CDK. After verifying that the deployment was successful, you cleaned up resources.
89+
90+
You can use this workflow to programmatically deploy and manage containerized applications on Arm-based compute powered by AWS Graviton processors.
58.7 KB
Loading

0 commit comments

Comments
 (0)