Files
floci/docs/services
Michal Schreiber 20470b7f4a feat(ec2): support transit gateways (#2329)
* feat(ec2): support transit gateways

CreateTransitGateway, DescribeTransitGateways, ModifyTransitGateway and
DeleteTransitGateway, as EC2 Query actions alongside the existing VPC and
route table ones. Metadata only: nothing routes packets, and the value is
in ids later resources can reference and describes that round-trip so
plans converge.

Option defaults come from a live AWS account rather than the reference:
amazonSideAsn 64512, dnsSupport, vpnEcmpSupport and both default route
table options enabled, autoAcceptSharedAttachments,
securityGroupReferencingSupport and multicastSupport disabled. The last
of those is the one worth stating, since disable is easy to assume the
other way round. transitGatewayCidrBlocks is omitted entirely when unset
rather than sent empty.

Creating a gateway with either default route table option enabled also
mints the route table AWS mints, and reports its id as both
associationDefaultRouteTableId and propagationDefaultRouteTableId. Both
name the same table, and it is already on the create response rather than
appearing later, so a caller reading either id sees what AWS shows. The
actions that operate on route tables directly are not implemented; nor
are attachments.

State is reported settled rather than transitional. AWS returns a new
gateway as pending and reaches available in about 50 seconds, and reports
deleting for about a minute before deleted; nothing here is slow, so the
settled state is what the caller sees, matching how
createManagedPrefixList already compresses create-in-progress.

Modify and delete echo the gateway without its tagSet while create and
describe include it, which is what the live API does.

Part one of #2308.

* fix(ec2): keep a transit gateway's default route table options coherent

ModifyTransitGateway changed the DefaultRouteTableAssociation and
DefaultRouteTablePropagation flags without touching their route table
ids, so a gateway created with both disabled could be modified into
reporting an option enabled while carrying no id for it.

AWS does not create a route table on that request; it rejects it unless
an existing table is named, and rejects an id supplied alongside a
disable. An unknown table comes back as InvalidRouteTableID.NotFound
rather than a transit-gateway-specific code. Checked on a live account:

  enable DefaultRouteTableAssociation conflicts with
  AssociationDefaultRouteTableId null

  disable DefaultRouteTableAssociation conflicts with
  AssociationDefaultRouteTableId tgw-rtb-0123456789abcdef0

  Transit Gateway Route Table tgw-rtb-0123456789abcdef0 was deleted or
  does not exist.

Validate instead: the flag and its id have to move together in both
directions, and a named table has to exist. The divergent state is now
unreachable and a rejected call leaves the gateway untouched.

* fix(ec2): carry a default route table change through to what it governs

Disabling DefaultRouteTableAssociation or DefaultRouteTablePropagation
changed the flag alone, leaving the id it governs on the gateway and the
matching marker on the route table. A describe then reported the option
disabled while still naming a table, and the table still claimed to be
the default for it.

Checked on a live account. Disabling association on a gateway created
with both defaults enabled drops AssociationDefaultRouteTableId from the
options entirely rather than blanking it, clears DefaultAssociationRouteTable
on the table, and leaves the table itself in place with its propagation
marker and the gateway's PropagationDefaultRouteTableId untouched:

  DefaultRouteTableAssociation  disable      (no AssociationDefaultRouteTableId)
  DefaultRouteTablePropagation  enable       PropagationDefaultRouteTableId tgw-rtb-…
  tgw-rtb-…  available  defAssoc False  defProp True

Apply the same: the id follows its flag, the table's marker follows with
it, and the table survives. Enabling with a named table marks that table
instead.

* fix(ec2): require a default route table to belong to the gateway naming it

The route table named on a ModifyTransitGateway request was only checked
for existence in the region, so a gateway could take another gateway's
table as its default. Worse than a bad reference: applying the change
then rewrote the foreign table's own default marker, leaving the gateway
that actually owns it describing a table that no longer claims to be its
default.

AWS rejects this, under the same code as a table that exists nowhere but
with the gateway named in the message. Checked on a live account, gateway
A naming gateway B's default table:

  Transit Gateway Route Table tgw-rtb-0381f… was deleted or does not
  exist in Transit Gateway tgw-0438f…

Both wordings are now reproduced: unqualified when the table exists
nowhere, gateway-qualified when it exists but belongs elsewhere.

The three rules governing these options - flag and id agreeing in both
directions, and the named table existing and belonging to the gateway -
now sit in one validation block rather than accumulating as separate
guards.

* fix(ec2): judge a default route table change against the stored gateway

Validation looked only at the request, so a route table id arriving
without its flag skipped the coherence check entirely: the id was stored
while the table's default marker was left alone, and a disabled option
could end up naming a table.

AWS judges the pair against the gateway as it stands. Probed the whole
combination surface on a live account rather than the one case reported:

  id alone, option enabled     accepted
  id alone, option disabled    InvalidParameterCombination, and the
                               message quotes the stored flag, not the request
  enable alone, table named    accepted, keeps that table
  enable alone, no table       InvalidParameterCombination
  disable with an id           InvalidParameterCombination
  disable with an unknown id   the combination is reported, not the lookup

So the flag defaults to the stored one when the request omits it, enabling
without an id keeps the table already named rather than dropping it, and an
id on its own marks its table. The lookup still runs after the combination
check, which is the order AWS reports them in.

Two other behaviours from the same pass, both already correct and now
covered: removals apply before additions, so a CIDR added and removed in
one call survives, and removing a CIDR that is not present is accepted.

* fix(ec2): serialize transit gateway CIDR blocks as the string list they are

transitGatewayCidrBlocks is a plain string list, so each item carries the
CIDR as its own text. The items wrapped it in a cidrBlock element
instead, which the AWS CLI parsed as an empty string: a caller that added
a block got it back as "" from create, describe and modify alike.

Caught by the CLI compatibility suite, not by the integration test, which
asserted the same wrong shape the handler produced and so agreed with it.
The bats case now reads the list back through describe as well as modify,
since one helper serializes all three responses.

* fix(ec2): apply tag changes to a transit gateway, not just to the tag store

CreateTags and DeleteTags on a tgw- id updated the tag store but left the
gateway object alone, because updateResourceTags had no branch for it.
DescribeTags saw the change and DescribeTransitGateways did not, so a
gateway kept serving whatever tags its TagSpecification carried at
creation.

That is the path a Terraform tag update takes: the provider sends
CreateTags, then re-reads with DescribeTransitGateways and compares. With
the two disagreeing, aws_ec2_transit_gateway would never converge.

Route tables get the same branch, so their tags behave once part three
can create them.

The AWS CLI cases now cover the tag round trip and CIDR blocks supplied
at creation, both of which were only asserted against shapes this branch
produced itself.
2026-08-15 18:11:24 -04:00
..
2026-05-10 11:53:31 -05:00
2026-05-10 11:53:31 -05:00
2026-05-10 11:53:31 -05:00
2026-05-10 11:53:31 -05:00
2026-05-10 11:53:31 -05:00
2026-05-10 11:53:31 -05:00