diff --git a/typescript/ecs/fargate-service-with-local-image/README.md b/typescript/ecs/fargate-service-with-local-image/README.md new file mode 100644 index 0000000000..c141e8f87c --- /dev/null +++ b/typescript/ecs/fargate-service-with-local-image/README.md @@ -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. diff --git a/typescript/ecs/fargate-service-with-local-image/cdk.json b/typescript/ecs/fargate-service-with-local-image/cdk.json index 2f0e44c6fd..a2f2aa6a9a 100644 --- a/typescript/ecs/fargate-service-with-local-image/cdk.json +++ b/typescript/ecs/fargate-service-with-local-image/cdk.json @@ -1,3 +1,3 @@ { - "app": "node index" + "app": "npx ts-node --prefer-ts-exts index.ts" } diff --git a/typescript/ecs/fargate-service-with-local-image/index.ts b/typescript/ecs/fargate-service-with-local-image/index.ts index 13be1cef89..b02aaa0b02 100644 --- a/typescript/ecs/fargate-service-with-local-image/index.ts +++ b/typescript/ecs/fargate-service-with-local-image/index.ts @@ -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 diff --git a/typescript/ecs/fargate-service-with-local-image/local-image/Dockerfile b/typescript/ecs/fargate-service-with-local-image/local-image/Dockerfile index b7439cbb02..4937fb77a7 100644 --- a/typescript/ecs/fargate-service-with-local-image/local-image/Dockerfile +++ b/typescript/ecs/fargate-service-with-local-image/local-image/Dockerfile @@ -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