Skip to content

feat: add gateway import command with executionRoleArn support#855

Open
jesseturner21 wants to merge 7 commits intoaws:mainfrom
jesseturner21:feat/import-gateway
Open

feat: add gateway import command with executionRoleArn support#855
jesseturner21 wants to merge 7 commits intoaws:mainfrom
jesseturner21:feat/import-gateway

Conversation

@jesseturner21
Copy link
Copy Markdown
Contributor

Summary

  • Add agentcore import gateway --arn <gatewayArn> command that imports an existing AWS gateway with its targets into a local agentcore project
  • Preserve the gateway's original IAM execution role via executionRoleArn, matching the pattern used by runtime and memory imports
  • On deploy, CDK uses iam.Role.fromRoleArn() instead of creating a new role, keeping original permissions intact
  • Unhide the import command from the TUI and add gateway ARN support to the ARN input component

Changes

Gateway Import Command

  • src/cli/commands/import/import-gateway.ts — new import command that fetches gateway details + targets from AWS, maps them to the local schema, writes agentcore.json and deployed-state.json, then runs CDK synth for CloudFormation import
  • src/cli/aws/agentcore-control.ts — extract roleArn from GetGateway API response

executionRoleArn Support

  • src/schema/schemas/mcp.ts — add optional executionRoleArn field to gateway schema
  • src/cli/commands/import/import-gateway.ts — map AWS roleArnexecutionRoleArn during import

CDK Constructs (separate PR in agentcore-l3-cdk-constructs)

  • Gateway.ts — use fromRoleArn when executionRoleArn is set, add addToPolicy guard method
  • AgentCoreMcp.ts — use gateway.addToPolicy() for policy engine grants
  • mcp.ts — add executionRoleArn to CDK schema

E2E Tests

  • e2e-tests/import-resources.test.ts — gateway import test, field verification (including executionRoleArn), deployed-state verification
  • e2e-tests/fixtures/import/setup_gateway.py — creates gateway + MCP server target for testing
  • e2e-tests/fixtures/import/common.py — gateway wait helpers

Test plan

  • 3301 unit tests pass
  • 152 CDK construct tests pass
  • E2e: create real AWS gateway, import it, verify executionRoleArn matches original role ARN
  • Verify agentcore.json contains all gateway fields (name, resourceName, description, authorizerType, enableSemanticSearch, exceptionLevel, executionRoleArn, tags, targets)
  • Verify deployed-state.json has gateway entry with gatewayId
  • Run full e2e suite with CDK tarball: CDK_TARBALL=<path> npm run test:e2e

Add `agentcore import gateway --arn <arn>` to import existing AWS gateways
(with all targets) into a local CLI project. Also remove import from the
HIDDEN_FROM_TUI list so it appears in the interactive TUI.

- Add AWS SDK wrappers for gateway/target list/get APIs
- Add import-gateway.ts with multi-resource CFN import support
- Add resourceName schema field to preserve actual AWS gateway name during import
- Register gateway in TUI ImportSelectScreen and ImportProgressScreen
- Extend ARN pattern, deployed state, and CFN constants for gateway type
The ARN text input was truncating long ARNs. Use the expandable prop to
wrap text across multiple lines. Also add gateway to the ARN validation
pattern and resource type labels.
Remove --name (confusing local rename) and --yes (no prompts to confirm)
from the gateway import command. The gateway's AWS name is used directly.
Add end-to-end tests that create a real AWS gateway with an MCP server
target, import it via `agentcore import gateway --arn`, and verify the
resulting agentcore.json fields and deployed-state.json entries.

New files:
- e2e-tests/fixtures/import/setup_gateway.py: creates gateway + target
- e2e-tests/fixtures/import/common.py: gateway wait helpers
- e2e-tests/fixtures/import/cleanup_resources.py: gateway cleanup

Constraint: Tests follow the existing import-resources.test.ts pattern
Confidence: high
Scope-risk: narrow
Extract roleArn from the AWS GetGateway response and map it to
executionRoleArn in agentcore.json. On deploy, CDK uses
iam.Role.fromRoleArn() instead of creating a new role, keeping the
original permissions intact.

Constraint: imported roles use mutable: false so CDK cannot modify them
Rejected: always create new role | breaks permissions on re-import
Confidence: high
Scope-risk: narrow
@jesseturner21 jesseturner21 requested a review from a team April 15, 2026 14:05
@github-actions github-actions bot added the size/xl PR size: XL label Apr 15, 2026
@github-actions github-actions bot added size/xl PR size: XL and removed size/xl PR size: XL labels Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.8.1.tgz

How to install

npm install https://github.com/aws/agentcore-cli/releases/download/pr-855-tarball/aws-agentcore-0.8.1.tgz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xl PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant