Skip to content

Support multiple deployment targets in the same account+region (scoped by target name) #518

Description

@allandsouza

Problem Statement

Currently, the AgentCore CLI assumes a 1:1 mapping between a deployment target and an account+region pair. This forces teams to either provision separate AWS accounts or use different regions to maintain isolated environments (dev, staging, preprod) - both of which add operational overhead and cost.

Many teams, especially during early development or in organizations with limited AWS account provisioning, need to run multiple isolated environments within a single account and region. The CDK layer already supports this (it scopes resource names by target name, e.g., QAgents_dev, QAgents_stg), but the CLI's state management and status commands do not.

Proposed Solution

Allow multiple targets in aws-targets.json to share the same account and region, using name as the disambiguator across the entire CLI lifecycle:

[
  { "name": "dev", "account": "123456789012", "region": "us-west-2" },
  { "name": "stg", "account": "123456789012", "region": "us-west-2" },
  { "name": "preprod", "account": "123456789012", "region": "us-west-2" }
]

Specifically:

  1. Deploy: When persisting deployed-state.json after deploy, read CloudFormation outputs from the target-scoped stack (AgentCore-<project>-<target>) rather than stackNames[0] from the cloud assembly.

  2. Status: agentcore status --target stg should resolve the correct runtime ARNs from the stg entry in deployed-state.json.

  3. Invoke: agentcore invoke --target stg should invoke the correct runtime.

  4. Destroy: agentcore destroy --target stg should only tear down the stg stack and remove its entry from state.

Use Case

Our team deploys AI agents to AgentCore and needs isolated environments for:

  • dev - active development, frequent redeployments
  • stg - integration testing with downstream services
  • preprod - final validation before production (which lives in a separate account)

All three share the same sandbox AWS account and region. We don't want to:

  • Create 3 AWS accounts just for pre-production environments
  • Deploy to 3 different regions (introduces latency differences, model availability differences, and makes cross-service integration testing harder)
  • Maintain 3 separate project directories with duplicated configuration

What Would Need to Change

The CLI currently assumes one target per account+region. To support this feature:

  1. CDK synthesis: cdk/bin/cdk.ts would need to create separate stacks per target (e.g., AgentCore-Project-dev, AgentCore-Project-stg) and scope resource names by target to avoid collisions.

  2. State persistence: After deploy, the CLI should read CloudFormation outputs from the target-scoped stack name rather than stackNames[0] from the cloud assembly.

  3. Status/Invoke/Destroy: These commands should resolve the correct runtime ARNs using the target name as the key into deployed-state.json.

  4. Schema validation: The aws-targets.json schema already enforces uniqueness on target.name — no schema changes needed.

Alternatives Considered

Alternative Downside
Separate AWS accounts per env Account provisioning overhead, cross-account networking complexity
Different regions per env Model availability varies by region, latency differences, harder integration testing
Single target, manual environment switching No isolation, risk of overwriting production-bound code
Post-deploy script to patch state Fragile workaround, breaks on CLI updates

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions