Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.10 KB | None | 0 0
  1. ---
  2. Description: "BC Workbench Setup"
  3. Parameters:
  4. UserName:
  5. Type: String
  6. Description: Enter workbench username.
  7. WorkbenchSecurityGroupIDS:
  8. Type: "List<AWS::EC2::SecurityGroup::Id>"
  9. Description: Enter Security group ids for this workbench.
  10. WorkbenchSubnetIDS:
  11. Type: "List<AWS::EC2::Subnet::Id>"
  12. Description: Enter Subnet IDs for this workbench.
  13. SaltedPassword:
  14. Type: String
  15. Description: Enter salted password for new user.
  16. Resources:
  17. BCHTTPListener:
  18. Type: "AWS::ElasticLoadBalancingV2::Listener"
  19. Properties:
  20. DefaultActions:
  21. - Type: forward
  22. TargetGroupArn: !Ref BCHTTPTargetGroup
  23. LoadBalancerArn: !Ref ALB
  24. Port: 80
  25. Protocol: HTTP
  26. BCHTTPTargetGroup:
  27. Type: "AWS::ElasticLoadBalancingV2::TargetGroup"
  28. Properties:
  29. HealthCheckIntervalSeconds: 30
  30. HealthCheckPath: "/"
  31. HealthCheckPort: "traffic-port"
  32. HealthCheckProtocol: "HTTP"
  33. HealthCheckTimeoutSeconds: 5
  34. HealthyThresholdCount: 5
  35. Matcher:
  36. HttpCode: 301
  37. Name: ${UserName}-bc-http
  38. Port: 80
  39. Protocol: HTTP
  40. Tags:
  41. - Key: Department
  42. Value: development
  43. - Key: chaos
  44. Value: dev
  45. TargetGroupAttributes:
  46. - Key: deregistration_delay.timeout_seconds
  47. Value: 300
  48. - Key: stickiness.enabled
  49. Value: false
  50. Targets:
  51. - Id: !Ref Workbench
  52. Port: 80
  53. TargetType: instance
  54. UnhealthyThresholdCount: 2
  55. VpcId: vpc-891ad7ed
  56. BCHTTPSListener:
  57. Type: "AWS::ElasticLoadBalancingV2::Listener"
  58. Properties:
  59. DefaultActions:
  60. - Type: forward
  61. TargetGroupArn: !Ref BCHTTPSTargetGroup
  62. LoadBalancerArn: !Ref ALB
  63. Port: 443
  64. Protocol: HTTPS
  65. Certificates:
  66. - CertificateArn: "arn:aws:acm:us-east-1:687433828854:certificate/0a3d771d-440a-49cb-8617-0fe7f4e28a17"
  67. SslPolicy: "ELBSecurityPolicy-2016-08"
  68. BCHTTPSTargetGroup:
  69. Type: "AWS::ElasticLoadBalancingV2::TargetGroup"
  70. Properties:
  71. HealthCheckIntervalSeconds: 30
  72. HealthCheckPath: "/"
  73. HealthCheckPort: "traffic-port"
  74. HealthCheckProtocol: "HTTP"
  75. HealthCheckTimeoutSeconds: 5
  76. HealthyThresholdCount: 5
  77. Matcher:
  78. HttpCode: 200
  79. Name: ${UserName}-bc-https
  80. Port: 443
  81. Protocol: HTTPS
  82. Tags:
  83. - Key: Department
  84. Value: development
  85. - Key: chaos
  86. Value: dev
  87. TargetGroupAttributes:
  88. - Key: deregistration_delay.timeout_seconds
  89. Value: 300
  90. - Key: stickiness.enabled
  91. Value: false
  92. Targets:
  93. - Id: !Ref Workbench
  94. Port: 443
  95. TargetType: instance
  96. UnhealthyThresholdCount: 2
  97. VpcId: vpc-891ad7ed
  98. APIRule:
  99. Type: "AWS::ElasticLoadBalancingV2::ListenerRule"
  100. Properties:
  101. Actions:
  102. - Type: forward
  103. TargetGroupArn: !Ref APITargetGroup
  104. Conditions:
  105. - Field: path-pattern
  106. Values:
  107. - "/api/*"
  108. ListenerArn: !Ref BCHTTPSListener
  109. Priority: 1000
  110. APITargetGroup:
  111. Type: "AWS::ElasticLoadBalancingV2::TargetGroup"
  112. Properties:
  113. HealthCheckIntervalSeconds: 30
  114. HealthCheckPath: "/api/"
  115. HealthCheckPort: "traffic-port"
  116. HealthCheckProtocol: "HTTP"
  117. HealthCheckTimeoutSeconds: 5
  118. HealthyThresholdCount: 5
  119. Matcher:
  120. HttpCode: 200
  121. Name: ${UserName}-bc-api
  122. Port: 5000
  123. Protocol: HTTP
  124. Tags:
  125. - Key: Department
  126. Value: development
  127. - Key: chaos
  128. Value: dev
  129. TargetGroupAttributes:
  130. - Key: deregistration_delay.timeout_seconds
  131. Value: 300
  132. - Key: stickiness.enabled
  133. Value: false
  134. Targets:
  135. - Id: !Ref Workbench
  136. Port: 5000
  137. TargetType: instance
  138. UnhealthyThresholdCount: 2
  139. VpcId: vpc-891ad7ed
  140. ALB:
  141. Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
  142. Properties:
  143. LoadBalancerAttributes:
  144. - Key: idle_timeout.timeout_seconds
  145. Value: 60
  146. Name: ${UserName}-workbench
  147. Scheme: internet-facing
  148. SecurityGroups: !Ref WorkbenchSecurityGroupIDS
  149. Subnets: !Ref WorkbenchSubnetIDS
  150. Tags:
  151. - Key: Department
  152. Value: development
  153. - Key: chaos
  154. Value: dev
  155. Type: application
  156. IpAddressType: ipv4
  157. Workbench:
  158. Type: "AWS::EC2::Instance"
  159. Properties:
  160. AvailabilityZone: "us-east-1c" ## This might need to be variable in the future
  161. IamInstanceProfile: "BC_Sandbox"
  162. ImageId: ami-80861296
  163. KeyName: sheetzam
  164. InstanceType: t2.medium
  165. SecurityGroupIds: !Ref WorkbenchSecurityGroupIDS
  166. SubnetId: "subnet-ffcee3a6"
  167. BlockDeviceMappings:
  168. - DeviceName: /dev/sda1
  169. Ebs:
  170. VolumeSize: 50
  171. Tags:
  172. - Key: Name
  173. Value: ${UserName}-bc-workbench
  174. - Key: Department
  175. Value: development
  176. - Key: chaos
  177. Value: dev
  178. - Key: ghe
  179. Value: dev-vm
  180. UserData:
  181. Fn::Base64:
  182. !Sub |
  183. #!/bin/bash -xe
  184. apt-get update
  185. debconf-set-selections <<< \"postfix postfix/mailname string dev.inspire.com\"
  186. debconf-set-selections <<< \"postfix postfix/main_mailer_type string 'Internet Site'\"
  187. DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -yq -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'
  188. apt-get install -y redis-tools mutt exuberant-ctags git build-essential tree tmux docker-compose mysql-client python-pip docker.io
  189. useradd -m -p ${SaltedPassword} -s /bin/bash ${UserName}
  190. adduser ${UserName} sudo; adduser ${UserName} docker
  191. mkdir -p /home/${UserName}/.ssh
  192. cp /home/ubuntu/.ssh/authorized_keys /home/${UserName}/.ssh/authorized_keys
  193. chown -R ${UserName}:${UserName} /home/${UserName}/.ssh
  194. sudo -u ${UserName} pip install awscli --upgrade --user
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement