* 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.
* feat(ec2): allow a security group rule to take a prefix list as its source
AuthorizeSecurityGroupIngress and AuthorizeSecurityGroupEgress now read
IpPermissions.N.PrefixListIds.M, so a rule can name a managed prefix list
instead of a CIDR. The rule carries prefixListId in place of cidrIpv4 and
DescribeSecurityGroups nests the reference under the permission, matching the
shapes AWS returns.
AWS emits one rule per source, so createRules expands a permission across its
CIDRs and its prefix lists rather than treating the two as alternatives; a
permission naming neither still yields the single bare rule it did before. An
unknown list is rejected with InvalidPrefixListID.NotFound before the rule is
stored, so a typo cannot leave a rule pointing at nothing.
Closes#2269
* fix(ec2): resolve every prefix list before writing any security group rule
createRules stored the CIDR rules of a permission before validating its prefix
lists, so a permission naming a valid CIDR alongside an unknown list returned
InvalidPrefixListID.NotFound while leaving the CIDR rule behind. AWS persists
neither, checked against a live account, and rejects the call as a whole rather
than per permission.
Resolve every reference a request names before the first write, across all of
its permissions, so a later bad permission cannot leave an earlier good one
applied. Also brace the new parsing conditional, as AGENTS.md requires.
* style(ec2): brace the conditionals in parseIpPermissions
AGENTS.md is unconditional about braces, and the method held five unbraced
conditionals around the line this branch added. Bracing the whole method rather
than only the new line keeps it internally consistent.
* fix(ec2): scope security group revocation to the sources it names
Revocation compared only protocol and ports, so revoking one source removed
every permission sharing that tuple: revoking a prefix list also dropped a CIDR
rule on the same port. AWS scopes it to the source, verified against a live
account, and leaves the others in place.
Subtract the named sources instead, dropping a permission only once it had
sources and has lost them all. A request naming no source at all still removes
the whole matching permission, which is how a bare protocol and port revoke
behaves.
The permission a revoke names can be the very object authorize stored on the
group, so the source values are snapshotted before either list is mutated.
* fix(ec2): validate prefix lists once per request rather than per permission
Resolving the prefix lists again inside createRules reopened the window the
request-wide check had closed: a list can be deleted between the two, since the
group lock and the prefix list lock are different monitors, so a later
permission could fail after earlier ones had already stored their rules.
Authorize resolves every reference before the first write, so the repeat is
removed. createRules keeps no validation of its own; its other callers pass the
CIDR-only default egress permission.
* fix(ec2): resolve group references when revoking too
Scoped revocation compares the sources a request names against the ones
stored on the permission. Authorize resolves a reference made by group
name to its group id before storing it, so a revoke naming the same
source by name alone carried no id and matched nothing: the rule
survived the revoke that named it.
Resolve on the revoke path as well, mirroring authorize.
This only surfaces once both source-scoped revocation and group
references as a source exist, so the gap is between this branch and
#2266 rather than in either alone.
---------
Co-authored-by: Michal Schreiber <michal.schreiber@benefitsystems.pl>
* feat(ec2): support CreateImage from an instance
Validates the source instance exists, then registers an image the same
way RegisterImage does. Unblocks AMI-baking flows (e.g. CDK
AwsCustomResource calling ec2:CreateImage on a stack-created instance).
Fixes#1978
* fix(ec2): CreateImage reboots the source and produces a launchable AMI
Two review findings.
CreateImage ignored the default reboot. AWS reboots the source instance unless
NoReboot=true so the image is captured from a quiesced file system; the action
only checked that the instance existed. NoReboot is now parsed and the reboot
runs by default.
The resulting AMI kept nothing of what it was captured from. registerImage was
called with null architecture, root device and block device mappings, so
DescribeImages reported a generic x86_64 /dev/sda1 image with no devices, and
RunInstances on the new id fell through to the catalog default guest because a
generated ami-* is not in the catalog. The image now inherits architecture,
root device name and block device mappings from the source instance's image,
and records the launchable ancestor so RunInstances starts the same guest.
CreateImage on an instance launched from a created AMI follows the chain back.
Tests: unit coverage for the reboot default and its NoReboot opt-out, and for
chained images resolving to the catalog ancestor rather than the generated id;
integration coverage that an arm64 source yields an arm64 AMI that launches.
* fix(ec2): a capture of a catalog AMI reports its root device
CreateImage inherits the source image's block device mappings, but a catalog
entry describes only its root device name and carries no mappings, so an AMI
captured from a catalog-launched instance was registered with no devices and
DescribeImages reported none.
The root device is now rebuilt from the catalog entry, with a snapshot
registered through the existing RegisterImage path.
* fix(ec2): a capture takes its own snapshot of each device
CreateImage handed the source AMI's mappings straight to RegisterImage, so the
captured image reported the source's snapshot ids and the two images shared one
snapshot. The mappings are now copied with fresh snapshot ids, keeping the
device name, size, type and encryption.
* fix(ec2): a capture includes the volumes attached after launch
CreateImage read only the mappings of the AMI the instance was launched from, so
a data volume attached afterwards was missing from the captured image. AWS
records block device mapping information for those volumes as well.
The instance's attached volumes are now added to the capture, each with its
device name, size, type and a fresh snapshot. The root volume is skipped because
the source AMI already describes that device.
Also lists CreateImage and RegisterImage in the AMIs action table. That table is
hand-maintained because Ec2QueryHandler is a deferred handler.
* fix(ec2): a capture reports the root volume type the source actually has
The catalog-source fallback in sourceImageMappings recorded the rebuilt root
device as gp2, while RunInstances creates the source instance's root volume as
gp3. DescribeImages therefore reported a type the instance never had.
Both sites now read one DEFAULT_ROOT_VOLUME_TYPE constant, alongside the
existing DEFAULT_ROOT_VOLUME_SIZE_GIB, so the two cannot drift apart again.
* fix(ec2): keep the source on security group rules
AuthorizeSecurityGroupIngress and -Egress read only
IpPermissions.N.IpRanges.M.CidrIp, so a rule whose source is another
security group was accepted and then silently stripped: it came back with
no source at all on the authorize response, on DescribeSecurityGroups and
on DescribeSecurityGroupRules. "Allow traffic from security group X" is how
an ALB is wired to its backend tasks, so that whole class of wiring could
be created against Floci but never asserted afterwards.
Parse the source types the permission actually carries: group references,
which the EC2 Query protocol serializes under the wire name Groups rather
than the SDK-facing UserIdGroupPairs, and IPv6 ranges. A reference made by
group name resolves to its group id within the target group's VPC, since
names are unique per VPC and ReferencedSecurityGroup has no name field.
Flatten one SecurityGroupRule per source entry, each keeping its own
description, matching the AWS invariant that a rule holds exactly one
source. A permission with no source at all still yields a single sourceless
rule, as before. The reference is returned as referencedGroupInfo on
DescribeSecurityGroupRules and as UserIdGroupPairs on
DescribeSecurityGroups.
An IPv6-only TCP ingress rule now publishes its host port, which it could
not do while the ranges were dropped at the parse; Ec2PortForwardManager
already treats IPv6 ranges as a CIDR source, and group references stay
unpublished.
Revoke still matches on protocol and port range alone and ignores sources,
unchanged by this.
Closes#2190
* style(ec2): brace the conditionals in the new source parsing
AGENTS.md requires braces on every conditional. The new IPv6 and group
source loops and the group-reference resolution used the unbraced form
the surrounding parse loop happens to use.
* fix(ec2): reject prefix list names AWS reserves for its own lists
CreateManagedPrefixList accepted names beginning com.amazonaws., com.amazon. or
com.aws., which AWS refuses with InvalidParameterValue, so a customer list could
shadow a seeded gateway-endpoint one.
The trailing dot is part of each prefix. Checked against a live account:
com.amazonaws-probe and comamazonaws.probe are both accepted there, so matching
without the dot would refuse names AWS allows.
Closes#2273
* fix(ec2): apply the reserved-name rule to a prefix list rename too
ModifyManagedPrefixList persisted any nonblank name, so a list could be renamed
to com.amazonaws.us-east-1.s3 and returned alongside the seeded AWS-managed list
of that name. AWS applies the same rule to a rename, verified against a live
account, and leaves the existing name in place when it rejects one.
Create and rename now share the check.
---------
Co-authored-by: Michal Schreiber <michal.schreiber@benefitsystems.pl>
* feat(ec2): support managed prefix lists
Implement CreateManagedPrefixList, DescribeManagedPrefixLists,
GetManagedPrefixListEntries, ModifyManagedPrefixList and
DeleteManagedPrefixList.
Entries are versioned: a list starts at version 1 and every modification that
changes entries stores a new version, so GetManagedPrefixListEntries can serve
an earlier TargetVersion. Renaming or raising MaxEntries does not create a
version, CurrentVersion makes a modification conditional, and removals apply
before additions so one call can replace an entry's description.
The AWS-managed gateway-endpoint lists are now built once and served by both
DescribeManagedPrefixLists and the existing DescribePrefixLists, so the two
surfaces cannot report different CIDRs for the same list. They are read-only.
Closes#2100
* fix(ec2): validate prefix list input and keep tag copies in sync
Three defects in the managed prefix list surface:
ModifyManagedPrefixList only checked the resulting entry count against
MaxEntries, so a zero or negative MaxEntries on an empty list passed the check
and persisted an impossible capacity.
CreateTags and DeleteTags update the generic tag store and then mirror the
result onto the resource, but updateResourceTags had no arm for prefix lists,
leaving the copy on the model stale for describe responses and tag filters.
MaxEntries and TargetVersion were converted with Integer/Long.valueOf, so
malformed input escaped as an unchecked NumberFormatException and became a 500
rather than a structured EC2 client error.
* fix(ec2): reject a missing PrefixListId and infer the prefix-list tag type
A null PrefixListId reached List.of() inside describeManagedPrefixLists and
threw NullPointerException, so DeleteManagedPrefixList,
GetManagedPrefixListEntries and ModifyManagedPrefixList answered a request that
never named a list with a 500 rather than a client error. Guard the lookup and
raise MissingParameter.
inferResourceType had no pl- arm, so tags on a prefix list were stored but
reported as resourceType "unknown" and were invisible to a DescribeTags filter
on resource-type. The existing test only covered describe and tag: filters,
which is why this went unnoticed.
Also cover the accepting branch of the address-family check, which until now was
only reached by the rejecting case.
* fix(ec2): treat a blank numeric parameter as malformed rather than absent
intOrNull and longOrNull returned null for a present but blank value, which the
callers read as "parameter not supplied". For CurrentVersion that silently
downgraded a conditional ModifyManagedPrefixList to an unconditional one, so a
request that asked to be gated on a version was applied anyway. Only an absent
parameter is null now; a blank one reaches the parse and surfaces as
InvalidParameterValue.
* fix(ec2): report PrefixListVersionMismatch for a stale CurrentVersion
A conditional ModifyManagedPrefixList that loses the version check returns
PrefixListVersionMismatch on AWS, not IncorrectState; verified against a live
account, which also supplies the message. The Terraform provider keys its retry
handling on that code, so the previous one would have left a caller unable to
recognise a losing conditional update.
---------
Co-authored-by: Michal Schreiber <michal.p.schreiber@gmail.com>
Terraform calls ReplaceRoute whenever an existing route changes target, so
route tables could be created but never updated; the only workaround was
to destroy and recreate the table.
The action replaces the target of the route matching DestinationCidrBlock.
AWS takes exactly one target per call, so the target a request does not name
is cleared rather than carried over; a merge would leave a route holding two
targets at once, which AWS cannot produce.
Only GatewayId and NatGatewayId are modelled by Route, plus LocalTarget,
which needs no new field because `local` is the gateway id a route table's
built-in route already carries. The other ten AWS targets keep the
UnsupportedOperation they returned before this action existed rather than
being accepted and silently clearing the route they were meant to repoint.
Errors follow the EC2 reference: InvalidRoute.NotFound when no route matches
the destination, MissingParameter when DestinationCidrBlock is absent (an
IPv6 or prefix-list request), and InvalidParameterCombination for two
targets or none.
Closes#2087
* docs: fill supported action descriptions
* docs(elb): describe listener default rule as non-deletable, not immutable
The CreateListener row called the default rule "immutable", which contradicts
the ModifyListener row (updates default actions) and the file's own note that
the rule can be changed via ModifyListener. The rule cannot be deleted or
reprioritized, but its action is mutable, so "non-deletable" is accurate.
* feat(ec2): publish security-group TCP ingress ports on the host
For each TCP port opened to a CIDR source by an instance's security
groups, start an alpine/socat sidecar that binds an allocated host port
(default 30000-30999) and forwards to the instance container's IP, so
the app is reachable from localhost. Forwards reconcile at launch, on
authorize/revoke-security-group-ingress, and on ModifyInstanceAttribute
group reassignment (previously ignored). Mappings persist and are
restored across restarts. SSH is never re-forwarded; wide rules and
per-instance totals are capped; disable with
publish-security-group-ports=false.
* fix(ec2): drop stale port mapping when sidecar recreation fails
On restore, a failed socat recreation released the host port but left
the appPort->hostPort entry in publishedPorts, so later reconciles saw
the port as already published and never re-published it, and a later
unpublish could double-release the host port. Remove the entry and
persist on failure. Also null-guard portForwardManager.restore() for
consistency with the setPersister guard. Adds a regression test.
* fix(ec2): skip port-forward reconcile on non-running instances
A reconcile queued by authorize-security-group-ingress could run after
a concurrent stop/terminate had already cleared publishedPorts and
removed the container; it then republished via the stale bridge IP,
leaking an orphaned socat sidecar and a host port that nothing would
release. Stop/terminate flip the instance state before their async
unpublishAll, so guarding reconcileNow on the running state under the
instance lock closes every window. Adds regression tests.
- emit routeTableIdSet/subnetIdSet items as plain text (AWS SDK for Go could not
deserialize the wrapped form)
- add DescribePrefixLists returning managed S3/DynamoDB prefix lists
- honor private_dns_enabled (default true for interface endpoints)
Adds Ec2IntegrationTest coverage and documents the new actions.
Implements CreateNetworkAcl, DescribeNetworkAcls (with vpc-id / default /
association.subnet-id filters), CreateNetworkAclEntry, ReplaceNetworkAclEntry,
DeleteNetworkAclEntry, ReplaceNetworkAclAssociation, and DeleteNetworkAcl.
Every VPC is provisioned with a default NACL and each subnet is associated with
it, so aws_network_acl and aws_default_network_acl work via Terraform.
Adds Ec2IntegrationTest coverage and documents the new actions.
CHANGELOG.md was empty for the 1.1.0-1.5.2 release cycle and service docs
had drifted from code behaviour. This sweep reconciles docs against the
current codebase on upstream/main.
- Backfill CHANGELOG.md for 1.1.0 through 1.5.2 from git history
- Correct exact operation counts in docs/services/index.md: S3 (~30 -> 58),
Lambda (~25 -> 30), API Gateway v1 (~24 -> 62). Counts now come from the
actual dispatch handlers rather than @Path annotation counts.
- Rewrite README "Supported Services" table to drop per-service op counts
(they drift too fast); point readers at docs/services/index.md
- Update 24 service docs for accuracy, add "Not Implemented" sections
where relevant (s3.md, lambda.md, api-gateway.md)
- Refresh configuration and getting-started docs
- Add EventBridge Scheduler and AppConfig to mkdocs nav
- Add AppConfig / AppConfigData rows to README and services index
following the 1.5.2 upstream release