CloudFormation Updating the SecurityGroupIds of an ec2 instance it recreates the instance instead of modifying the same

0 votes

I created ec2 instance with cloudformation. When I try to update the securitygroup of the instance in the same template , cloudformation recreates the instance instead of modifying the same (Like in terraform). How to update the SecurityGroup of instance without recreating it ?

 For example the below template -

Resources:
  Ec2Instance:
    Type: 'AWS::EC2::Instance'
    Properties:
      InstanceType: t2.micro
      ImageId: ami-0ed9277fb7eb570c9
      SecurityGroupIds:

        - sg-09d68774a93ec40df

Now If I try to add another SecurityGroupIds it recreates the ec2 -

Resources:
  Ec2Instance:
    Type: 'AWS::EC2::Instance'
    Properties:
      InstanceType: t2.micro
      ImageId: ami-0ed9277fb7eb570c9
      SecurityGroupIds:
        - sg-09d68774a93ec40df
        - sg-05555951931eeaca7

Dec 17, 2021 in AWS by Goural

edited Mar 4, 2025 356 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP