Repository navigation
feat(account): emulate the Account Management Region opt-in API (#629) - #633
Merged
Merged
Conversation
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 Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #629.
Substrate had no
accountservice namespace, soListRegions,GetRegionOptStatus,EnableRegionandDisableRegionall 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
ListRegionsreports all 34 Regions — 17ENABLED_BY_DEFAULTand 17DISABLEDuntil enabled — with
RegionOptStatusContainsfiltering andMaxResults/NextTokenpaging (bounds 1–50, from the model's own shape).AccountIdtargets a member account of the caller's organization, resolvedthrough 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 firstGetRegionOptStatusreportsENABLING,the next reports
ENABLED, and it never moves again;ListRegionsresolvesidentically, 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:
CreateAccount.CreateAccounthands back anIN_PROGRESSstatus in its ownresponse, so a consumer sees the in-flight state without polling.
EnableRegionhas no output shape at all, so a poll is the only placeENABLINGis ever observable — resolving sooner would leave a consumer'sin-flight branch, the branch that exists because AWS takes "a few minutes to
several hours" here, unexecutable in a test.
EnableRegionreads throughpeekRegionStatus, which advances nothing. A redundant enable of anENABLEDor
ENABLINGRegion succeeds silently and rewrites nothing, which is whatmakes an "ensure these Regions are on" routine safe to re-run; writing
ENABLINGoverENABLEDwould make the Region go backwards for a waiter thathad already finished.
A correction to the issue
Disabling a default Region is
ValidationExceptionwith reasoninvalidRegionOptTarget, not theConstraintViolationExceptionthe issuenames — the
account/2021-02-01model declares no such error for anyoperation, 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}plusx-amzn-errortypeand has noreasonmember. The message alsodistinguishes 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 anobservation 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 timeoutbranch and the
ConflictException(409) an opposite opt gets mid-flight. A seednaming 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
TooManyRequestsExceptionboundary refuses requestsAWS 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.
ec2SeededRegionsstays a separate, smaller list: it answers which Regions EC2reports, 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
RegionOptStatusenum but noRegion list. Every status, error code, HTTP status, required member and numeric
bound is from
account/2021-02-01/service-2.json.Verification
gofmt,go build,go vet,golangci-lint run ./...— 0 issuesmake test(race detector) green; coverage 82.2%make docs-reference-check docs-versions,npm --prefix docs run buildgreengo vet -C test/e2e ./...andgo test -C test/e2e ./...greensubstrate server --address :4678withAWS_MAX_ATTEMPTS=1: every line of the issue's repro matches, including the409 wire shape (
x-amzn-errortype: ConflictException)aws-sdk-go-v2/service/accountclient(added to
test/e2e/go.mod). This is the level that catches an unroutedservice: the account API sends no
X-Amz-Targetand carries its operationentirely in the URL, and SSO Admin is unreachable: parser.go maps a guessed X-Amz-Target prefix, not the real SWBExternalService #561/organizations: every SDK call answers "service not emulated" — the X-Amz-Target prefix has no alias #610 were both a plugin that was registered,
fully unit-tested, and unreachable from every SDK.
errors.Ason*types.ValidationExceptionand*types.ConflictExceptionis what asserts thecode reached the client where the REST-JSON parser looks for it.
dropped from the opt path;
GetRegionOptStatusnever resolving; it resolvingtoo early;
EnableRegionmade non-idempotent; theoperationResolversentryremoved (the Fault injection: S3 rules can't name an operation, can't be bounded to N fires, and drop ErrorCode on the wire #480/authz/parser: 17 REST services reach the pipeline named after their HTTP method, so a correct policy is denied #572 defect — the plugin still works while the pipeline
authorizes, meters and records every call as
POST).