Update a CloudFormation template
Services Covered
CloudFormation
Lab description
You have been tasked with the following:
Increasing the size of one of the instances
Allowing HTTP access to the instances from anywhere
Exposing the instance Id of one of the instances as a stack template output
Learning Objectives
Enable Stack Termination Protection
Update template
Lab date
31-12-2021
Prerequisites
:cloud: AWS account
:computer: EC2 Instance running or Terraform installed locally
Lab steps
- Enable Stack Termination Protection. Using AWS Management Console enable termination protection for the lab CloudFormation stack.
- Update EC2 Instance Type.
TestEc2Instance: Type: "AWS::EC2::Instance" Properties: ImageId: !Ref LatestAmiId InstanceType: t3.micro KeyName: !Ref "AWS::AccountId" NetworkInterfaces: - AssociatePublicIpAddress: "true" DeviceIndex: "0" GroupSet: - Ref: Ec2InstanceSecurityGroup SubnetId: !Ref PublicSubnet Tags: - Key: Name Value: !Sub ${TagPrefix} Test Instance
- Add a Security Group Ingress Rule.
Ec2InstanceSecurityGroup: Type: "AWS::EC2::SecurityGroup" Properties: GroupDescription: Security group for EC2 instances GroupName: ec2-instance-sg VpcId: !Ref VPC SecurityGroupIngress: - IpProtocol: tcp FromPort: 80 ToPort: 80 CidrIp: 0.0.0.0/0
- Add a Template Output.
ProdEc2Instance: Description: Instance Id Value: !Ref ProdEc2Instance
- Use Specific IAM Role for Updates.
- Update stack.