【发布时间】:2020-12-01 17:09:24
【问题描述】:
我有以下 WebAppLaunchConfig 和 WebAppGroup 配置,不知道为什么会出现该错误。
escription: >
High availability web app
Parameters:
EnvironmentName:
Description: An environment name that will be prefixed to resource names
Type: String
Resources:
LBSecGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow http to our load balancer
VpcId:
Fn::ImportValue:
!Sub "${EnvironmentName}-VPCID"
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
SecurityGroupEgress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
WebServerSecGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow http to our hosts and SSH from local only
VpcId:
Fn::ImportValue:
!Sub "${EnvironmentName}-VPCID"
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
SecurityGroupEgress:
- IpProtocol: tcp
FromPort: 0
ToPort: 65535
CidrIp: 0.0.0.0/0
WebAppLaunchConfig:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
UserData:
Fn::Base64: !Sub |
#!/bin/bash
# Install docker
apt-get update
apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install -y docker-ce
mkdir docker-test
cd docker-test
wget https://udagram-dev-u.s3.ap-south-1.amazonaws.com/index.html.zip
apt-get install unzip
unzip index.html.zip
echo "FROM ubuntu:latest" >> Dockerfile
echo "RUN apt-get update" >> Dockerfile
echo "RUN apt-get install -y nodejs" >> Dockerfile
echo "RUN apt-get install -y npm" >> Dockerfile
echo "RUN npm install -g http-server" >> Dockerfile
echo "WORKDIR /usr/apps/test-docker/" >> Dockerfile
echo "COPY index.html /usr/apps/test-docker/" >> Dockerfile
echo 'CMD ["http-server", "-s"]' >> Dockerfile
docker build -t "test:test-docker" .
usermod -aG docker ubuntu
docker run -d -p 8080:8080 "test:test-docker"
ImageId: ami-005bdb005fb00e791
SecurityGroups:
- Ref: WebServerSecGroup
InstanceType: t3.medium
BlockDeviceMappings:
- DeviceName: "/dev/sdk"
Ebs:
VolumeSize: '10'
WebAppGroup:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
VPCZoneIdentifier:
- Fn::ImportValue:
!Sub "${EnvironmentName}-PRIV-NETS"
LaunchConfigurationName:
Ref: WebAppLaunchConfig
MinSize: '4'
MaxSize: '6'
TargetGroupARNs:
- Ref: WebAppTargetGroup
【问题讨论】:
-
你能像 YAML 文件一样编辑它吗?
标签: amazon-cloudformation aws-cli