Skip to content

(aws-efs): Add fileSystemArn property and grant method for FileSystem construct #14998

@DaWyz

Description

@DaWyz

When creating or importing a File System in a CDK App, the construct is missing the fileSystemArn property.

Use Case

When trying to grant permissions to a FileSystem, we have to build the fileSystem the policy and the arn manually.

const customStack = new Stack(app);

const customVpc = new ec2.Vpc(customStack, 'VPC');
const fs = new FileSystem(customVpc, 'EfsFileSystem', {
  vpc: customVpc,
});

new iam.PolicyStatement({
  actions: ['elasticfilesystem:ClientWrite'],
  resources: [Stack.of(scope).formatArn({
    service: 'elasticfilesystem',
    resource: 'file-system',
    resourceName: fs.fileSystemId,
  })],
});

That would become

const customStack = new Stack(app);

const customVpc = new ec2.Vpc(customStack, 'VPC');
const fs = new FileSystem(customVpc, 'EfsFileSystem', {
  vpc: customVpc,
});

fs.grant(grantee, 'elasticfilesystem:ClientWrite');

Proposed Solution

Add a fileSystemArn attribute to the construct.
Allow import using arn.
Add a grant method.

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-efsRelated to Amazon Elastic File Systemeffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.good first issueRelated to contributions. See CONTRIBUTING.mdp2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions