Fix:EC2 Tags in create vpc and create subnet (#3338)

Co-authored-by: usmankb <usman@krazybee.com>
This commit is contained in:
usmangani1 2020-09-27 13:54:17 +05:30 committed by GitHub
commit 55e7caccfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 2 deletions

View file

@ -2892,6 +2892,7 @@ class VPCBackend(object):
cidr_block,
instance_tenancy="default",
amazon_provided_ipv6_cidr_block=False,
tags=[],
):
vpc_id = random_vpc_id()
try:
@ -2910,6 +2911,12 @@ class VPCBackend(object):
instance_tenancy,
amazon_provided_ipv6_cidr_block,
)
for tag in tags:
tag_key = tag.get("Key")
tag_value = tag.get("Value")
vpc.add_tag(tag_key, tag_value)
self.vpcs[vpc_id] = vpc
# AWS creates a default main route table and security group.
@ -3409,6 +3416,7 @@ class SubnetBackend(object):
availability_zone=None,
availability_zone_id=None,
context=None,
tags=[],
):
subnet_id = random_subnet_id()
vpc = self.get_vpc(
@ -3479,6 +3487,11 @@ class SubnetBackend(object):
assign_ipv6_address_on_creation=False,
)
for tag in tags:
tag_key = tag.get("Key")
tag_value = tag.get("Value")
subnet.add_tag(tag_key, tag_value)
# AWS associates a new subnet with the default Network ACL
self.associate_default_network_acl_with_subnet(subnet_id, vpc_id)
self.subnets[availability_zone][subnet_id] = subnet