Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions typescript/ecs/fargate-service-with-local-image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Fargate Service with local image

The ecs-pattern `ApplicationLoadBalancedFargateService` will be used to start up a loadbalanced Fargate serice with an image defined locally.

`--platform=linux/amd64` is added to `local-image/Dockerfile` to ensure that the build will succeed when initiated from other platforms.

## Build

To build this app, you need to be in this example's root folder. Then run the following:

```bash
npm install
npx cdk synth
```

After the deployment you will see the API's URL, which represents the url you can then use.

## Deploy

Run `cdk deploy`. This will deploy / redeploy your Stack to your AWS Account.

Deployment takes about 5 minutes.

After the deployment you will see the API's URL, which represents the url you can then use.


## Synthesize Cloudformation Template

To see the Cloudformation template generated by the CDK, run `cdk synth`, then check the output file in the "cdk.out" directory.
2 changes: 1 addition & 1 deletion typescript/ecs/fargate-service-with-local-image/cdk.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"app": "node index"
"app": "npx ts-node --prefer-ts-exts index.ts"
}
3 changes: 2 additions & 1 deletion typescript/ecs/fargate-service-with-local-image/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const stack = new cdk.Stack(app, 'FargateServiceWithLocalImage');

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

// Instantiate Fargate Service with a cluster and a local image that gets
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use an official Python runtime as a parent image
FROM python:3.4-alpine
FROM --platform=linux/amd64 python:3.4-alpine

# Set the working directory to /app
WORKDIR /app
Expand Down
Loading