fix(gateway): default inbound auth to iam — authorizer is immutable after creation - #779
Merged
Merged
Conversation
PlatformStack failed deploying #778 to dev: Authorizer type cannot be updated for an existing gateway (Service: BedrockAgentCoreControl, Status Code: 400) AgentCore will not change a Gateway's authorizerType after creation. The stack rolled back cleanly and the Gateway kept AWS_IAM, READY, and both targets — but the migration as designed cannot work in place. Neither pre-deploy check caught this. The CloudFormation resource reference documents AuthorizerType as "Update requires: No interruption", and `cdk diff` via a real change set reported an in-place [~] modify. Both describe CFN's plan, not the AgentCore service's validation. A change set is not a deploy test. Two failures to fix, not one: 1. The backend half shipped while the infra half rolled back, so the runtime had no AGENTCORE_GATEWAY_INBOUND_AUTH — and the agent's default was 'jwt'. That pointed the new agent at bearer auth against an AWS_IAM Gateway, 401ing every Gateway tool call. Both defaults are now 'iam': an absent value means "behave like the Gateway that is actually deployed", which is the only safe direction when the two halves can land independently. 2. CDK_GATEWAY_INBOUND_AUTH existed only in config.ts — step 1 of the repo's 7-step config pattern. The documented escape hatch was unreachable from CI. Now exported and validated in load-env.sh, passed as context (synth.sh and deploy.sh already use build_cdk_context_params), and carried in platform.yml's job env. backend.yml runs no CDK, so it needs nothing. Also corrects every place that asserted the opposite: the GatewayConfig doc, the construct's inline comment and class doc, the plan's Phase 0/1A, and the public environments.md page (now a :::danger: covering the real error and why the pre-deploy signals mislead). The single-Gateway endstate still holds. What changes is the mechanism: reaching CUSTOM_JWT needs a new Gateway plus target re-registration and a cutover, not a config flip. Targets are managed out-of-band by app-api's GatewayTargetService and the mcp-servers repo, so that needs its own design — tracked in the plan. Verified: synth against dev now emits AuthorizerType AWS_IAM matching the live Gateway, and `cdk diff` shows no authorizer change, so the deploy proceeds. tsc clean; infra 481 jest; 58 backend gateway + supply-chain tests.
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.
Hotfix for #778. The Gateway authorizer migration cannot work in place, and the partial deploy left dev in a broken state.
What happened
PlatformStackfailed deploying #778 to dev:The stack rolled back cleanly. The Gateway kept
AWS_IAM,READY, and both registered targets (arxiv,policy-search) — no infrastructure damage.Why the pre-deploy checks missed it
Two signals said the change was safe. Both describe CloudFormation's plan, not the AgentCore service's validation:
AuthorizerType→ "Update requires: No interruption"cdk diff(real change set)[~]modify-in-place, no replacementThe general lesson for AgentCore resources: a change set is not a deploy test.
Two problems fixed, not one
1. Dev was about to break (the urgent one). The backend half of #778 deployed successfully while the infra half rolled back. That left the runtime with no
AGENTCORE_GATEWAY_INBOUND_AUTH— and the agent's default wasjwt. So the new agent sent bearer tokens to anAWS_IAMGateway and 401'd every Gateway tool call. It didn't even degrade gracefully:GatewayAuthErroronly fires when there's no token, and here there was one.Both defaults are now
iam. An absent value means "behave like the Gateway that is actually deployed" — the only safe direction when the two halves can land independently. The agent is correct now even if the env var never lands.2. The escape hatch didn't exist.
CDK_GATEWAY_INBOUND_AUTHwas only inconfig.ts— step 1 of the repo's 7-step config pattern. The documented rollback knob was unreachable from CI, which mattered once it became load-bearing. Now:iam|jwt) inload-env.shsynth.sh/deploy.shalready usebuild_cdk_context_params)platform.yml's job-level envbackend.ymlruns no CDK, so it needs nothingCorrections to the record
Every place that asserted the opposite is fixed: the
GatewayConfigdoc, the construct's inline comment and class doc, the plan's Phase 0 and 1A, open decision #1, and the publicenvironments.mdpage — now a:::dangerbox carrying the real error text and an explanation of why the pre-deploy signals mislead.What this means for the migration
The single-Gateway endstate still holds. What changes is the mechanism:
inboundAutheffectively sets the authorizer at Gateway creation. ReachingCUSTOM_JWTon an existing deployment requires:CUSTOM_JWT(the existing one keeps serving)/{prefix}/gateway/idStep 2 is the hard part — targets are managed out-of-band by app-api's
GatewayTargetServiceand by themcp-serversrepo, so it isn't CDK-only. That needs its own design; it's recorded in the plan rather than attempted here.The plan's original "option B" (second Gateway) turns out not to be a preference but the only available mechanism.
Verification
AuthorizerType: AWS_IAM, matching the live Gatewaycdk diffshows no authorizer change on the Gateway resource — the deploy will proceediamtscclean; 481 infra jest; 58 backend gateway + supply-chain tests (the latter guardload-env.sh)After merge
platform.ymlshould deploy green, andbackend.ymlre-ships the agent withiam. Then confirm a Gateway tool (arxivorpolicy-search) works in dev — that verifies SigV4 is restored end to end.