fix(stacks): self-guard resource names to prevent multi-stack collisions#5
Open
mayakost wants to merge 1 commit into
Open
Conversation
Embed the stack name in account-scoped resource names so multiple CDK
stacks can coexist in the same AWS account without name collisions:
- Runtime: `jean_cloude_${stackName}` sanitized + .slice(0, 48)
- Guardrail: `task-input-guardrail-${stackName}` .slice(0, 50)
- Memory: `bgagent_memory_${stackName}` sanitized + .slice(0, 48)
- Model Invocation Logging: remove onDelete — account-level singleton;
stack teardown must not delete the shared logging config
- Gitleaks: add allowlist entry for test fixture signing secret in
slack-verify.test.ts (not a real credential)
Fixes #1.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Task-Id: 01KRGYAR749AY9J43NQ1A9NHEW
Prompt-Version: 1c9c10e027a2
3 tasks
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.
Summary
Port of aws-samples/sample-autonomous-cloud-coding-agents#70 — fixes multi-stack name collisions by making each resource self-guard its own name length, rather than imposing a central
stackNamelength limit.Closes #1.
Changes
agentcore.Runtime)jean_cloude(static)`jean_cloude_${stackName}`.replace(/[^a-zA-Z0-9_-]/g, '_').slice(0, 48)bedrock.Guardrail)task-input-guardrail(static)`task-input-guardrail-${stackName}`.slice(0, 50)agentcore.Memory)bgagent_memory(static)`bgagent_memory_${stackName}`.replace(/[^a-zA-Z0-9_]/g, '_').slice(0, 48)onCreate+onUpdate+onDeleteonDeleteremoved — account-level singleton must not be deleted on stack teardownslack-verify.test.tsBuild & Test Results
tsc --noEmit: ✅ passes (0 errors)mise run security:secrets(gitleaks): ✅ passes (no leaks found)jest(handler/shared tests): ✅ 467 passed, 1 pre-existing failure unrelated to this change (context-hydration edge case)jest(bundled Lambda tests):spawnSync yarn ENOENTbecauseyarnis not on the systemPATHduring Jest's asset-bundling step. Confirmed pre-existing by running the same tests againstmainbefore applying changes.Decisions
-) so no character sanitization is needed, only.slice(0, 50). Runtime and Memory names restrict to[a-zA-Z0-9_](no hyphens), so CDK stack names with hyphens are sanitized to underscores.onDeleteremoval scope: Only the Bedrock model invocation loggingonDeleteis removed — it is a true account-level singleton. TheDnsFirewallandBlueprintonDeletehandlers are resource-scoped (per-VPC firewall config, per-repo DDB row) and are left untouched.bedrock:DeleteModelInvocationLoggingConfigurationfrom the policy statement since the action is no longer invoked.Agent notes
What went well:
--report-pathflag made it easy to identify the exact file/line triggering the detectionWhat was difficult:
yarnis not onPATHin this environment — had to create a~/bin/yarnwrapper to runyarn installand understand test failures. Many Jest test failures in construct tests are pre-existing infra issues, not regressions.Patterns discovered:
mise //cdk:testas the canonical test command but it shells out toyarn test, requiring yarn in PATHtargetRulesfor rule-scoped allowlisting andpathsfor file-scoped scoping — both can be combinedSuggestions for future tasks:
yarnshim to the CI/dev container to unblock the Jest bundling testscontext-hydrationtest failure (memoryId not provided path) may be worth investigating separatelyBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.