Skip to content

feat: add EFS and S3 filesystem mount support#1436

Merged
padmak30 merged 2 commits into
mainfrom
feat/byo-filesystem-new
Jun 3, 2026
Merged

feat: add EFS and S3 filesystem mount support#1436
padmak30 merged 2 commits into
mainfrom
feat/byo-filesystem-new

Conversation

@padmak30
Copy link
Copy Markdown
Contributor

@padmak30 padmak30 commented Jun 2, 2026

Adds session storage, EFS access point, and S3 Files access point filesystem mounts across the full stack: CLI flags, TUI wizard steps, schema validation, CDK IAM permissions, and generated agent templates.

CLI (agentcore create / add agent / add harness):

  • --session-storage-mount-path, --efs-access-point-arn/--efs-mount-path, --s3-access-point-arn/--s3-mount-path flags on create and add agent
  • Harness create path wires filesystem flags through to harness.json
  • Sync validation: ARN format, paired flags, max mounts, VPC requirement in both validateCreateOptions and validateCreateHarnessOptions
  • Async validation: L1 access point exists, L2 VPC/AZ topology, L3 SG in agent create, add agent, and harness create paths
  • Level 3 SG check uses EFS/S3 ARN region (not agent region) for mount target SG queries; validation reads deployment region from aws-targets.json

TUI wizard:

  • EFS/S3 two-step ARN→path entry with add/edit/remove review screens
  • Shared useFilesystemMountState hook (generate wizard + BYO + harness)
  • Shared buildMountListItems helper
  • Session-storage advanced setting in harness wizard includes EFS/S3 steps
  • VPC warning and validation on harness EFS/S3 ARN steps
  • Harness TUI add flow forwards efsAccessPoints/s3AccessPoints to primitive

Schema:

  • FilesystemConfigurationSchema union (sessionStorage | efsAccessPoint | s3FilesAccessPoint) with z.strictObject, duplicate path detection, max-count enforcement, VPC requirement
  • EFS_ACCESS_POINT_ARN_PATTERN / S3_FILES_ACCESS_POINT_ARN_PATTERN constants shared between CLI validators and Zod schema
  • HarnessSpec gains efsAccessPoints/s3AccessPoints with VPC enforcement and duplicate mount path validation

CDK / deploy:

  • AgentCoreRuntime: typed filesystemConfigurations props (aws-cdk-lib 2.257)
  • AgentCoreHarnessRole: EFS ClientMount/ClientWrite and S3 Files ClientMount/ClientWrite IAM policies when mounts are configured
  • harness-mapper writes all three filesystem types; hasFilesystem uses correct boolean coercion; mount paths normalized (trailing slash stripped)
  • Vended cdk-stack.ts and bin/cdk.ts include new HarnessConfig fields

Templates:

  • HTTP, A2A, AGUI, MCP Python templates render file_read/file_write/ list_files filesystem tools via {{#if needsOs}} blocks
  • needsOs uses || not ?? so S3-only agents correctly generate tools
  • EFS ARN regex constants shared (single source of truth)
  • regionFromEfsArn/regionFromS3FilesArn merged into single regionFromArn

Tests:

  • filesystem-utils.test.ts: ARN format, path validation, pairing, mounts
  • filesystem-roundtrip.test.ts, filesystem-error-quality.test.ts: schema
  • harness-mapper.test.ts: EFS, S3, combined filesystem mapping
  • validate.test.ts: 16 new EFS/S3 validation cases for create path
  • harness-validate.test.ts: 12 new cases for harness create path
  • buildMountListItems.test.ts: 6 cases for mount list item builder
  • schema-mapper.test.ts: 12 filesystem configuration mapping cases
  • useFilesystemMountState.test.tsx: 15 hook handler tests
  • computeByoSteps.test.ts: filesystem step inclusion
  • useGenerateWizard.test.tsx: EFS/S3 flow, edit/remove, deselect

@padmak30 padmak30 requested a review from a team June 2, 2026 06:07
@github-actions github-actions Bot added the size/xl PR size: XL label Jun 2, 2026
@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label Jun 2, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jun 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Package Tarball

aws-agentcore-0.16.0.tgz

How to install

gh release download pr-1436-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.16.0.tgz

@@ -1,4 +1,6 @@
{{#if needsOs}}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These are false positives. The .py files under src/assets/python/ are Handlebars templates, not executable Python. The {{#if ...}}, {{#each ...}}, and {{/if}} directives are intentional — they are rendered at
project creation time by the Handlebars engine into valid Python. This pattern is pre-existing across all templates in the codebase (e.g., src/assets/python/http/strands/base/main.py).

@@ -1,4 +1,6 @@
{{#if needsOs}}
@@ -1,4 +1,6 @@
{{#if needsOs}}
@@ -1,4 +1,6 @@
{{#if needsOs}}
@@ -1,4 +1,6 @@
{{#if needsOs}}
@@ -1,4 +1,6 @@
{{#if needsOs}}
@@ -1,7 +1,65 @@
{{#if needsOs}}
@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 Jun 2, 2026
@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Jun 2, 2026
Adds session storage, EFS access point, and S3 Files access point
filesystem mounts across the full stack: CLI flags, TUI wizard steps,
schema validation, CDK IAM permissions, and generated agent templates.

CLI (agentcore create / add agent / add harness):
- --session-storage-mount-path, --efs-access-point-arn/--efs-mount-path,
  --s3-access-point-arn/--s3-mount-path flags on create and add agent
- Harness create path wires filesystem flags through to harness.json
- Sync validation: ARN format, paired flags, max mounts, VPC requirement
  in both validateCreateOptions and validateCreateHarnessOptions
- Async validation: L1 access point exists, L2 VPC/AZ topology, L3 SG
  in agent create, add agent, and harness create paths
- Level 3 SG check uses EFS/S3 ARN region (not agent region) for mount
  target SG queries; validation reads deployment region from aws-targets.json

TUI wizard:
- EFS/S3 two-step ARN→path entry with add/edit/remove review screens
- Shared useFilesystemMountState hook (generate wizard + BYO + harness)
- Shared buildMountListItems helper
- Session-storage advanced setting in harness wizard includes EFS/S3 steps
- VPC warning and validation on harness EFS/S3 ARN steps
- Harness TUI add flow forwards efsAccessPoints/s3AccessPoints to primitive

Schema:
- FilesystemConfigurationSchema union (sessionStorage | efsAccessPoint |
  s3FilesAccessPoint) with z.strictObject, duplicate path detection,
  max-count enforcement, VPC requirement
- EFS_ACCESS_POINT_ARN_PATTERN / S3_FILES_ACCESS_POINT_ARN_PATTERN
  constants shared between CLI validators and Zod schema
- HarnessSpec gains efsAccessPoints/s3AccessPoints with VPC enforcement
  and duplicate mount path validation

CDK / deploy:
- AgentCoreRuntime: typed filesystemConfigurations props (aws-cdk-lib 2.257)
- AgentCoreHarnessRole: EFS ClientMount/ClientWrite and S3 Files
  ClientMount/ClientWrite IAM policies when mounts are configured
- harness-mapper writes all three filesystem types; hasFilesystem uses
  correct boolean coercion; mount paths normalized (trailing slash stripped)
- Vended cdk-stack.ts and bin/cdk.ts include new HarnessConfig fields

Templates:
- HTTP, A2A, AGUI, MCP Python templates render file_read/file_write/
  list_files filesystem tools via {{#if needsOs}} blocks
- needsOs uses || not ?? so S3-only agents correctly generate tools
- EFS ARN regex constants shared (single source of truth)
- regionFromEfsArn/regionFromS3FilesArn merged into single regionFromArn

Tests:
- filesystem-utils.test.ts: ARN format, path validation, pairing, mounts
- filesystem-roundtrip.test.ts, filesystem-error-quality.test.ts: schema
- harness-mapper.test.ts: EFS, S3, combined filesystem mapping
- validate.test.ts: 16 new EFS/S3 validation cases for create path
- harness-validate.test.ts: 12 new cases for harness create path
- buildMountListItems.test.ts: 6 cases for mount list item builder
- schema-mapper.test.ts: 12 filesystem configuration mapping cases
- useFilesystemMountState.test.tsx: 15 hook handler tests
- computeByoSteps.test.ts: filesystem step inclusion
- useGenerateWizard.test.tsx: EFS/S3 flow, edit/remove, deselect
@padmak30 padmak30 force-pushed the feat/byo-filesystem-new branch from 5e271d7 to 578752e Compare June 2, 2026 07:00
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Jun 2, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jun 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 35.54% 11176 / 31445
🔵 Statements 34.87% 11881 / 34066
🔵 Functions 30.27% 1879 / 6206
🔵 Branches 29.3% 7131 / 24330
Generated in workflow #3455 for commit 98af0ea by the Vitest Coverage Report Action

@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 Jun 2, 2026
Comment thread src/cli/commands/create/command.tsx Outdated
// non-fatal: Level 2 topology checks are skipped when VPC ID cannot be resolved
}
}
const fsValidation = await validateFilesystemMountsConfiguration({
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.

style nit: this is duplicated across handleCreateCLI and handleCreateHarnessCLI + a bunch of other logic.
can we extract them to shared helpers?

if not resolved.startswith(os.path.realpath(SESSION_STORAGE_PATH)):
raise ValueError(f"Path '{path}' is outside the storage boundary")
resolved = os.path.realpath(path)
if not any(resolved.startswith(os.path.realpath(m)) for m in _MOUNT_PATHS):
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.

If mount is /mnt/a, then /mnt/abc/secret passes the check because "/mnt/abc/secret".startswith("/mnt/a") is True, granting access outside the configured mount boundary.

Fix: if not any(resolved == os.path.realpath(m) or resolved.startswith(os.path.realpath(m) + os.sep) for m in _MOUNT_PATHS):

Comment thread src/schema/schemas/agent-env.ts
Comment thread src/cli/commands/shared/filesystem-utils.ts
Copy link
Copy Markdown
Contributor

@jariy17 jariy17 left a comment

Choose a reason for hiding this comment

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

LGTM please modify e2e test to add these mounts.

Comment thread src/cli/commands/shared/filesystem-utils.ts
logger.logSubStep(`Type: ${addAgentConfig.agentType}, Language: ${addAgentConfig.language}`);

// Validate EFS/S3 filesystem mounts before writing anything (shared by create and BYO paths)
const validateFilesystemMounts = async () => {
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.

nit/p4: If a customer has multiple mounts, we should parallelize the validation by mount.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the max allowed is 2 each so leaving as it is for now

- Extract duplicated EFS/S3 mount resolution and validation logic from
  handleCreateCLI and handleCreateHarnessCLI into a shared
  resolveAndValidateFilesystemMounts() helper in filesystem-utils.ts
- Fix path traversal vulnerability in _safe_resolve: append os.sep
  before startswith check to prevent prefix collision (e.g. /mnt/a
  incorrectly matching /mnt/abc/secret)
- Add JSDoc describing L1/L2/L3 validation levels on
  validateFilesystemMountsConfiguration
- Add tests for buildFilesystemConfigurations and
  resolveAndValidateFilesystemMounts
@github-actions github-actions Bot removed the size/xl PR size: XL label Jun 3, 2026
@github-actions github-actions Bot added the size/xl PR size: XL label Jun 3, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jun 3, 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 Jun 3, 2026
@padmak30 padmak30 changed the title feat: add EFS and S3 filesystem mount support (BYO agents and harness) feat: add EFS and S3 filesystem mount support Jun 3, 2026
@padmak30 padmak30 merged commit 64b9b63 into main Jun 3, 2026
32 of 33 checks passed
@padmak30 padmak30 deleted the feat/byo-filesystem-new branch June 3, 2026 17:20
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.

3 participants