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