Skip to content

CloudFormation Update and Delete Stack Hands OnΒΆ

We can select our stack and click on update. Then you can choose how you want to update it. We are going to upload a new file.

---
Parameters:
    SecurityGroupDescription:
        Description: Security Group Description
        Type: String
Resources:
    MyInstance:
        Type: AWS::EC2::Instance
        Properties:
            AvailabilityZone: us-east-1a
            ImageId: ami-a4c7edb2
            InstanceType: t2.micro
            SecurityGroups:
                - !Ref SSHSecurityGroup
                - !Ref ServerSecurityGroup
    MyEIP:
        Type: AWS::EC2::EIP
        Properties:
            InstanceId: !Ref MyInstance
    SSHSecurityGroup:
        Type: AWS::EC2::SecurityGroup
        Properties:
            GroupDescription: Enable SSH access via port 22
            SecurityGroupIngress:
                - CidrIp: 0.0.0.0/0
                  FromPort: 22
                  IpProtocol: tcp
                  ToPort: 22
    ServerSecurityGroup:
        Type: AWS::EC2::SecurityGroup
        Properties:
            GroupDescription: !Ref SecurityGroupDescription
            SecurityGroupIngress:
                - CidrIp: 0.0.0.0/0
                  FromPort: 80
                  IpProtocol: tcp
                  ToPort: 80
                - CidrIp: 192.168.1.1.1/32
                  FromPort: 22
                  IpProtocol: tcp
                  ToPort: 22

Now we'll get prompted to input a parameter.

In the review we'll see that we'll add a bunch of stuff, but will modify the already existing instance.


We can also select the cloudformation stack and click on delete. It will delete all the resources created.