Skip to content

feat: add EFS and S3 filesystem mount support (BYO agents and harness)#1436

Open
padmak30 wants to merge 1 commit into
mainfrom
feat/byo-filesystem-new
Open

feat: add EFS and S3 filesystem mount support (BYO agents and harness)#1436
padmak30 wants to merge 1 commit 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.39% 11129 / 31445
🔵 Statements 34.72% 11831 / 34071
🔵 Functions 30.13% 1869 / 6202
🔵 Branches 29.12% 7094 / 24360
Generated in workflow #3424 for commit 578752e 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
// 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):

.regex(/^\/mnt\/[^/]+$/, 'Must be a path under /mnt with exactly one subdirectory (e.g. /mnt/data)'),
.min(6)
.max(200)
.regex(/^\/mnt\/[a-zA-Z0-9._-]+\/?$/, 'Must be a path under /mnt with exactly one subdirectory (e.g. /mnt/data)'),
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.

same as CDK comment why did the regex change?

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.

Updated as per AWS docs https://docs.aws.amazon.com/cli/latest/reference/bedrock-agentcore-control/create-agent-runtime.html
Since deploy would have failed for invalid regex this should be a safe change for existing projects

Comment on lines +402 to +417
/**
* Orchestrate full async filesystem validation (Levels 1–3).
* Returns on first error. Skips topology and inbound SG checks when agent VPC/SG info is absent.
*/
export async function validateFilesystemMountsConfiguration(opts: FilesystemValidationOptions): Promise<SyncResult> {
const {
efsMounts,
s3FilesMounts,
agentVpcId,
agentSubnetIds,
agentSecurityGroupIds,
region,
skipTopologyChecks,
skipInboundSgChecks,
} = opts;

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.

Nice 3 level validation here!

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.

}

/**
* Orchestrate full async filesystem validation (Levels 1–3).
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: Add some information about how the validator works.

// L1: verify access point exists and agent SGs allow NFS egress (port 2049)
  // L2: confirm mount target shares agent's VPC and has a subnet in a matching AZ
  // L3: check mount target SGs permit inbound 2049 from agent SGs
  // Each level is skipped if the prior level's prerequisite data is unavailable (graceful degradation)

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.

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