Commit Graph
16 Commits
Author SHA1 Message Date
David Phillips 7ce4b6bd23 feat(autoscaling): describe suspended process reasons (#5941)
* feat(autoscaling): describe suspended process reasons

* fix(autoscaling): record suspended process dates
2026-10-18 14:24:58 -04:00
Jackson Price 0be4581d4e fix(ec2): preserve IAM instance profile identity (#5671)
* fix(ec2): preserve IAM instance profile identity

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): probe metadata readiness with IMDSv2

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(autoscaling): preserve launch profiles and metadata options

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): preserve automatic public addresses across launch paths

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): honor metadata token requirements and profile identity

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): keep synthesized node identity and mock addresses consistent

- IMDS iam/info serves the instance profile identity EKS synthesizes for
  its cluster nodes while IAM holds no such profile. The node carries a
  stable IAM-shaped profile id, which DescribeInstances now copies too.
- Mock instances get their automatic public address however the launch
  completes, DescribeInstanceStatus included. An associated Elastic IP
  replaces it, disassociating gives a running instance a new one, and
  termination leaves none.
- CreateFleet forwards the launch template's metadata options and its
  primary interface AssociatePublicIpAddress.
- Launch templates store a profile name and ARN pair as given and the
  launch from them rejects it, since AWS does not fully validate
  template parameters at creation.
- CloudFormation launch-configuration MetadataOptions resolve Fn::If and
  AWS::NoValue.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): refuse profile pairs for groups and keep Elastic IPs exclusive

- Auto Scaling refuses a group whose launch template, directly or
  through its mixed instances policy, names both an instance profile
  name and an ARN, with ValidationError, instead of accepting a group
  that can never launch.
- AssociateAddress disassociates the Elastic IP an instance already
  has, as AWS documents. In mock mode a terminated instance takes no
  address, and an unchanged address is not written again.
- IMDS iam/info falls back to a cluster node's synthesized identity
  only while IAM holds no profile at that ARN; a held profile without a
  role answers 404.
- CreateFleet takes the subnet of the device-index-0 interface first,
  as RunInstances does.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(ec2): assert profile ids and launch configuration metadata via the SDK

Ec2InstanceProfilePathTest now checks that direct, template, override
and fleet launches report IAM's InstanceProfileId, and AutoScalingTest
round-trips launch configuration MetadataOptions through the AWS SDK for
Java v2, including the absent structure and a rejected hop limit.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): displace an Elastic IP a retained interface carries

- AssociateAddress also disassociates an Elastic IP held by the
  instance's primary interface, which a retained network interface
  carries from an earlier instance, so one instance never holds two.
- Mock stop and terminate change the instance's state and public
  address under its lock, like the launch and Elastic IP writes.
- Docs and comments say where the profile pair fails and when
  CreateFleet falls back to another interface's subnet.
- Tests cover the retained-interface address, the group update path,
  the full refusal message and the fleet's availability zone, and the
  SDK launch configuration test cleans up on failure.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): refuse reserved RunInstances tags before resolving the profile

Resolving the instance profile called the EC2 service before tag parsing,
so a reserved aws: tag was refused only after that lookup. Parse tags first,
as the reserved-tag check requires.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(autoscaling): assert the refresh launched the replacement

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(autoscaling): describe what the refresh assertion checks

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(cloudformation): cover invalid launch-configuration metadata options

Invalid HttpTokens, invalid HttpEndpoint, hop limits of 0 and 65 and a
non-integer hop limit each fail the AWS::AutoScaling::LaunchConfiguration
resource with the validation message, roll the stack back and leave no
launch configuration behind.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(cloudformation): pin metadata failure reasons and accepted hop limits

Assert the exact resource failure reason, and cover hop limits of 1 and 64,
a string hop limit and one from a Number parameter.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* refactor(ec2): leave IMDS token enforcement to a separate change

HttpTokens=required enforcement, the IMDSv2 readiness probe and the helper
shell environment reset move to their own pull request, so this change
keeps only the instance profile identity.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* refactor(ec2): leave mock public addresses to a separate change

Mock public IPv4 assignment, primary-interface public IP and subnet handling
and Elastic IP displacement move to their own pull request.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* refactor(autoscaling): leave launch metadata options to a separate change

Launch-configuration MetadataOptions over Query and CloudFormation, and
metadata options forwarded from launch templates and EC2 Fleet, move to
their own pull request. Launch-configuration profile resolution stays.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(ec2): use the shared metadata and authorization fixtures

Ec2MetadataProfileIntegrationTest starts its metadata server and requests
tokens through Ec2MetadataTestFixture, and it and
Ec2InstanceProfileIdentityIntegrationTest build their Authorization header
with EnforcementFixtures.auth.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* docs(ec2): close the Auto Scaling profile paragraph's code fence

Removes a stray fence that rendered the launch-configuration profile
paragraph as code, and a doubled blank line before the iam/info paragraph.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(ec2): find profile identity launches by a run tag

Each launch carries a tag unique to the test run, and the tests look their
instances up by that tag rather than by client token.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* refactor(ec2): leave the client-token filter to a separate change

The instance filter is not part of the profile identity, and this copy let
a wildcard match instances launched without a token.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-17 08:03:38 -04:00
Allen Sanborn 05153b30be feat(autoscaling): implement DescribeTags (#5750)
* feat(autoscaling): implement DescribeTags

DescribeTags returned UnsupportedOperation while CreateOrUpdateTags and
DeleteTags already stored group tags. Serve it from those stored tags:
filters auto-scaling-group, key, value and propagate-at-launch (values
within a filter ORed, filters ANDed, unknown filter names rejected with
ValidationError), MaxRecords/NextToken paging reusing the offset token
DescribeInstanceRefreshes uses, results ordered by group then key.

* fix(autoscaling): reject non-numeric MaxRecords and sparse filter indices in DescribeTags

* fix(autoscaling): harden DescribeTags paging, vanished groups and oversized indices

- rejectIndexGap compares member indices as BigInteger, so an index past
  int range is a 400 ValidationError instead of a NumberFormatException 500.
- describeTags skips a null group value (deleted between StorageBackedMap's
  key snapshot and value read).
- NextToken is now an opaque cursor on the last (group, key) returned, not
  an offset, so tags added or removed between pages are neither skipped
  nor repeated.
- Import hamcrest containsString in the integration test.

* fix(autoscaling): sign DescribeTags NextToken and route DescribeTags by Version

A token that decodes to a (group, key) it was never issued for is now
refused with InvalidNextToken, as AWS refuses a token it did not mint:
the cursor carries an HMAC-SHA256 over region and cursor under a
per-process key. DescribeTags joins the autoscaling action set so a
request without a credential scope reaches autoscaling under its
2011-01-01 Version instead of ec2.

* fix(autoscaling): bind DescribeTags NextToken to the account; per-instance HMAC key

A static SecureRandom key can be initialized at native-image build time and
baked into every process; hold it on the ApplicationScoped bean instead. The
MAC now covers the caller's account id, so a token issued under one account
is InvalidNextToken under another.

* fix(autoscaling): draw the DescribeTags cursor key with nextBytes, not generateSeed

* fix(autoscaling): AND repeated DescribeTags filters of the same name

Each Filters.member entry is now its own filter, so two 'key' filters
must both match instead of being merged into one ORed value list, per
the Filter shape: multiple filters are joined with AND.

Also cover a NextToken whose own cursor tag is deleted between pages.

* fix(autoscaling): page DescribeTags through core Pagination, read filters to first gap

Per review: the NextToken is now a (group, key) cursor through
core.common.Pagination with a namespace and InvalidNextToken, replacing
the HMAC, per-instance key and account binding (groups are stored per
account, and the per-instance key voided every token on restart).
rejectIndexGap is gone; filters are read up to the first missing index
like every other member list in the handler. propagate-at-launch values
match exactly, as the Filter model says values are case-sensitive.
2026-10-15 21:07:14 -04:00
David Phillips b395560fe2 fix(autoscaling): preserve paused refresh ownership (#5668)
* fix(autoscaling): retain paused refresh replacements across reloads

* fix(autoscaling): preserve paused and detached refresh instances

* fix(autoscaling): retain recovered refresh launch identity

* test(autoscaling): cover refresh recovery across groups

* test(autoscaling): cover paused refresh SDK responses

* fix(autoscaling): publish refresh ownership before reconciliation

* fix(autoscaling): release refresh ownership during group changes

* test(autoscaling): retain launch settings during refreshes

* fix(autoscaling): report accepted refresh placement

* fix(autoscaling): retain refresh settings and report launch failures
2026-10-14 17:05:00 -04:00
Andre Kurait 6442d75115 fix(autoscaling): balance scale-out across zones and subnets (#5525)
Signed-off-by: Andre Kurait <akurait@amazon.com>
2026-10-14 13:48:06 -04:00
David Phillips b488d0c418 fix(autoscaling): preserve launch template user data (#5607)
* fix(autoscaling): preserve launch template user data

* test(autoscaling): share launch-template SDK fixtures
2026-10-14 07:24:34 -04:00
David Phillips ddc0e0257b fix(autoscaling): preserve launch configuration user data (#5600)
* fix(autoscaling): preserve launch configuration user data

* fix(autoscaling): reject unusable launch configuration data
2026-10-13 21:26:05 -04:00
David Phillips 41517f3c2f fix(autoscaling): pause suspended capacity adjustments (#5545)
* fix(autoscaling): pause suspended capacity adjustments

* test(autoscaling): cover suspended capacity through AWS clients

* fix(autoscaling): coordinate suspension with capacity changes

* fix(autoscaling): keep capacity locks within each account

* test(autoscaling): check suspension without scheduler waits
2026-10-13 09:37:17 -04:00
lex00 991bf3ab9e fix(autoscaling): round-trip InstanceMaintenancePolicy, AvailabilityZoneDistribution, CapacityReservationSpecification, ServiceLinkedRoleARN, WeightedCapacity and EnabledMetrics (#5513)
* fix(autoscaling): round-trip InstanceMaintenancePolicy, AvailabilityZoneDistribution, CapacityReservationSpecification, ServiceLinkedRoleARN, WeightedCapacity and EnabledMetrics

DescribeAutoScalingGroups dropped several members of the AutoScalingGroup shape
that CreateAutoScalingGroup and UpdateAutoScalingGroup accept, so a client that
set them read them back as absent and saw a permanent diff.

- AsgOptionalFields gains ServiceLinkedRoleARN, InstanceMaintenancePolicy,
  AvailabilityZoneDistribution and CapacityReservationSpecification with its
  CapacityReservationTarget. The four-argument constructor stays, so existing
  call sites are unchanged.
- MixedInstancesPolicy launch template overrides carry WeightedCapacity.
- EnableMetricsCollection and DisableMetricsCollection are implemented, and
  DescribeAutoScalingGroups reports EnabledMetrics.
- Validation follows the botocore model. MinHealthyPercentage 0 to 100 and
  MaxHealthyPercentage 100 to 200, both required, at most 100 apart, and -1
  on both clears the policy. CapacityDistributionStrategy and
  CapacityReservationPreference enums. No target with preference none.
  CapacityReservationIds 1 to 255 characters matching [A-Za-z0-9-_/] and
  resource group ARNs 1 to 1600. ServiceLinkedRoleARN 1 to 1600 characters.
  WeightedCapacity 1 to 999 in at most 32 characters, set on every override
  or none. Granularity required and 1Minute. Known metric names only.
- The AWS::AutoScaling::AutoScalingGroup provisioner passes the new properties
  and MetricsCollection through, and its update rollback snapshot restores
  them. It requires CapacityReservationPreference and each entry's
  Granularity as the resource schema does, and rejects an unknown metric
  before creating the group.
- The Java SDK compatibility suite gains a round-trip case that sets every
  new member, reads it back through DescribeAutoScalingGroups, then clears
  the maintenance policy and the enabled metrics.

* fix(autoscaling): route the metrics collection actions and close the review gaps

EnableMetricsCollection and DisableMetricsCollection now route to Auto
Scaling when a request carries no credential scope. Both hold the group
lock, so concurrent calls keep each other's changes and a call racing a
delete cannot write the group back.

A failed stack update now clears the service-linked role, AZ
distribution and capacity reservation when the group had none before.
A blank ServiceLinkedRoleARN or WeightedCapacity in a template reaches
the service's validation instead of reading as unset. The provisioner
reuses the service's granularity rule and message.
2026-10-12 16:26:44 -04:00
Andre Kurait 017901a030 test(autoscaling): preserve AWS subnet whitespace normalization (#5509)
Signed-off-by: Andre Kurait <akurait@amazon.com>
2026-10-12 15:03:54 -04:00
lex00 cebb011a00 fix(autoscaling): round-trip the dropped Auto Scaling group fields (#3494)
* fix(autoscaling): round-trip the dropped Auto Scaling group fields

CreateAutoScalingGroup and UpdateAutoScalingGroup accepted DesiredCapacityType,
CapacityRebalance, MaxInstanceLifetime and DefaultInstanceWarmup and threw them
away, so DescribeAutoScalingGroups never read them back. A mixed instances policy
launch template override that selected instance types by InstanceRequirements
instead of by name was dropped the same way, and because the override parser used
InstanceType's presence as its only "is there another override" signal, such an
override also truncated the whole Overrides list.

The four scalar members now travel into AutoScalingService as one AsgOptionalFields
record and are stored on AutoScalingGroup as boxed, uninitialised fields, so a group
that never set one omits it from the Describe response rather than reporting a
default. Update keeps its partial-update semantics: an absent member leaves the
stored value alone. DefaultInstanceWarmup honours the documented -1 removal
sentinel, MaxInstanceLifetime must be 0 or at least 86400, and DesiredCapacityType
is checked against units, vcpu and memory-mib.

LaunchTemplateOverrides.InstanceRequirements parses and echoes every member of the
botocore shape except BaselinePerformanceFactors, and an override that sets both
InstanceType and InstanceRequirements raises ValidationError as AWS does.

Verified against botocore autoscaling/2011-01-01/service-2.json from awscli 2.35.24.

* fix(autoscaling): enforce the attribute-based instance selection rules

Two rules that botocore states but does not encode as constraints were missing.

DesiredCapacityType is typed XmlStringMaxLen255 with no enum, and
CreateAutoScalingGroupType.members.DesiredCapacityType.documentation carries the
rule: "Amazon EC2 Auto Scaling supports DesiredCapacityType for attribute-based
instance type selection only." Floci accepted vcpu and memory-mib for a group
whose launch template names a fixed instance type. Both values now raise
ValidationError unless the mixed instances policy left in effect by the request
carries a launch template override with a non-empty InstanceRequirements. units
is the documented default and stays legal everywhere, and an absent member is
not validated.

The effective policy is the one the request supplies on create. On update it is
the policy the request supplies, the stored policy when the request names no
launch source, or none when the request switches the group to a launch
configuration or a plain launch template. The effective DesiredCapacityType is
likewise the request value or, when absent, the stored one, so an update cannot
strip attribute-based selection out from under a stored vcpu.

shapes.InstanceRequirements.required is ["VCpuCount", "MemoryMiB"] and the shape
documentation repeats it as "You must specify VCpuCount and MemoryMiB". An
override carrying InstanceRequirements without both ranges was stored and
returned 200; it now raises ValidationError. Both rules run on create and on
update.

createGroupCarryingEveryOptionalField is @Order(1) and seeds the group the later
ordered tests reuse, so its setup moved from a launch template naming t3.micro
to a mixed instances policy whose override sets VCpuCount and MemoryMiB. That
makes its DesiredCapacityType=vcpu legal without relaxing any assertion, and the
ordered updates that follow still see attribute-based selection in effect.
2026-09-12 18:37:36 -05:00
lex00 4cc850e8df fix(autoscaling): round-trip launch configuration InstanceMonitoring and BlockDeviceMappings (#3174)
CreateLaunchConfiguration stores InstanceMonitoring.Enabled and
BlockDeviceMappings, and DescribeLaunchConfigurations returns both
structures the way AWS does, with monitoring defaulting to enabled and
mappings to an empty list. The Terraform provider read the missing
elements as disabled monitoring and no root device, which forced a
replacement on every plan.

Ported from lex00/floci#132.
2026-09-07 11:25:40 -04:00
lex00 09801146b1 feat(autoscaling): warm pools, scheduled actions, traffic sources, and process suspension (#2973)
* feat(autoscaling): warm pools, scheduled actions, traffic sources, and process suspension

PutWarmPool/DescribeWarmPool/DeleteWarmPool, PutScheduledUpdateGroupAction/
DescribeScheduledActions/DeleteScheduledAction, AttachTrafficSources/
DetachTrafficSources/DescribeTrafficSources, and SuspendProcesses/
ResumeProcesses, parsed against botocore's autoscaling/2011-01-01 wire model.
Deleting a group also removes its scheduled actions and warm pool.

* fix(autoscaling): scope scheduled-action cleanup to the group's region

Deleting a group removed scheduled actions with the same group name in every region. PutScheduledUpdateGroupAction now rejects a malformed StartTime or EndTime with ValidationError instead of treating it as absent.
2026-09-04 09:30:25 -04:00
Jason van Zyl 9236b40073 feat(autoscaling): preserve policy and mixed instances parity (#1437)
* fix(autoscaling): preserve launch template capacity metadata

* feat(autoscaling): preserve target tracking policies

* feat(autoscaling): preserve mixed instances policies
2026-06-18 23:42:31 -05:00
Hector Ventura 9e35046647 Docs/enviroment instead yml (#764)
* docs: moving all config to env instead of yml
* docs: sync with main and new features
* docs: reverting docker-compose.yml
2026-05-10 11:53:31 -05:00
Hector Ventura b5dde6dae8 feat(autoscaling): EC2 Auto Scaling stored-state API + capacity reconciler (#681)
* feat(autoscaling): implement EC2 Auto Scaling Phase 1+2
* docs: updating documentation
2026-05-02 07:53:45 -05:00