Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 7bcb024 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
xyos
force-pushed
the
feat/deploy-denial-guidance
branch
2 times, most recently
from
November 11, 2026 15:59
e0eef08 to
5ff3132
Compare
When AWS denied a request of the deployment itself, for example a CloudFormation resource that an AWS Organizations policy denies, the deploy commands printed nothing beyond the CDK output: the credential check before the deploy passes in that case. A production deploy then waited for the rollback, minutes after the first failure, and a sandbox printed its Express Mode note recommending sandbox:destroy, which deletes an existing sandbox's data, for a failure that a redeploy cannot get past. The deploy commands now read the CDK CLI's failure output while it runs: the reason column of CloudFormation events whose status ends in _FAILED, and the CDK CLI's error block, read by paragraph because it hard-wraps the reason mid-phrase (the stack name in its banner, resource headings and source locations are left out). App log lines that cdk watch prints are skipped before anything else. An explicit deny by a service or resource control policy is explained as soon as its line arrives; any other denial once the deploy is known to fail, so that it is not explained as missing IAM permissions just before an explicit deny of another resource. Each is explained at most once per deployment, including each deployment of the sandbox's watch mode. The notice adds no details from the error, and output, errors and exit codes are unchanged. The classifier now tolerates terminal colors, CRLF and line breaks inside a phrase, accepts the AuthorizationError (SNS) and UnauthorizedOperation (EC2) error names, and no longer treats the CDK CLI's note "(e.g. AccessDenied)" about cdk diagnose as a denial. Capture: the production deploy already streams both pipes. The initial sandbox deploy, which inherited all stdio synchronously at the default log level, now keeps stdin and stdout there (where the CDK CLI decides its terminal behavior) and pipes only stderr, where it writes progress and errors without --ci; each chunk is relayed unchanged as it arrives and read line by line on the side. Because that stderr is no longer a terminal, the sandbox deploy passes --progress events, as the production deploy does. With CI set, the CDK CLI prints its events to the inherited stdout, and the denial is explained from the error block on stderr when the deploy fails. At BLOCKS_LOG_LEVEL=quiet|normal (the blocks CLI's --quiet and default), where both streams are already piped and curated, each line of the deploy and of cdk watch is read once the curated relay has handled it. The notices and guidance are not log lines, so no level hides them, and they name the command that ran (for example `npx --no -- cdk-blocks sandbox`). After a denial, a failed sandbox deploy prints fixed recovery guidance instead of the Express Mode note: a first deploy's failed stack holds no data and sandbox:destroy removes it, while a sandbox that existed before must not be destroyed. Other failures keep the Express Mode note unchanged. Credentials that expire or are rejected while the sandbox deploys, which the pre-deploy check cannot catch, are now explained from the same failure output, never as a denial: the sign-in instructions of the bundled IAM Identity Center and aws login credential providers (which take precedence over an AccessDeniedException that they wrap, though not over an explicit Organizations deny, which signing in again cannot get past), the SDK error names ExpiredToken, ExpiredTokenException, TokenRefreshRequired, InvalidClientTokenId and UnrecognizedClientException where the output names an error, and STS's expired or invalid security token wording. RequestExpired alone is not read as expiry, since it also means a clock that is off. cdk watch does not print the error block of a failed deployment, so a failed asset upload (`<stack>: fail:`) also counts as failure output. Once per deployment, the sandbox prints the pre-deploy check's source-aware sign-in guidance for its deployment target; in watch mode its last line says to save a file for credentials that the CDK CLI loads again on expiry (IAM Identity Center, aws login, roles assumed with source_profile), or to restart for credentials that it keeps for the life of the process (access keys, credential_process).
xyos
force-pushed
the
feat/deploy-denial-guidance
branch
from
November 15, 2026 08:45
5ff3132 to
7bcb024
Compare
This branch has not been deployed
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.
Problem
When AWS denies a request of the deployment itself, for example a CloudFormation resource that an AWS Organizations policy (SCP or RCP) denies, the credential check before the deploy passes, and the deploy commands print nothing beyond the CDK output:
CREATE_FAILEDarrives early, but the command only fails after the rollback, minutes later.npm run sandbox:destroy. That deletes an existing sandbox and its data, for a failure a redeploy cannot get past.cdk watch) get no sign-in guidance at all.Issue #, if available:
Changes
Reading CDK's failure output.
_FAILED, the CDK error block (read by paragraph, because CDK hard-wraps it mid-phrase), and failed asset uploads (<stack>: fail:), sincecdk watchswallows the error block.cdk watch.denial-guidance.ts(from feat(core): explain denied credential checks and the aws login Region #839) now tolerates ANSI codes, CRLF and wrapped phrases; acceptsAuthorizationErrorandUnauthorizedOperation; and no longer treats CDK's(e.g. AccessDenied)note aboutcdk diagnoseas a denial.When it reports.
Credential expiry in
npm run sandbox. Expired or rejected credentials print the credential check's source-aware sign-in guidance, once per deployment. Order of precedence:aws loginprovider's own sign-in instruction;RequestExpiredalone is not read as expiry, because it also means clock skew. In watch mode the last line says to save a file for credentials the CDK reloads (IAM Identity Center,aws login, roles viasource_profile), or to restart for credentials it keeps for the life of the process (access keys,credential_process). No prompts, no automatic login.Sandbox recovery after a denial. Fixed two-case guidance replaces the Express Mode note: after a first deploy,
sandbox:destroyremoves the empty failed stack; a sandbox that existed before must not be destroyed. Other failures keep the Express Mode note byte for byte.Capture strategy.
cdk-output.ts). Undercdk-blocksatquietandnormal(the curated levels), each line is observed after the curated relay handles it. Atverboseanddebug, and when no level is set, stdin and stdout are inherited (stdout followsBLOCKS_LOG_STREAMas before) and only stderr is piped to the observer, relayed unchanged as it arrives. This runner uses the same cross-spawn helper and bounded drain as the existing curated runner.CIset, CDK prints events to stdout, so the denial is explained from the stderr error block when the deploy fails.Output channel and wording: the notice, credential guidance and recovery text are printed like errors, so no log level hides them, and they name the command that was run (for example
npx --no -- cdk-blocks sandbox deploy). Because curated levels print the full CDK output only after a failure, the notice says "The CDK output has the details" rather than "above".Visible change: the initial sandbox deploy passes
--progress events, likenpm run deploy, because its stderr is no longer a terminal. It prints one line per CloudFormation event instead of a progress bar.Docs:
packages/blocks/README.mdandcreate-blocks-app/resources/AGENTS.md. Changeset: core, blocks, create-blocks-app (patch). No public API change (check:apipasses).Not in this PR: credential-expiry guidance during a production deploy (the pre-deploy check already covers expiry at start), and naming a spend limit as the cause of a denial (there is no supported signal for that yet).
Validation
AccessDeniedorExpiredToken, and app log lines shaped like deploy events;aws login, environment-key and role-chain credential messages;mainc672712(no merge commit; import and placement conflicts with the deploy-history recorder from feat(admin-ui): add the Blocks Admin UI, a local dashboard for Blocks apps #843 indeploy.tsandsandbox.tsresolved by keeping both sides):npm install,npm run build,npm run lint(two existinguseAwaitThenablenursery warnings),npm run lint:depsandnpm run check:apipass.startSandboxwith a fake CDK atnormal,quietandverbose(withBLOCKS_LOG_STREAM=stderr). It reports one notice naming the CLI command before the verdict, plus the recovery text; it fails if the curated wiring is removed. The production monitor is also tested with curated streams atnormalandquiet.npm test(all workspaces, afternpm run build:force): 13203 passed, 0 failed, 10 skipped. An earlier run on the same commit failed one file,packages/blocks/dist/conditional-exports.test.js, because the local checkout still held ignored build leftovers of the removedbb-auth-basic,bb-auth-cognitoandbb-auth-oidcpackage directories; with those moved aside, the full rerun passed.npm run test:e2e:local: 522 passed, 6 skipped; 12/12; 2/2; 1/1; 14/14; 0 failed.CREATE_FAILED; in one production run that is about 2.5 minutes before CDK's own failure message. Recordeddev,destroyandsandbox:destroyoutput produced no notice.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.