Amazon ECS Deployment with CloudFormation: Difference between revisions
Jump to navigation
Jump to search
Line 93: | Line 93: | ||
==Dependencies== | ==Dependencies== | ||
<font color=darkgray>TODO: | |||
* TaskRole | |||
<font color=darkgray>TODO</font> | * TaskExecutionRole | ||
* ServiceLogGroup | |||
</font> | |||
=Create a Cluster= | =Create a Cluster= | ||
<font color=darkgray>TODO</font> | <font color=darkgray>TODO</font> |
Revision as of 01:08, 31 March 2019
External
Internal
Procedure
Declare a set of configuration parameters that abstract out operational details, such as project name, etc. Then declare the task definition:
Prerequisites
Parameters: ProjectID: Type: String Default: themyscira Description: | The key that uniquely identifies a resource consumer (service, tool that requires AWS resources, etc.). The project ID is used as root when assembling the names of associated resources. Image: Type: String Tag: Type: String
AWS::ECS::TaskDefinition
Resources: ... TaskDefinition: Type: AWS::ECS::TaskDefinition Properties: Family: !Ref ProjectID RequiresCompatibilities: ['FARGATE'] TaskRoleArn: !GetAtt TaskRole.Arn ExecutionRoleArn: !GetAtt TaskExecutionRole.Arn NetworkMode: 'awsvpc' Memory: '4096' Cpu: '2048' ContainerDefinitions: - Name: !Sub '${ProjectID}-container' Image: !Sub ${Image}:${Tag} Essential: 'true' Memory: '4096' Cpu: '2048' PortMappings: - HostPort: 10002 ContainerPort: 10002 Environment: - Name: SPRING_PROFILES_ACTIVE Value: 'something' LogConfiguration: LogDriver: "awslogs" Options: awslogs-group: !Ref ServiceLogGroup awslogs-region: !Sub ${AWS::Region} awslogs-stream-prefix: 'task'
TaskRole and TaskExecutionRole, a service-specific ServiceLogGroup will also have to be declared, see Dependencies below.
AWS::ECS::Service
Resources: ... ServiceDefinition: Type: AWS::ECS::Service DependsOn: LoadBalancerListener Properties: ServiceName: !Ref ProjectID LaunchType: FARGATE Cluster: 'some-cluster' TaskDefinition: !Ref TaskDefinition DesiredCount: 1 HealthCheckGracePeriodSeconds: 60 NetworkConfiguration: AwsvpcConfiguration: AssignPublicIp: DISABLED SecurityGroups: - !Ref ServiceSecurityGroup Subnets: - 'blue-subnet' - 'green-subnet' ServiceRegistries: - RegistryArn: !GetAtt ServiceDiscovery.Arn LoadBalancers: - ContainerName: !Sub '${ProjectID}-container' ContainerPort: 10002 TargetGroupArn: !Ref TargetGroup
Dependencies
TODO:
- TaskRole
- TaskExecutionRole
- ServiceLogGroup
Create a Cluster
TODO