Skip to content

aws-efs: FileSystem deployment fails if vpcSubnets are referenced from existing subnets #33876

Open
@vumdao

Description

@vumdao

Describe the feature

Code

    const efs = new FileSystem(this, 'FileSystem', {
      vpc,
      encrypted: true,
      lifecyclePolicy: LifecyclePolicy.AFTER_7_DAYS,
      vpcSubnets: { subnets: [ Subnet.fromSubnetAttributes(this, subnetId, {subnetId: subnetId, availabilityZone: az}) ] },
      removalPolicy: RemovalPolicy.DESTROY,
    });

Error:

Error: Resolution error: ID components may not include unresolved tokens: EfsMountTarget-${Token[TOKEN.1221]}.
Object creation stack:
  at Execute again with CDK_DEBUG=true to capture stack traces
    at makeUniqueId (/Users/dev/workspace/github/org/core/node_modules/aws-cdk-lib/core/lib/private/uniqueid.js:1:660)
    at orgStack.allocateLogicalId (/Users/dev/workspace/github/org/core/node_modules/aws-cdk-lib/core/lib/stack.js:1:19234)
    at orgStack.getLogicalId (/Users/dev/workspace/github/org/core/node_modules/aws-cdk-lib/core/lib/stack.js:1:8662)
    at CfnMountTarget.synthesizeLogicalId (/Users/dev/workspace/github/org/core/node_modules/aws-cdk-lib/core/lib/cfn-element.js:2:687)
    at Object.produce (/Users/dev/workspace/github/org/core/node_modules/aws-cdk-lib/core/lib/cfn-element.js:1:915)
    at LazyString.resolve (/Users/dev/workspace/github/org/core/node_modules/aws-cdk-lib/core/lib/lazy.js:1:4176)
    at RememberingTokenResolver.resolveToken (/Users/dev/workspace/github/org/core/node_modules/aws-cdk-lib/core/lib/resolvable.js:1:1401)
    at RememberingTokenResolver.resolveToken (/Users/dev/workspace/github/org/core/node_modules/aws-cdk-lib/core/lib/private/resolve.js:1:4116)
    at resolve (/Users/dev/workspace/github/org/core/node_modules/aws-cdk-lib/core/lib/private/resolve.js:1:2747)
    at Object.resolve (/Users/dev/workspace/github/org/core/node_modules/aws-cdk-lib/core/lib/private/resolve.js:1:1115)```

Related: https://github.com/aws/aws-cdk/pull/26155 where I see it uses `EfsMountTarget-${subnet.node.id}` as the stack ID of mount target

### Use Case

Create FileSystem with subnets from references

### CDK version used

2.185.0

### Environment details (OS name and version, etc.)

macOS Sequoia 15.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-efsRelated to Amazon Elastic File SystembugThis issue is a bug.effort/mediumMedium work item – several days of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions