Skip to content

Commit 1e14ba1

Browse files
klangkaiz-io
andauthored
add readme, adjust cdk.json, add platform to Dockerfile, use one NAT (#1106)
Co-authored-by: Michael Kaiser <[email protected]>
1 parent 95212c3 commit 1e14ba1

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Fargate Service with local image
2+
3+
The ecs-pattern `ApplicationLoadBalancedFargateService` will be used to start up a loadbalanced Fargate serice with an image defined locally.
4+
5+
`--platform=linux/amd64` is added to `local-image/Dockerfile` to ensure that the build will succeed when initiated from other platforms.
6+
7+
## Build
8+
9+
To build this app, you need to be in this example's root folder. Then run the following:
10+
11+
```bash
12+
npm install
13+
npx cdk synth
14+
```
15+
16+
After the deployment you will see the API's URL, which represents the url you can then use.
17+
18+
## Deploy
19+
20+
Run `cdk deploy`. This will deploy / redeploy your Stack to your AWS Account.
21+
22+
Deployment takes about 5 minutes.
23+
24+
After the deployment you will see the API's URL, which represents the url you can then use.
25+
26+
27+
## Synthesize Cloudformation Template
28+
29+
To see the Cloudformation template generated by the CDK, run `cdk synth`, then check the output file in the "cdk.out" directory.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"app": "node index"
2+
"app": "npx ts-node --prefer-ts-exts index.ts"
33
}

typescript/ecs/fargate-service-with-local-image/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const stack = new cdk.Stack(app, 'FargateServiceWithLocalImage');
99

1010
// Create VPC and Fargate Cluster
1111
// NOTE: Limit AZs to avoid reaching resource quotas
12-
const vpc = new ec2.Vpc(stack, 'MyVpc', { maxAzs: 2 });
12+
// NAT needed to pull from ECR and to push cloudwatch logs
13+
const vpc = new ec2.Vpc(stack, 'MyVpc', { maxAzs: 2, natGateways: 1 });
1314
const cluster = new ecs.Cluster(stack, 'Cluster', { vpc });
1415

1516
// Instantiate Fargate Service with a cluster and a local image that gets

typescript/ecs/fargate-service-with-local-image/local-image/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use an official Python runtime as a parent image
2-
FROM python:3.4-alpine
2+
FROM --platform=linux/amd64 python:3.4-alpine
33

44
# Set the working directory to /app
55
WORKDIR /app

0 commit comments

Comments
 (0)