Global outage event
If you’re experiencing issues with your AWS services, then please refer to the AWS Health Dashboard. You can find the overall status of ongoing outages, the health of AWS services, and the latest updates from AWS engineers.
Ubuntu 또는 RHEL AMI에 CloudFormation 도우미 스크립트를 설치하려면 어떻게 해야 합니까?
Ubuntu 또는 Red Hat Enterprise Linux(RHEL) Amazon Machine Image(AMI)용 AWS CloudFormation 도우미 스크립트를 설치하려고 합니다.
해결 방법
부팅 프로세스 중에 Ubuntu 20.04 LTS, Ubuntu 22.04 LTS 및 RHEL 9 AMI용 CloudFormation 도우미 스크립트를 설치하려면 템플릿을 사용하십시오.
aws-cfn-bootstrap 패키지의 최신 바이너리를 가져오려면 CloudFormation 도우미 스크립트 참조를 확인하십시오.
인스턴스의 UserData 속성을 사용한 다음, AMI용 스크립트를 다운로드하여 설치합니다. cfn-hup /lib/systemd/system/cfn-hup.service의 경우 cfn-hup 구성 파일, cfn-hup 후크 및 systemd 파일을 생성하십시오. systemd에서 서비스를 활성화하려면 commands 키를 사용하여 서비스를 시작합니다.
예제 템플릿:
AWSTemplateFormatVersion: "2010-09-09" Description: Installing Cloudformation helper scripts in Ubuntu 22.04 LTS Parameters: KeyName: Description: Name of an existing EC2 KeyPair to enable SSH access to the instance Type: AWS::EC2::KeyPair::KeyName Version: Description: Ubuntu release version Type: String AllowedValues: - ubuntu2004 - ubuntu2204 - Rhel9 InstanceType: Description: WebServer EC2 instance type Type: String AllowedValues: - t1.micro - t2.nano - t2.micro - t2.small - t2.medium - t2.large - m1.small - m1.medium - m1.large - m1.xlarge - m2.xlarge - m2.2xlarge - m2.4xlarge - m3.medium - m3.large - m3.xlarge - m3.2xlarge - m4.large - m4.xlarge - m4.2xlarge - m4.4xlarge - m4.10xlarge - c1.medium - c1.xlarge - c3.large - c3.xlarge - c3.2xlarge - c3.4xlarge - c3.8xlarge - c4.large - c4.xlarge - c4.2xlarge - c4.4xlarge - c4.8xlarge - r3.large - r3.xlarge - r3.2xlarge - r3.4xlarge - r3.8xlarge - i2.xlarge - i2.2xlarge - i2.4xlarge - i2.8xlarge - d2.xlarge - d2.2xlarge - d2.4xlarge - d2.8xlarge - hs1.8xlarge - cr1.8xlarge - cc2.8xlarge Default: t2.small ConstraintDescription: must be a valid EC2 instance type. SSHLocation: Description: The IP address range that can be used to SSH to the EC2 instances Type: String Default: 0.0.0.0/0 MinLength: "9" MaxLength: "18" AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2}) ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x. SubnetId: Type: AWS::EC2::Subnet::Id Conditions: ubuntu2004Version: !Equals - !Ref 'Version' - ubuntu2004 ubuntu2204Version: !Equals - !Ref 'Version' - ubuntu2204 RHEL9Version: !Equals - !Ref 'Version' - Rhel9 notrhel: !Not [!Equals [!Ref Version, Rhel9]] Mappings: AWSRegionArch2004AMI: us-east-1: HVM64: ami-0149b2da6ceec4bb0 us-west-2: HVM64: ami-0c09c7eb16d3e8e70 us-west-1: HVM64: ami-03f6d497fceb40069 eu-west-1: HVM64: ami-0fd8802f94ed1c969 eu-west-2: HVM64: ami-04842bc62789b682e eu-west-3: HVM64: ami-064736ff8301af3ee eu-central-1: HVM64: ami-06148e0e81e5187c8 ap-northeast-1: HVM64: ami-09b18720cb71042df ap-northeast-2: HVM64: ami-07d16c043aa8e5153 ap-northeast-3: HVM64: ami-09d2f3a31110c6ad4 ap-southeast-1: HVM64: ami-00e912d13fbb4f225 ap-southeast-2: HVM64: ami-055166f8a8041fbf1 ap-south-1: HVM64: ami-024c319d5d14b463e us-east-2: HVM64: ami-0d5bf08bc8017c83b ca-central-1: HVM64: ami-043a72cf696697251 sa-east-1: HVM64: ami-00742e66d44c13cd9 AWSRegionArch2204AMI: us-east-1: HVM64: ami-08c40ec9ead489470 us-west-2: HVM64: ami-017fecd1353bcc96e us-west-1: HVM64: ami-02ea247e531eb3ce6 eu-west-1: HVM64: ami-096800910c1b781ba eu-west-2: HVM64: ami-0f540e9f488cfa27d eu-west-3: HVM64: ami-0493936afbe820b28 eu-central-1: HVM64: ami-0caef02b518350c8b ap-northeast-1: HVM64: ami-03f4fa076d2981b45 ap-northeast-2: HVM64: ami-0e9bfdb247cc8de84 ap-northeast-3: HVM64: ami-08c2ee02329b72f26 ap-southeast-1: HVM64: ami-07651f0c4c315a529 ap-southeast-2: HVM64: ami-09a5c873bc79530d9 ap-south-1: HVM64: ami-062df10d14676e201 us-east-2: HVM64: ami-097a2df4ac947655f ca-central-1: HVM64: ami-0a7154091c5c6623e sa-east-1: HVM64: ami-04b3c23ec8efcc2d6 AWSRegionArchRhelAMI: us-east-1: HVM64: ami-0149b2da6ceec4bb0 us-west-2: HVM64: ami-0c09c7eb16d3e8e70 us-west-1: HVM64: ami-03f6d497fceb40069 eu-west-1: HVM64: ami-0fd8802f94ed1c969 eu-west-2: HVM64: ami-04842bc62789b682e eu-west-3: HVM64: ami-064736ff8301af3ee eu-central-1: HVM64: ami-06148e0e81e5187c8 ap-northeast-1: HVM64: ami-09b18720cb71042df ap-northeast-2: HVM64: ami-07d16c043aa8e5153 ap-northeast-3: HVM64: ami-09d2f3a31110c6ad4 ap-southeast-1: HVM64: ami-00e912d13fbb4f225 ap-southeast-2: HVM64: ami-055166f8a8041fbf1 ap-south-1: HVM64: ami-024c319d5d14b463e us-east-2: HVM64: ami-0d5bf08bc8017c83b ca-central-1: HVM64: ami-043a72cf696697251 sa-east-1: HVM64: ami-00742e66d44c13cd9 Resources: EC2Instance: CreationPolicy: ResourceSignal: Timeout: PT10M Count: "1" Type: AWS::EC2::Instance Metadata: AWS::CloudFormation::Init: configSets: full_install: - install_and_enable_cfn_hup install_and_enable_cfn_hup: files: /etc/cfn/cfn-hup.conf: content: !Sub | [main] stack=${AWS::StackId} region=${AWS::Region} mode: "000400" owner: root group: root /etc/cfn/hooks.d/cfn-auto-reloader.conf: content: !Sub | [cfn-auto-reloader-hook] triggers=post.update path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource EC2Instance --configsets InstallAndRun --region ${AWS::Region} runas=root mode: "000400" owner: root group: root /lib/systemd/system/cfn-hup.service: content: | [Unit] Description=cfn-hup daemon [Service] Type=simple ExecStart=/usr/local/bin/cfn-hup Restart=always [Install] WantedBy=multi-user.target commands: 01enable_cfn_hup: command: systemctl enable cfn-hup.service 02start_cfn_hup: command: systemctl start cfn-hup.service Properties: InstanceType: !Ref InstanceType SubnetId: !Ref SubnetId SecurityGroupIds: - !GetAtt InstanceSecurityGroup.GroupId KeyName: !Ref KeyName ImageId: !If - ubuntu2004Version - !FindInMap - AWSRegionArch2004AMI - !Ref 'AWS::Region' - HVM64 - !If - ubuntu2204Version - !FindInMap - AWSRegionArch2204AMI - !Ref 'AWS::Region' - HVM64 - !FindInMap - AWSRegionArchRhelAMI - !Ref 'AWS::Region' - HVM64 UserData: !If - notrhel - Fn::Base64: Fn::Sub: | #!/bin/bash -xe sudo apt-get update -y sudo apt-get -y install python3-pip mkdir -p /opt/aws/ sudo pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz sudo ln -s /usr/local/init/ubuntu/cfn-hup /etc/init.d/cfn-hup /usr/local/bin/cfn-init -v --stack ${AWS::StackName} --resource EC2Instance --configsets full_install --region ${AWS::Region} /usr/local/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource EC2Instance --region ${AWS::Region} - Fn::Base64: Fn::Sub: | #!/bin/bash -xe sudo apt-get update -y sudo apt-get -y install python3-pip mkdir -p /opt/aws/ sudo pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz sudo ln -s /usr/local/init/ubuntu/cfn-hup /etc/init.d/cfn-hup /usr/local/bin/cfn-init -v --stack ${AWS::StackName} --resource EC2Instance --configsets full_install --region ${AWS::Region} /usr/local/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource EC2Instance --region ${AWS::Region} InstanceSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: Enable SSH access via port 22 SecurityGroupIngress: - IpProtocol: tcp FromPort: "22" ToPort: "22" CidrIp: !Ref SSHLocation
참고: multi-user.target을 사용하여 systemd를 기존 부트 대상의 종속성으로 만드십시오.
스택을 생성한 후 인스턴스에 연결합니다.
cfn-hup 서비스가 스택을 시작한 후 시작되는지 확인하려면 다음 명령을 실행합니다.
systemctl status cfn-hup
출력 예시:
cfn-hup.service - cfn-hup daemon Loaded: loaded (/usr/lib/systemd/system/cfn-hup.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2016-10-12 08:10:26 EDT; 1min 11s ago Main PID: 4852 (cfn-hup) CGroup: /system.slice/cfn-hup.service └─4852 /usr/bin/python /opt/aws/bin/cfn-hup Oct 12 08:10:26 ip-172-31-44-180.ec2.internal systemd[1]: Started cfn-hup daemon. Oct 12 08:10:26 ip-172-31-44-180.ec2.internal systemd[1]: Starting cfn-hup daemon...

