Support pre-built container image URI in agentcore deploy (skip CodeBuild)
- Dominant language
- TypeScript
- Stars
- 283
- Forks
- 95
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 183
Description
### Description
Currently, the Container build type always builds images via AWS CodeBuild during agentcore deploy. This doesn't support workflows where users cross-compile for a different architecture, use custom CI/CD pipelines that push images to ECR before deploying, or want to avoid redundant builds when the image already exists in ECR.
Add a `--container-uri ` flag to agentcore deploy that accepts a pre-built ECR image URI and wires it directly to AgentCoreRuntime, bypassing the CodeBuild step entirely.
Example usage:
`agentcore deploy -y --container-uri 123456789012.dkr.ecr.us-west-2.amazonaws.com/myproject/myagent:abc123`
The container URI is passed to the CDK app via an environment variable (AGENTCORE_CONTAINER_URI) so the CDK toolkit wrapper doesn't need modification. When set, the CDK stack creates an AgentCoreRuntime construct directly with the pre-built image instead of going through the AgentCoreApplication (CodeBuild) path.
### Acceptance Criteria
- [ ] `agentcore deploy --container-uri ` deploys using the provided ECR image without triggering a CodeBuild build
- [ ] Invalid ECR URI formats are rejected with a clear error message before deployment starts
- [ ] Dockerfile validation is skipped when `--container-uri` is provided
- [ ] The flag triggers non-interactive (CLI) mode
- [ ] `DeployOptions` and `ValidatedDeployOptions` interfaces include the optional `containerUri` field
- [ ] The CDK stack branches correctly: `containerUri` set → `AgentCoreRuntime` with pre-built image; unset → existing `AgentCoreApplication` (CodeBuild) path
- [ ] `CfnOutput` for `RuntimeId` and `RuntimeArn` is emitted in the pre-built image path
- [ ] Unit tests cover: URI validation (valid/invalid formats), Dockerfile validation skip, env var propagation, CDK stack branching logic
- [ ] Existing Container build type (no `--container-uri`) continues to work unchanged
### Additional Context
This currently assumes a single agent (spec.agents[0]). We likely would want to address multi-agent/multi-URI mappings somehow.
The ECR repo must already exist with the referenced tag.
Contributor guide
Assessment
This issue has not been assessed yet.