Remove inline container build from vended cdk-stack.ts#954
Open
Remove inline container build from vended cdk-stack.ts#954
Conversation
Container image building is now handled by AgentCoreHarnessEnvironment inside the L3 CDK construct via CodeBuild, matching the runtime pattern. The vended stack no longer needs DockerImageAsset, the toPascalId helper, or the per-harness build loop. Update snapshot to match.
The new AgentCoreHarnessEnvironment construct nests AgentCoreHarnessRole under a 'Role' child, which changes the CDK output key from ApplicationHarness<Name>RoleArnOutput to ApplicationHarness<Name>Role RoleArnOutput. Similarly, the container URI output moves from a stack- level Harness<Name>ContainerUri key to ApplicationHarness<Name>ImageUri. Update both resolvers to try the new pattern first, falling back to the old pattern for backward compatibility with existing stacks that haven't upgraded their CDK constructs.
The preview branch renamed dockerfile→dockerfileName and codeLocation→harnessDir, but the CDK construct's HarnessRoleConfig still uses dockerfile and codeLocation. Without matching field names, AgentCoreHarnessEnvironment never sees the dockerfile and skips the CodeBuild container build entirely.
notgitika
reviewed
Apr 24, 2026
Contributor
notgitika
left a comment
There was a problem hiding this comment.
Looks good overall — two suggestions below.
| * New (AgentCoreHarnessEnvironment wrapping AgentCoreHarnessRole): | ||
| * ApplicationHarness{PascalName}RoleRoleArnOutput... | ||
| */ | ||
| function resolveRoleArn(harnessName: string, cdkOutputs?: Record<string, string>): string | undefined { |
Contributor
There was a problem hiding this comment.
Ordering matters here: RoleRoleArn must come before RoleArn since the shorter prefix is a substring of the longer one. If someone reorders this array, the old prefix will match first and return the wrong value. Worth a short comment noting the ordering is intentional.
| roleArn: 'arn:aws:iam::123456789012:role/HarnessRole', | ||
| }) | ||
| ); | ||
| expect(mockedCreateHarness).toHaveBeenCalledWith(createOptions); |
Contributor
There was a problem hiding this comment.
nit: Consider adding a test case where both old and new output keys are present in cdkOutputs (e.g. both ...RoleRoleArn... and ...RoleArn... keys). This would document the precedence contract and guard against regressions if the prefix array order changes. Same applies to the harness-mapper.test.ts counterpart.
notgitika
approved these changes
Apr 24, 2026
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
ContainerSourceAssetFromPath/AgentEcrRepository/ContainerBuildProject/ContainerImageBuilderimports, and theharnessesForCdkarray from the vendedcdk-stack.tsAgentCoreApplication, which delegates toAgentCoreHarnessEnvironmentinternallyWhy
Depends on aws/agentcore-l3-cdk-constructs#175, which encapsulates harness container building inside the L3 construct. With that change, the vended stack no longer needs to orchestrate CodeBuild directly. This keeps the vended CDK assets thin and means future build pipeline improvements are picked up automatically on
@aws/agentcore-cdkupgrade.Test plan
DkrFinalTestproject (CodeBuild triggers correctly; build failure was Docker Hub rate limit, not a code issue)