ankit tyagi
ankit tyagi

Reputation: 846

Add a security group to running instance using Ansible

How can I add a new security group to a running instance without removing existing ones using Ansible?

I tried ec2 module but that doesn't look like changing anything even if I pass a new security group with instance id.

Any help please?

Upvotes: 1

Views: 3848

Answers (1)

helloV
helloV

Reputation: 52423

There is no direct support for it in ansible. If you have AWS CLI installed, use shell module to modify the SG. You must specify all security groups.

- shell: aws ec2 modify-instance-attribute --instance-id i-12345678 --groups sg-old-123def sg-new-abc123

Upvotes: 2

Related Questions