diff --git a/aws-ecs-ec2/services.yaml b/aws-ecs-ec2/services.yaml index c352e66..6767b8e 100644 --- a/aws-ecs-ec2/services.yaml +++ b/aws-ecs-ec2/services.yaml @@ -3,7 +3,7 @@ Description: Deploy robot shop services to a given ECS cluster Parameters: StackName: Type: String - Default: production + Default: ecs-ec2-robotshop Description: The name of the parent cluster stack that you created. Necessary to locate and reference resources created by that stack. WebServiceName: @@ -14,6 +14,10 @@ Parameters: Type: String Default: mongodb Description: The mongodb service name + RedisServiceName: + Type: String + Default: redis + Description: The redis service name ImageUrl: Type: String Default: nginx @@ -27,6 +31,10 @@ Parameters: Type: Number Default: 27017 Description: What port number the application inside the docker container is binding to + RedisContainerPort: + Type: Number + Default: 6379 + Description: What port number the application inside the docker container is binding to ContainerCpu: Type: Number Default: 256 @@ -93,6 +101,38 @@ Resources: DesiredCount: 1 TaskDefinition: !Ref 'MongoDbTaskDefinition' + # Redis service + RedisTaskDefinition: + Type: AWS::ECS::TaskDefinition + Properties: + Family: !Ref 'RedisServiceName' + Cpu: !Ref 'ContainerCpu' + Memory: !Ref 'ContainerMemory' + TaskRoleArn: + Fn::If: + - 'HasCustomRole' + - !Ref 'Role' + - !Ref "AWS::NoValue" + ContainerDefinitions: + - Name: !Ref 'RedisServiceName' + Cpu: !Ref 'ContainerCpu' + Memory: !Ref 'ContainerMemory' + Image: redis:4.0.6 + PortMappings: + - ContainerPort: !Ref 'RedisContainerPort' + LogConfiguration: + LogDriver: json-file + RedisService: + Type: AWS::ECS::Service + DependsOn: LoadBalancerRule + Properties: + ServiceName: !Ref 'RedisServiceName' + Cluster: + Fn::ImportValue: + !Join [':', [!Ref 'StackName', 'ClusterName']] + DesiredCount: 1 + TaskDefinition: !Ref 'RedisTaskDefinition' + WebTaskDefinition: Type: AWS::ECS::TaskDefinition Properties: