Conversation
There was a problem hiding this comment.
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.ts – environment():
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_TOKENwhen defined, e.g....(credentials.sessionToken && { AWS_SESSION_TOKEN: credentials.sessionToken }), and addAWS_SESSION_TOKEN/AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEYto 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()callsJSON.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 confusingSyntaxError. Consider matching from the first{/[, or asserting the shape via zod with a clearer error.lockTargetrecordsprocess.pidin.agentcore.lockbut 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.
|
Claude Security Review: no high-confidence findings. (run) |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
Claude Security Review: no high-confidence findings. (run) |
|
Claude Security Review: no high-confidence findings. (run) |
Summary
Adds a standalone Terraform HCL template in
examples/terraform/awsccfor an AgentCore Runtime and short-term Memory using typedhashicorp/awsccresources and Cloud Control APIs. Customers package the included Python sample and deploy it with ordinaryterraform init,plan, andapply.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
.tffiles.Validation