Skip to content

Instantly share code, notes, and snippets.

@richardsonlima
Last active July 31, 2020 00:58
Show Gist options
  • Save richardsonlima/a433a389c3a98f1892c5444f50aec1d8 to your computer and use it in GitHub Desktop.
Save richardsonlima/a433a389c3a98f1892c5444f50aec1d8 to your computer and use it in GitHub Desktop.
CodeShots CDK
import * as cdk from '@aws-cdk/core';
import * as ec2 from "@aws-cdk/aws-ec2";
import * as ecs from "@aws-cdk/aws-ecs";
import * as ecs_patterns from "@aws-cdk/aws-ecs-patterns";
import { Cluster } from '@aws-cdk/aws-ecs';
export class CdkRichopsStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpc = new ec2.Vpc(this, "richops-vpc-01", {
maxAzs: 3 // default is all AZs in region
});
const cluster = new ecs.Cluster(this, "RichOps-Cluster-01", {
vpc: vpc
});
// Create a load-balanced Fargate service and make it public
new ecs_patterns.ApplicationLoadBalancedFargateService(this, "MyFargateService", {
cluster: cluster, // required
cpu: 256, // default 256
desiredCount: 1 ,//default is 1
taskImageOptions: {
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
},
memoryLimitMiB: 512, //default is 512
publicLoadBalancer: true, //default is false
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment