Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ECSAutoScalingGroup:
- Type: "AWS::AutoScaling::AutoScalingGroup"
- Properties:
- VPCZoneIdentifier:
- - Ref: "Subnet1"
- - Ref: "Subnet2"
- LaunchConfigurationName: !Ref "AutoScalingGroupConfig"
- MinSize: "1"
- MaxSize: "1"
- DesiredCapacity: "1"
- CreationPolicy:
- ResourceSignal:
- Timeout: "PT5M"
- UpdatePolicy:
- AutoScalingReplacingUpdate:
- WillReplace: true
- ...
- ECSALB:
- Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
- DependsOn: "AttachGateway"
- Properties:
- Name: "ECSALB"
- LoadBalancerAttributes:
- - Key: idle_timeout.timeout_seconds
- Value: 30
- Subnets:
- - Ref: "Subnet1"
- - Ref: "Subnet2"
- SecurityGroups: [!Ref "LoadBalancerSecurityGroup"]
- ...
- ALBRabbitMQManagementListener:
- Type: "AWS::ElasticLoadBalancingV2::Listener"
- DependsOn: [ "ECSServiceRole", "RabbitMQTargetGroup" ]
- Properties:
- DefaultActions:
- - Type: "forward"
- TargetGroupArn: !Ref "RabbitMQTargetGroup"
- LoadBalancerArn: !Ref "ECSALB"
- Port: 15672
- Protocol: "HTTP"
- ...
- ALBListenerHTTPS:
- Type: "AWS::ElasticLoadBalancingV2::Listener"
- DependsOn: [ "ECSServiceRole", "ECSALB" ]
- Properties:
- Certificates:
- - CertificateArn: “some_certificate”
- DefaultActions:
- - Type: "redirect"
- RedirectConfig:
- Protocol: "HTTPS"
- Host: "static.domain.com"
- Path: "/#{path}"
- Query: "#{query}"
- StatusCode: "HTTP_301"
- LoadBalancerArn: !Ref "ECSALB"
- Port: 443
- Protocol: "HTTPS"
- ...
- ECSALBListenerRuleWebSocket:
- Type: "AWS::ElasticLoadBalancingV2::ListenerRule"
- DependsOn: [ "ALBListenerHTTPS", "RabbitMQTargetGroup" ]
- Properties:
- Actions:
- - Type: "forward"
- TargetGroupArn: !Ref "RabbitMQTargetGroup"
- Conditions:
- - Field: "path-pattern"
- Values: [ "/ws" ]
- ListenerArn: !Ref "ALBListenerHTTPS"
- Priority: 2
- ...
- RabbitMQTargetGroup:
- Type: "AWS::ElasticLoadBalancingV2::TargetGroup"
- DependsOn: "ECSALB"
- Properties:
- HealthCheckIntervalSeconds: 30
- HealthCheckPath: "/"
- HealthCheckPort: 15672
- HealthCheckProtocol: "HTTP"
- HealthCheckTimeoutSeconds: 5
- HealthyThresholdCount: 2
- Name: "RabbitMQTargetGroup"
- Port: 15674
- Protocol: "HTTP"
- TargetGroupAttributes:
- - Key: "stickiness.enabled"
- Value: true # Needed to support WebSockets
- - Key: "stickiness.lb_cookie.duration_seconds"
- Value: 604800 # One week (this is the maximum)
- UnhealthyThresholdCount: 3
- VpcId: !Ref "Vpc"
- ...
- RabbitMQService:
- Type: AWS::ECS::Service
- DependsOn: [ "ALBListenerHTTPS", "RabbitMQTargetGroup", "ECSALBListenerRuleWebSocket" ]
- Properties:
- Cluster: !Ref “MyCluster"
- Role: !Ref "ECSServiceRole"
- DesiredCount: 1
- TaskDefinition: !Ref "RabbitMQTask"
- DeploymentConfiguration:
- MinimumHealthyPercent: 100
- LoadBalancers:
- - ContainerName: "rabbitmq-service"
- ContainerPort: 15674
- TargetGroupArn: !Ref "RabbitMQTargetGroup"
- ...
- RabbitMQTask:
- Type: "AWS::ECS::TaskDefinition"
- Properties:
- Family: "rabbitmq-service"
- NetworkMode: "host"
- ContainerDefinitions:
- - Name: "rabbitmq-service"
- Essential: true
- Image: “some_docker_image”
- MemoryReservation: 1024
- PortMappings:
- - ContainerPort: 15672
- - ContainerPort: 15674
- LogConfiguration:
- LogDriver: "awslogs"
- Options:
- awslogs-group: "rabbitmq"
- awslogs-region: !Ref "AWS::Region"
- awslogs-stream-prefix: “my_prefix”
- awslogs-datetime-format: "%Y-%m-%d %H:%M:%S.%L"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement