Skip to content

Instantly share code, notes, and snippets.

Avatar

Ramon Blanquer docwhite

View GitHub Profile
View ecsfs_auto_scaling.yaml
# Specifies a resource that Application Auto Scaling can scale. In our case
# it's just the backend.
AutoScalingTarget:
Type: AWS::ApplicationAutoScaling::ScalableTarget
Properties:
MinCapacity: 1
MaxCapacity: 3
ResourceId: !Join ['/', [service, !Ref ECSCluster, !GetAtt BackendService.Name]]
ScalableDimension: ecs:service:DesiredCount
ServiceNamespace: ecs
View ecsfs_services.yaml
BackendService:
Type: AWS::ECS::Service
Properties:
ServiceName: ecsfs-backend-service
Cluster: !Ref ECSCluster
LaunchType: FARGATE
DesiredCount: 1
ServiceRegistries: # And that's how you associate ecsfs-backend.local!
- RegistryArn: !GetAtt BackendLocalDiscoveryService.Arn
NetworkConfiguration:
View ecsfs_service_discovery.yaml
LocalNamespace:
Type: AWS::ServiceDiscovery::PrivateDnsNamespace
Properties:
Vpc: !Ref VPC
Name: local
NginxLocalDiscoveryService:
Type: AWS::ServiceDiscovery::Service
Properties:
Name: ecsfs-nginx
View ecsfs_task_definitions.yaml
BackendTaskDefinition:
Type: AWS::ECS::TaskDefinition
DependsOn: LogGroup
Properties:
Family: ecsfs-backend-td
Cpu: 256
Memory: 1024
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
View ecsfs_iam_roles.yaml
ExecutionRole:
Type: AWS::IAM::Role
Properties:
RoleName: ecsfs-execution-role
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Action: sts:AssumeRole
View ecsfs_log.yaml
LogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: ecsfs-logs
View ecsfs_cluster.yaml
ECSCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: ecsfs-cluster
View ecsfs_load_balancer.yaml
TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Name: ecsfs-target-group
Port: 80
Protocol: HTTP
TargetType: ip
VpcId: !Ref VPC
ListenerHTTP:
View ecsfs_security.yaml
FargateContainerSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Access to Fargate containers.
VpcId: !Ref VPC
IngressFromPublicALBSecurityGroup:
Type: AWS::EC2::SecurityGroupIngress
Properties:
Description: Ingress from the public Application Load Balancer.
View ecsfs_private_routing.yaml
NatElasticIP:
Type: AWS::EC2::EIP
NatGateway:
Type: AWS::EC2::NatGateway
Properties:
AllocationId: !GetAtt NatElasticIP.AllocationId
SubnetId: !Ref PublicSubnetOne
PrivateRouteTable: