Skip to content

feat(examples): add AWSCC AgentCore Terraform templates - #2347

Closed
jariy17 wants to merge 3 commits into
refactorfrom
feat/terraform-awscc-backend
Closed

jariy17 wants to merge 3 commits into
refactorfrom
feat/terraform-awscc-backend

Conversation

@jariy17

@jariy17 jariy17 commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a standalone Terraform HCL template in examples/terraform/awscc for an AgentCore Runtime and short-term Memory using typed hashicorp/awscc resources and Cloud Control APIs. Customers package the included Python sample and deploy it with ordinary terraform init, plan, and apply.

The template includes versioned encrypted S3 artifact storage, public-access blocking, an IAM runtime role with scoped artifact/logging/Memory permissions, configurable inputs, and Runtime/Memory outputs. No CLI implementation or dependency changes are included.

Files and usage

  • main.tf: AgentCore Runtime and Memory resources.
  • versions.tf, variables.tf, outputs.tf: providers, inputs, and outputs.
  • storage.tf, iam.tf: artifact storage and runtime permissions.
  • agent.py, build.py: dependency-free sample and ZIP packaging.
  • terraform.tfvars.example, README.md: configuration and deployment/invocation instructions.

AWSCC provisions normal AgentCore resources without creating a CloudFormation stack. IAM and S3 use the AWS provider in both alternatives. Runtime uses Python 3.12 CodeZip and public networking; Memory has no long-term strategies. Application-specific resources and model permissions can be added to the .tf files.

Validation

  • Terraform formatting and validation passed with the pinned providers.
  • Repository formatting and secret scanning passed.
  • Live AWS deployment passed: Runtime and Memory creation, Runtime invocation, description updates with unchanged resource IDs, and a final Terraform plan reporting no changes.
  • Destruction was not exercised. Verification resources and state are retained.

@github-actions github-actions Bot added the size/xl PR size: XL label Sep 20, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress labels Sep 20, 2026
@jariy17 jariy17 changed the title feat(project): preview AWSCC Terraform backend for AgentCore feat(project): add AWSCC Terraform backend preview Sep 20, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Sep 20, 2026

@agentcore-devx-automation agentcore-devx-automation Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AgentCore Harness Review

Verdict: Changes requested

Nice work overall — the compiler validates the unsupported project surface up front, the state binding refuses ownership changes, and the tests lean on real temp dirs rather than fs mocks. A couple of things worth addressing before merge:

1. AWS_SESSION_TOKEN: undefined will break long-term credentials

src/core/project/backends/terraform.tsenvironment():

return {
  ...env,
  AWS_ACCESS_KEY_ID: credentials.accessKeyId,
  AWS_SECRET_ACCESS_KEY: credentials.secretAccessKey,
  AWS_SESSION_TOKEN: credentials.sessionToken,
  ...
};

credentials.sessionToken is optional on AwsCredentialIdentity. When callers use long-term IAM user creds (or any provider that returns no session token), sessionToken is undefined. child_process.spawn stringifies undefined env values to the literal string "undefined", which the AWS providers inside Terraform will then treat as an invalid session token and reject with an auth error.

Also note AWS_SESSION_TOKEN isn't in the filter list for process.env, so if a stale token is present in the outer environment, the override to undefined is what determines the final value passed to Terraform.

Options:

  • Only set AWS_SESSION_TOKEN when defined, e.g. ...(credentials.sessionToken && { AWS_SESSION_TOKEN: credentials.sessionToken }), and add AWS_SESSION_TOKEN/AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY to the filtered keys so stale env vars can't leak through.
  • Or scrub any key starting with AWS_ from the passthrough and set exactly the ones you need.

Please also add a test covering the no-session-token path so this doesn't regress.

2. No telemetry for the new backend selection

Per src/cli/telemetry/README.md, new features should be instrumented. --backend terraform (and the wizard equivalent) is a new user-visible choice, but CreateAttrs in src/cli/telemetry/schemas/command-run.ts isn't extended and no attribute is recorded from the create handler. Add a backend / managed_by attribute to CreateAttrs and record it from the create path so we can see adoption and, more importantly, correlate failures to the Terraform preview.

Minor things worth a look (not blocking)

  • TerraformRunner.json() calls JSON.parse(stdout.join("\n")) unconditionally. If Terraform ever writes a non-JSON line to stdout before the JSON payload (some deprecation/warning notices land on stdout depending on version), this throws with a confusing SyntaxError. Consider matching from the first {/[, or asserting the shape via zod with a clearer error.
  • lockTarget records process.pid in .agentcore.lock but never reads it. If the intent is to help diagnose stale locks (as the error message hints), the check message could point users at the recorded pid, otherwise the write is dead weight.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Sep 20, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 20, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Sep 20, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 20, 2026
@codecov-commenter

codecov-commenter commented Sep 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.26%. Comparing base (a23e472) to head (c81ae2c).

Additional details and impacted files
@@            Coverage Diff            @@
##           refactor    #2347   +/-   ##
=========================================
  Coverage     97.26%   97.26%           
=========================================
  Files           610      610           
  Lines         40590    40590           
=========================================
+ Hits          39480    39481    +1     
+ Misses         1110     1109    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 20, 2026
@github-actions github-actions Bot added size/m PR size: M and removed size/xl PR size: XL labels Sep 20, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 20, 2026
@jariy17 jariy17 changed the title feat(project): add AWSCC Terraform backend preview feat(examples): add AWSCC AgentCore Terraform templates Sep 20, 2026
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Sep 20, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 20, 2026
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Sep 20, 2026
@jariy17 jariy17 closed this Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants