Skip to content

Instantly share code, notes, and snippets.

@vioquedu
Created August 18, 2020 05:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
{
"Resources": {
"VPCFARGATE": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16",
"InstanceTenancy": "default",
"EnableDnsSupport": "true",
"EnableDnsHostnames" : "true"
}
},
"INTGATEWAY": {
"Type": "AWS::EC2::InternetGateway"
},
"ATTACHIG": {
"Type": "AWS::EC2::VPCGatewayAttachment",
"DependsOn": ["VPCFARGATE", "INTGATEWAY"],
"Properties": {
"InternetGatewayId" : {"Ref": "INTGATEWAY"},
"VpcId" : {"Ref": "VPCFARGATE"}
}
},
"ROUTETABLE": {
"Type" : "AWS::EC2::RouteTable",
"DependsOn": ["VPCFARGATE"],
"Properties" : {
"VpcId" : {"Ref": "VPCFARGATE"}
}
},
"ROUTE": {
"Type": "AWS::EC2::Route",
"DependsOn": ["VPCFARGATE", "INTGATEWAY", "ROUTETABLE"],
"Properties": {
"RouteTableId": {"Ref": "ROUTETABLE"},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": {"Ref": "INTGATEWAY"}
}
},
"SUBNETFARGATE": {
"Type": "AWS::EC2::Subnet",
"DependsOn": ["VPCFARGATE"],
"Properties": {
"AvailabilityZone" : "eu-central-1a",
"CidrBlock" : "10.0.0.0/24",
"MapPublicIpOnLaunch" : "true",
"VpcId" : {"Ref": "VPCFARGATE"}
}
},
"SUBNETROUTE": {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"DependsOn": ["SUBNETFARGATE", "ROUTETABLE"],
"Properties" : {
"RouteTableId" : {"Ref": "ROUTETABLE"},
"SubnetId" : {"Ref": "SUBNETFARGATE"}
}
},
"SGFARGATE": {
"Type": "AWS::EC2::SecurityGroup",
"DependsOn": ["VPCFARGATE"],
"Properties": {
"GroupDescription" : "Fargate Security Group",
"GroupName" : "Fargate-SG",
"SecurityGroupIngress" : [
{
"CidrIp" : "0.0.0.0/0",
"Description" : "Allow HTTP traffic on port 80",
"FromPort" : 80,
"IpProtocol" : "tcp",
"ToPort" : 80
},{
"CidrIp": "0.0.0.0/0",
"Description": "Allow HTTPS traffic on port 443",
"FromPort": 443,
"IpProtocol": "tcp",
"ToPort": 443
}
],
"VpcId" : {"Ref": "VPCFARGATE"}
}
},
"FARGATECLUSTER": {
"Type": "AWS::ECS::Cluster",
"Properties": {
"ClusterName": "Cluster-CF"
}
},
"ECSTASK": {
"Type": "AWS::ECS::TaskDefinition",
"Properties": {
"ContainerDefinitions": [
{
"Name": "dash-container",
"Image": "account_id.dkr.ecr.eu-central-1.amazonaws.com/dash-app:1.0",
"PortMappings": [
{"ContainerPort": 80, "HostPort": 80, "Protocol": "tcp"}
],
"LogConfiguration": {
"LogDriver": "awslogs",
"Options": {
"awslogs-group": "/ecs/task-medium",
"awslogs-region": "eu-central-1",
"awslogs-stream-prefix": "ecs"
}
}
}
],
"Cpu": 512,
"Memory": 1024,
"NetworkMode": "awsvpc",
"RequiresCompatibilities": ["FARGATE"],
"TaskRoleArn": "ecsTaskExecutionRole",
"ExecutionRoleArn": "ecsTaskExecutionRole",
"Tags": [
{
"Key": "created_by",
"Value": "CloudFormation"
}
]
}
},
"SERVICE": {
"Type": "AWS::ECS::Service",
"DependsOn": ["ECSTASK", "FARGATECLUSTER", "SUBNETFARGATE", "SGFARGATE"],
"Properties": {
"Cluster" : "Cluster-CF",
"DeploymentConfiguration" : {
"MaximumPercent": 200,
"MinimumHealthyPercent": 100
},
"DeploymentController" : {"Type": "ECS"},
"DesiredCount" : 1,
"LaunchType" : "FARGATE",
"NetworkConfiguration" : {
"AwsvpcConfiguration": {
"AssignPublicIp" : "ENABLED",
"Subnets": [{"Ref": "SUBNETFARGATE"}],
"SecurityGroups": [{"Ref": "SGFARGATE"}]
}
},
"SchedulingStrategy" : "REPLICA",
"ServiceName" : "Service-CF",
"TaskDefinition" : {"Ref": "ECSTASK"}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment