I need to associate security group to VPC trough awscli, I have 4 security groups that I created and I want to use them multiply times for all the clusters I am going to create, IS there a way to associate an existing security group to a newly created VPC? Is that he right way to do it?
I saw that there is a way like that following command that creates a security group for the specified VPC:
$ aws ec2 create-security-group --group-name my-sg --description "My security group" --vpc-id vpc-1a2b3c4d
{
"GroupId": "sg-903004f8"
}
But I only wants to associate the security group to VPC and not create it...
A security group can be CREATED per VPC, and then you can ASSOCIATE it with other objects in your account, such as Instances, ELBs, etc.
You cannot create cross-VPC security groups if that is your intention.
If you have multiple VPCs with similar rules, you must create a relevant security group for each VPC separately.