cloudtools / cloudtools/troposphere

GatewayId is evil

Open
#436 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
4.9k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Description

Hey there,

I just spent a bit of time with AWS Support, so wanted to pass it on and get a type check in Route.

troposphere will gladly generate a template from this code:

``` python
nat = t.add_resource(ec2.NatGateway(
'NatGateway{}'.format(letter),
AllocationId=GetAtt(eip, 'AllocationId'),
SubnetId=az['subnet_id']
))
t.add_resource(ec2.Route(
'NatGateway{}Route'.format(letter),
GatewayId=Ref(nat),
DestinationCidrBlock='0.0.0.0/0',
RouteTableId=Ref(route_table_id),
))
```

and silly me didn't realize that `GatewayId` is only for IGWs and VGWs. For a NAT Gateway they have a separate field called `NatGatewayId` when creating a Route. The above should be:

``` python
t.add_resource(ec2.Route(
'NatGateway{}Route'.format(letter),
NatGatewayId=Ref(nat),
DestinationCidrBlock='0.0.0.0/0',
RouteTableId=Ref(route_table_id),
))
```

I think some troposhere resources do some type checking, right? Can we add a type check to `GatewayId` in `Route` to return an error message when someone references a `ec2.NatGateway`?

Contributor guide

Open the contributing guide

Research direction

Start by locating the ec2.Route and ec2.NatGateway definitions and reviewing how existing resource property type checks work. Verify the distinction between GatewayId and NatGatewayId, then add coverage showing that a NatGateway reference in GatewayId produces an error while the NatGatewayId form remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.