I have one ec2 instance(instance_A), and I have to create one more new ec2 instance(instance_B) using instance_A ec2_fact.
to get facts of ec2 I am using the ec2_instance_facts module.on instance_A have multiple security groups which I want to add on instance_B on creation time.
I am not able to figure it out how to add all security group of instance_A to instance_B
Can you help me with this problem?
here is ec2_facts result.
"public_dns_name": "ec2-10.ab-cd-ef.compute.amazonaws.com",
"public_ip_address": "18.XX.XX.XX",
"root_device_name": "/dev/sda1",
"root_device_type": "ebs",
"security_groups": [
{
"group_id": "sg-4e3bb823",
"group_name": "ws-services"
},
{
"group_id": "sg-4e3bb824",
"group_name": "dbs-services"
},
{
"group_id": "sg-4e3bb825",
"group_name": "dbs-services"
},
{
"group_id": "sg-1834b775",
"group_name": "dcs-services"
},
{
"group_id": "sg-4e3bb823",
"group_name": "app-services"
},
{
"group_id": "sg-4e3bb823",
"group_name": "prod-services"
}
],
"source_dest_check": true,
"state": {
"code": 16,
"name": "running"
},
"state_transition_reason": "",