Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. ECSAutoScalingGroup:
  2. Type: "AWS::AutoScaling::AutoScalingGroup"
  3. Properties:
  4. VPCZoneIdentifier:
  5. - Ref: "Subnet1"
  6. - Ref: "Subnet2"
  7. LaunchConfigurationName: !Ref "AutoScalingGroupConfig"
  8. MinSize: "1"
  9. MaxSize: "1"
  10. DesiredCapacity: "1"
  11. CreationPolicy:
  12. ResourceSignal:
  13. Timeout: "PT5M"
  14. UpdatePolicy:
  15. AutoScalingReplacingUpdate:
  16. WillReplace: true
  17. ...
  18. ECSALB:
  19. Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
  20. DependsOn: "AttachGateway"
  21. Properties:
  22. Name: "ECSALB"
  23. LoadBalancerAttributes:
  24. - Key: idle_timeout.timeout_seconds
  25. Value: 30
  26. Subnets:
  27. - Ref: "Subnet1"
  28. - Ref: "Subnet2"
  29. SecurityGroups: [!Ref "LoadBalancerSecurityGroup"]
  30. ...
  31. ALBRabbitMQManagementListener:
  32. Type: "AWS::ElasticLoadBalancingV2::Listener"
  33. DependsOn: [ "ECSServiceRole", "RabbitMQTargetGroup" ]
  34. Properties:
  35. DefaultActions:
  36. - Type: "forward"
  37. TargetGroupArn: !Ref "RabbitMQTargetGroup"
  38. LoadBalancerArn: !Ref "ECSALB"
  39. Port: 15672
  40. Protocol: "HTTP"
  41. ...
  42. ALBListenerHTTPS:
  43. Type: "AWS::ElasticLoadBalancingV2::Listener"
  44. DependsOn: [ "ECSServiceRole", "ECSALB" ]
  45. Properties:
  46. Certificates:
  47. - CertificateArn: “some_certificate”
  48. DefaultActions:
  49. - Type: "redirect"
  50. RedirectConfig:
  51. Protocol: "HTTPS"
  52. Host: "static.domain.com"
  53. Path: "/#{path}"
  54. Query: "#{query}"
  55. StatusCode: "HTTP_301"
  56. LoadBalancerArn: !Ref "ECSALB"
  57. Port: 443
  58. Protocol: "HTTPS"
  59. ...
  60. ECSALBListenerRuleWebSocket:
  61. Type: "AWS::ElasticLoadBalancingV2::ListenerRule"
  62. DependsOn: [ "ALBListenerHTTPS", "RabbitMQTargetGroup" ]
  63. Properties:
  64. Actions:
  65. - Type: "forward"
  66. TargetGroupArn: !Ref "RabbitMQTargetGroup"
  67. Conditions:
  68. - Field: "path-pattern"
  69. Values: [ "/ws" ]
  70. ListenerArn: !Ref "ALBListenerHTTPS"
  71. Priority: 2
  72. ...
  73. RabbitMQTargetGroup:
  74. Type: "AWS::ElasticLoadBalancingV2::TargetGroup"
  75. DependsOn: "ECSALB"
  76. Properties:
  77. HealthCheckIntervalSeconds: 30
  78. HealthCheckPath: "/"
  79. HealthCheckPort: 15672
  80. HealthCheckProtocol: "HTTP"
  81. HealthCheckTimeoutSeconds: 5
  82. HealthyThresholdCount: 2
  83. Name: "RabbitMQTargetGroup"
  84. Port: 15674
  85. Protocol: "HTTP"
  86. TargetGroupAttributes:
  87. - Key: "stickiness.enabled"
  88. Value: true # Needed to support WebSockets
  89. - Key: "stickiness.lb_cookie.duration_seconds"
  90. Value: 604800 # One week (this is the maximum)
  91. UnhealthyThresholdCount: 3
  92. VpcId: !Ref "Vpc"
  93. ...
  94. RabbitMQService:
  95. Type: AWS::ECS::Service
  96. DependsOn: [ "ALBListenerHTTPS", "RabbitMQTargetGroup", "ECSALBListenerRuleWebSocket" ]
  97. Properties:
  98. Cluster: !Ref “MyCluster"
  99. Role: !Ref "ECSServiceRole"
  100. DesiredCount: 1
  101. TaskDefinition: !Ref "RabbitMQTask"
  102. DeploymentConfiguration:
  103. MinimumHealthyPercent: 100
  104. LoadBalancers:
  105. - ContainerName: "rabbitmq-service"
  106. ContainerPort: 15674
  107. TargetGroupArn: !Ref "RabbitMQTargetGroup"
  108. ...
  109. RabbitMQTask:
  110. Type: "AWS::ECS::TaskDefinition"
  111. Properties:
  112. Family: "rabbitmq-service"
  113. NetworkMode: "host"
  114. ContainerDefinitions:
  115. - Name: "rabbitmq-service"
  116. Essential: true
  117. Image: “some_docker_image”
  118. MemoryReservation: 1024
  119. PortMappings:
  120. - ContainerPort: 15672
  121. - ContainerPort: 15674
  122. LogConfiguration:
  123. LogDriver: "awslogs"
  124. Options:
  125. awslogs-group: "rabbitmq"
  126. awslogs-region: !Ref "AWS::Region"
  127. awslogs-stream-prefix: “my_prefix”
  128. awslogs-datetime-format: "%Y-%m-%d %H:%M:%S.%L"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement