-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_deploy.yaml
More file actions
109 lines (102 loc) · 2.84 KB
/
Copy pathcode_deploy.yaml
File metadata and controls
109 lines (102 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Description:
This template builds a Webapp application on an AutoScaling group, behind an Application Load Balancer, with a CodeDeploy application.
Parameters:
AWSInfraStack:
Description: Name of the infrastructure CloudFormation stack .
Type: String
MinLength: 1
MaxLength: 255
AllowedPattern: "^[a-zA-Z][-a-zA-Z0-9]*$"
Default: AWSInfraStack
Stage:
Description: Release stage
Type: String
MinLength: 1
MaxLength: 255
AllowedPattern: "^[a-zA-Z][-a-zA-Z0-9]*$"
Default: Prod
Resources:
DeploymentGroup:
Type: "AWS::CodeDeploy::DeploymentGroup"
Properties:
DeploymentGroupName: !Join
- '-'
- - !Ref 'AWS::StackName'
- DeploymentGroup
ApplicationName:
Fn::ImportValue:
!Sub "${AWSInfraStack}:CodeDeployApplication"
ServiceRoleArn:
Fn::ImportValue:
!Sub "${AWSInfraStack}:CodeDeployRole"
DeploymentConfigName: CodeDeployDefault.AllAtOnce
AutoScalingGroups:
- Ref: AutoScalingGroup
AutoScalingGroup:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
HealthCheckType: ELB
HealthCheckGracePeriod: 300
MinSize: 1
MaxSize: 3
LaunchConfigurationName:
Fn::ImportValue:
!Sub "${AWSInfraStack}:LaunchConfig"
VPCZoneIdentifier:
Fn::Split:
- ","
- Fn::ImportValue:
!Sub "${AWSInfraStack}:PublicSubnets"
TargetGroupARNs:
- Ref: LoadBalancerTargetGroup
Tags:
- Key: Name
Value: !Join
- "-"
- - Fn::ImportValue:
!Sub "${AWSInfraStack}:ApplicationName"
- !Ref Stage
PropagateAtLaunch: true
LoadBalancerListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
-
Type: forward
TargetGroupArn:
Ref: LoadBalancerTargetGroup
LoadBalancerArn:
Ref: LoadBalancer
Port: 80
Protocol: HTTP
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Scheme: internet-facing
Subnets:
Fn::Split:
- ","
- Fn::ImportValue:
!Sub "${AWSInfraStack}:PublicSubnets"
SecurityGroups:
- Fn::ImportValue:
!Sub "${AWSInfraStack}:PublicHttpIngressSecurityGroup"
LoadBalancerTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
HealthCheckIntervalSeconds: 30
UnhealthyThresholdCount: 2
HealthyThresholdCount: 2
Port: 80
Protocol: HTTP
VpcId:
Fn::ImportValue:
!Sub "${AWSInfraStack}:VPC"
Outputs:
Url:
Description: Webapp application URL
Value:
Fn::Sub: 'http://${LoadBalancer.DNSName}'
DeploymentGroup:
Description: Webapp application deployment group
Value: !Ref DeploymentGroup