adding physical_resource_id in SubnetRouteTableAssociation, Route and NatGW classes (#3789)
* adding physical_resource_id in SubnetRouteTableAssociation, Route and NatGW classes * adding tests * passing litern at test * passsing black==19.10b0 as lintern * passing test to python 2.7
This commit is contained in:
parent
a5fc99c9af
commit
04cbd1fa1a
@ -4030,6 +4030,10 @@ class SubnetRouteTableAssociation(CloudFormationModel):
|
||||
self.route_table_id = route_table_id
|
||||
self.subnet_id = subnet_id
|
||||
|
||||
@property
|
||||
def physical_resource_id(self):
|
||||
return self.route_table_id
|
||||
|
||||
@staticmethod
|
||||
def cloudformation_name_type():
|
||||
return None
|
||||
@ -4254,6 +4258,10 @@ class Route(CloudFormationModel):
|
||||
self.interface = interface
|
||||
self.vpc_pcx = vpc_pcx
|
||||
|
||||
@property
|
||||
def physical_resource_id(self):
|
||||
return self.id
|
||||
|
||||
@staticmethod
|
||||
def cloudformation_name_type():
|
||||
return None
|
||||
@ -5843,6 +5851,10 @@ class NatGateway(CloudFormationModel):
|
||||
self._backend.associate_address(eni=self._eni, allocation_id=self.allocation_id)
|
||||
self.tags = tags
|
||||
|
||||
@property
|
||||
def physical_resource_id(self):
|
||||
return self.id
|
||||
|
||||
@property
|
||||
def vpc_id(self):
|
||||
subnet = self._backend.get_subnet(self.subnet_id)
|
||||
|
@ -1940,13 +1940,23 @@ def test_nat_gateway():
|
||||
|
||||
cf_conn = boto3.client("cloudformation", "us-east-1")
|
||||
cf_conn.create_stack(StackName="test_stack", TemplateBody=json.dumps(template))
|
||||
stack_resources = cf_conn.list_stack_resources(StackName="test_stack")
|
||||
nat_gateway_resource = stack_resources.get("StackResourceSummaries")[0]
|
||||
for resource in stack_resources["StackResourceSummaries"]:
|
||||
if resource["ResourceType"] == "AWS::EC2::NatGateway":
|
||||
nat_gateway_resource = resource
|
||||
elif resource["ResourceType"] == "AWS::EC2::Route":
|
||||
route_resource = resource
|
||||
|
||||
result = ec2_conn.describe_nat_gateways()
|
||||
|
||||
result["NatGateways"].should.have.length_of(1)
|
||||
result["NatGateways"][0]["VpcId"].should.equal(vpc_id)
|
||||
result["NatGateways"][0]["SubnetId"].should.equal(subnet_id)
|
||||
result["NatGateways"][0]["State"].should.equal("available")
|
||||
result["NatGateways"][0]["NatGatewayId"].should.equal(
|
||||
nat_gateway_resource.get("PhysicalResourceId")
|
||||
)
|
||||
route_resource.get("PhysicalResourceId").should.contain("rtb-")
|
||||
|
||||
|
||||
@mock_cloudformation()
|
||||
|
Loading…
Reference in New Issue
Block a user