From c58432972c05089fbd0864ad07fc3870613b503d Mon Sep 17 00:00:00 2001 From: Cedric Ziel Date: Mon, 11 May 2020 15:05:55 +0200 Subject: [PATCH] Add cart service --- aws-ecs-ec2/services.yaml | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/aws-ecs-ec2/services.yaml b/aws-ecs-ec2/services.yaml index e05bd8b..245c632 100644 --- a/aws-ecs-ec2/services.yaml +++ b/aws-ecs-ec2/services.yaml @@ -30,6 +30,10 @@ Parameters: Type: String Default: user Description: The user service name + CartServiceName: + Type: String + Default: cart + Description: The cart service name ImageUrl: Type: String Default: nginx @@ -59,6 +63,10 @@ Parameters: Type: Number Default: 8080 Description: What port number the application inside the docker container is binding to + CartContainerPort: + Type: Number + Default: 8080 + Description: What port number the application inside the docker container is binding to ContainerCpu: Type: Number Default: 256 @@ -255,6 +263,39 @@ Resources: DesiredCount: 1 TaskDefinition: !Ref 'UserTaskDefinition' + # cart service + CartTaskDefinition: + Type: AWS::ECS::TaskDefinition + DependsOn: ['RedisService'] + Properties: + Family: !Ref 'CartServiceName' + Cpu: !Ref 'ContainerCpu' + Memory: !Ref 'ContainerMemory' + TaskRoleArn: + Fn::If: + - 'HasCustomRole' + - !Ref 'Role' + - !Ref "AWS::NoValue" + ContainerDefinitions: + - Name: !Ref 'CartServiceName' + Cpu: !Ref 'ContainerCpu' + Memory: !Ref 'ContainerMemory' + Image: robotshop/rs-cart + PortMappings: + - ContainerPort: !Ref 'CartContainerPort' + LogConfiguration: + LogDriver: json-file + CartService: + Type: AWS::ECS::Service + DependsOn: LoadBalancerRule + Properties: + ServiceName: !Ref 'CartServiceName' + Cluster: + Fn::ImportValue: + !Join [':', [!Ref 'StackName', 'ClusterName']] + DesiredCount: 1 + TaskDefinition: !Ref 'CartTaskDefinition' + WebTaskDefinition: Type: AWS::ECS::TaskDefinition Properties: