Skip to content

feat(account): emulate the Account Management Region opt-in API (#629) - #633

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/account-region-optin
Aug 14, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/account-region-optin

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #629.

Substrate had no account service namespace, so ListRegions,
GetRegionOptStatus, EnableRegion and DisableRegion all fell through to
"service not emulated". A consumer that baselines an account's usable Regions
before it deploys anything therefore could not be tested against substrate —
which is how this was found: by driving a shipped consumer against
substrate server, not by reading the API model.

What's here

ListRegions reports all 34 Regions — 17 ENABLED_BY_DEFAULT and 17 DISABLED
until enabled — with RegionOptStatusContains filtering and
MaxResults/NextToken paging (bounds 1–50, from the model's own shape).
AccountId targets a member account of the caller's organization, resolved
through the same member→management index #623 added rather than a second copy
of it: two answers to "who manages this account" is one too many.

An opt is asynchronous and resolves on observation, following
resolveCreateAccountStatus. The first GetRegionOptStatus reports ENABLING,
the next reports ENABLED, and it never moves again; ListRegions resolves
identically, so a caller polling the listing and one polling a single Region
cannot contradict each other.

Two deliberate departures, both with the reasoning in the code:

  • The first observation reports the in-flight status, unlike
    CreateAccount. CreateAccount hands back an IN_PROGRESS status in its own
    response, so a consumer sees the in-flight state without polling.
    EnableRegion has no output shape at all, so a poll is the only place
    ENABLING is ever observable — resolving sooner would leave a consumer's
    in-flight branch, the branch that exists because AWS takes "a few minutes to
    several hours" here, unexecutable in a test.
  • An opt is not an observation. EnableRegion reads through
    peekRegionStatus, which advances nothing. A redundant enable of an ENABLED
    or ENABLING Region succeeds silently and rewrites nothing, which is what
    makes an "ensure these Regions are on" routine safe to re-run; writing
    ENABLING over ENABLED would make the Region go backwards for a waiter that
    had already finished.

A correction to the issue

Disabling a default Region is ValidationException with reason
invalidRegionOptTarget
, not the ConstraintViolationException the issue
names — the account/2021-02-01 model declares no such error for any
operation, so a consumer catching one could never match. The reason rides at the
front of the message, because the REST-JSON error document is {message, Message, Code} plus x-amzn-errortype and has no reason member. The message also
distinguishes a default Region from an unknown one: the code and the reason are
identical for both cases, so the message is the only thing that tells them apart
— a mutation deleting the default-Region check proved this, surviving until the
test asserted on the message.

Seeding

POST/DELETE /v1/account/region-opt-status (Region code or "*") pins what an
observation reports. It is the only route to a status a sequence of API calls
cannot produce — a Region held in ENABLING, and with it a waiter's timeout
branch and the ConflictException (409) an opposite opt gets mid-flight. A seed
naming a default Region is refused rather than ignored: that status is fixed
before a seed is consulted, so an accepted seed would leave the test asserting
nothing.

Not modelled

Two published limits, and the docs say why: 6 in-progress requests per account,
and a per-organization limit the same guide gives as 50 in one section and
20 in another. A guessed TooManyRequestsException boundary refuses requests
AWS accepts, and there is no way to choose between two published numbers without
making one wrong. The other eleven operations in the model — alternate contacts,
the primary contact, the account name, the primary email — are out of scope;
#629 asked for the four Region operations.

ec2SeededRegions stays a separate, smaller list: it answers which Regions EC2
reports, not which ones an account has opted into, and unifying them would make
every EC2 fixture's Region list depend on this table.

Provenance

Both Region tables come from the Account Management Reference
Guide

rather than from the API model, which publishes the RegionOptStatus enum but no
Region list. Every status, error code, HTTP status, required member and numeric
bound is from account/2021-02-01/service-2.json.

Verification

There was no `account` service namespace, so ListRegions, GetRegionOptStatus,
EnableRegion and DisableRegion all fell through to "service not emulated" and a
consumer that baselines an account's usable Regions before deploying anything
could not be tested against substrate at all.

ListRegions reports all 34 Regions -- 17 ENABLED_BY_DEFAULT and 17 DISABLED
until enabled -- with RegionOptStatusContains filtering and MaxResults/NextToken
paging. AccountId targets a member account of the caller's organization through
the same member->management index #623 added, rather than a second copy of it.

An opt is asynchronous and resolves on observation, following
resolveCreateAccountStatus: the first GetRegionOptStatus reports ENABLING, the
next ENABLED, and it never moves again. Reporting the in-flight status on the
first observation differs from CreateAccount deliberately -- EnableRegion has no
output shape, so a poll is the only place ENABLING is ever visible. An opt is
not an observation: a redundant EnableRegion neither advances nor rewrites the
record, which is what makes an "ensure" pass safe to re-run.

Disabling a default Region is ValidationException/invalidRegionOptTarget, not
the ConstraintViolationException the issue named -- the account/2021-02-01 model
declares no such error for any operation.

A control-plane seed pins what an observation reports, which is the only route
to a Region held in ENABLING and so to the ConflictException an opposite opt
gets mid-flight.
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.78142% with 74 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/account_plugin.go 83.39% 24 Missing and 24 partials ⚠️
emulator/account_control.go 62.50% 15 Missing and 9 partials ⚠️
emulator/plugins.go 75.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 9184adf into main Aug 14, 2026
16 checks passed
@scttfrdmn
scttfrdmn deleted the feat/account-region-optin branch August 14, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Account Management API: no plugin exists, so opt-in region enablement is unreachable

1 participant