Skip to content

Commit

Permalink
fix(efs): support tagging for access point (#24336)
Browse files Browse the repository at this point in the history
Closes #20743 .

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

* [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
* [X] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
ymhiroki committed Mar 1, 2023
1 parent 7ad8bc0 commit f9af47f
Show file tree
Hide file tree
Showing 41 changed files with 875 additions and 159 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "30.1.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "21.0.0",
"version": "30.1.0",
"files": {
"742f32336d22265973f0e225f7f35f8254d591f606eb0b3fbbc4ffbe4909a323": {
"dea8441064e2b7f93a29d086bcfc92bbdd9b163aed56cc08208f3ec941e96441": {
"source": {
"path": "batch-stack.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "742f32336d22265973f0e225f7f35f8254d591f606eb0b3fbbc4ffbe4909a323.json",
"objectKey": "dea8441064e2b7f93a29d086bcfc92bbdd9b163aed56cc08208f3ec941e96441.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,12 @@
"FileSystemId": {
"Ref": "EFSF3301CFD"
},
"AccessPointTags": [
{
"Key": "Name",
"Value": "batch-stack/EFSAccessPoint"
}
],
"PosixUser": {
"Gid": "1000",
"Uid": "1000"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"20.0.0"}
{"version":"30.1.0"}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "30.1.0",
"testCases": {
"BatchWithEFSTest/DefaultTest": {
"stacks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"version": "21.0.0",
"version": "30.1.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"batch-stack.assets": {
"type": "cdk:asset-manifest",
"properties": {
Expand All @@ -23,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/742f32336d22265973f0e225f7f35f8254d591f606eb0b3fbbc4ffbe4909a323.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/dea8441064e2b7f93a29d086bcfc92bbdd9b163aed56cc08208f3ec941e96441.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -490,6 +484,12 @@
]
},
"displayName": "BatchWithEFSTest/DefaultTest/DeployAssert"
},
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
"id": "App",
"path": "",
"children": {
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.140"
}
},
"batch-stack": {
"id": "batch-stack",
"path": "batch-stack",
Expand Down Expand Up @@ -942,6 +934,12 @@
"fileSystemId": {
"Ref": "EFSF3301CFD"
},
"accessPointTags": [
{
"key": "Name",
"value": "batch-stack/EFSAccessPoint"
}
],
"posixUser": {
"uid": "1000",
"gid": "1000"
Expand Down Expand Up @@ -970,6 +968,14 @@
"id": "DefaultJobRole",
"path": "batch-stack/DefaultJobRole",
"children": {
"ImportDefaultJobRole": {
"id": "ImportDefaultJobRole",
"path": "batch-stack/DefaultJobRole/ImportDefaultJobRole",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "batch-stack/DefaultJobRole/Resource",
Expand Down Expand Up @@ -1132,6 +1138,14 @@
"id": "Ecs-Instance-Role",
"path": "batch-stack/batch-demand-compute-env-launch-template/Ecs-Instance-Role",
"children": {
"ImportEcs-Instance-Role": {
"id": "ImportEcs-Instance-Role",
"path": "batch-stack/batch-demand-compute-env-launch-template/Ecs-Instance-Role/ImportEcs-Instance-Role",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "batch-stack/batch-demand-compute-env-launch-template/Ecs-Instance-Role/Resource",
Expand Down Expand Up @@ -1199,6 +1213,14 @@
"id": "Resource-Service-Instance-Role",
"path": "batch-stack/batch-demand-compute-env-launch-template/Resource-Service-Instance-Role",
"children": {
"ImportResource-Service-Instance-Role": {
"id": "ImportResource-Service-Instance-Role",
"path": "batch-stack/batch-demand-compute-env-launch-template/Resource-Service-Instance-Role/ImportResource-Service-Instance-Role",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "batch-stack/batch-demand-compute-env-launch-template/Resource-Service-Instance-Role/Resource",
Expand Down Expand Up @@ -1358,6 +1380,14 @@
"id": "Ecs-Instance-Role",
"path": "batch-stack/batch-spot-compute-env/Ecs-Instance-Role",
"children": {
"ImportEcs-Instance-Role": {
"id": "ImportEcs-Instance-Role",
"path": "batch-stack/batch-spot-compute-env/Ecs-Instance-Role/ImportEcs-Instance-Role",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "batch-stack/batch-spot-compute-env/Ecs-Instance-Role/Resource",
Expand Down Expand Up @@ -1425,6 +1455,14 @@
"id": "Resource-Service-Instance-Role",
"path": "batch-stack/batch-spot-compute-env/Resource-Service-Instance-Role",
"children": {
"ImportResource-Service-Instance-Role": {
"id": "ImportResource-Service-Instance-Role",
"path": "batch-stack/batch-spot-compute-env/Resource-Service-Instance-Role/ImportResource-Service-Instance-Role",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "batch-stack/batch-spot-compute-env/Resource-Service-Instance-Role/Resource",
Expand Down Expand Up @@ -1587,6 +1625,14 @@
"id": "Ecs-Instance-Role",
"path": "batch-stack/batch-demand-compute-env-launch-template-2/Ecs-Instance-Role",
"children": {
"ImportEcs-Instance-Role": {
"id": "ImportEcs-Instance-Role",
"path": "batch-stack/batch-demand-compute-env-launch-template-2/Ecs-Instance-Role/ImportEcs-Instance-Role",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "batch-stack/batch-demand-compute-env-launch-template-2/Ecs-Instance-Role/Resource",
Expand Down Expand Up @@ -1654,6 +1700,14 @@
"id": "Resource-Service-Instance-Role",
"path": "batch-stack/batch-demand-compute-env-launch-template-2/Resource-Service-Instance-Role",
"children": {
"ImportResource-Service-Instance-Role": {
"id": "ImportResource-Service-Instance-Role",
"path": "batch-stack/batch-demand-compute-env-launch-template-2/Resource-Service-Instance-Role/ImportResource-Service-Instance-Role",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "batch-stack/batch-demand-compute-env-launch-template-2/Resource-Service-Instance-Role/Resource",
Expand Down Expand Up @@ -1852,6 +1906,14 @@
"id": "Resource-Service-Instance-Role",
"path": "batch-stack/batch-fargate-compute-env/Resource-Service-Instance-Role",
"children": {
"ImportResource-Service-Instance-Role": {
"id": "ImportResource-Service-Instance-Role",
"path": "batch-stack/batch-fargate-compute-env/Resource-Service-Instance-Role/ImportResource-Service-Instance-Role",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "batch-stack/batch-fargate-compute-env/Resource-Service-Instance-Role/Resource",
Expand Down Expand Up @@ -1986,6 +2048,14 @@
"id": "Resource-Service-Instance-Role",
"path": "batch-stack/batch-fargate-spot-compute-env/Resource-Service-Instance-Role",
"children": {
"ImportResource-Service-Instance-Role": {
"id": "ImportResource-Service-Instance-Role",
"path": "batch-stack/batch-fargate-spot-compute-env/Resource-Service-Instance-Role/ImportResource-Service-Instance-Role",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "batch-stack/batch-fargate-spot-compute-env/Resource-Service-Instance-Role/Resource",
Expand Down Expand Up @@ -2313,6 +2383,14 @@
"id": "execution-role",
"path": "batch-stack/execution-role",
"children": {
"Importexecution-role": {
"id": "Importexecution-role",
"path": "batch-stack/execution-role/Importexecution-role",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "batch-stack/execution-role/Resource",
Expand Down Expand Up @@ -2502,6 +2580,22 @@
"fqn": "@aws-cdk/aws-batch.JobDefinition",
"version": "0.0.0"
}
},
"BootstrapVersion": {
"id": "BootstrapVersion",
"path": "batch-stack/BootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnParameter",
"version": "0.0.0"
}
},
"CheckBootstrapVersion": {
"id": "CheckBootstrapVersion",
"path": "batch-stack/CheckBootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnRule",
"version": "0.0.0"
}
}
},
"constructInfo": {
Expand All @@ -2522,12 +2616,30 @@
"path": "BatchWithEFSTest/DefaultTest/Default",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.140"
"version": "10.1.252"
}
},
"DeployAssert": {
"id": "DeployAssert",
"path": "BatchWithEFSTest/DefaultTest/DeployAssert",
"children": {
"BootstrapVersion": {
"id": "BootstrapVersion",
"path": "BatchWithEFSTest/DefaultTest/DeployAssert/BootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnParameter",
"version": "0.0.0"
}
},
"CheckBootstrapVersion": {
"id": "CheckBootstrapVersion",
"path": "BatchWithEFSTest/DefaultTest/DeployAssert/CheckBootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnRule",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/core.Stack",
"version": "0.0.0"
Expand All @@ -2544,6 +2656,14 @@
"fqn": "@aws-cdk/integ-tests.IntegTest",
"version": "0.0.0"
}
},
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.252"
}
}
},
"constructInfo": {
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-efs/lib/access-point.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ArnFormat, IResource, Resource, Stack } from '@aws-cdk/core';
import { ArnFormat, IResource, Resource, Stack, Tags } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { IFileSystem } from './efs-file-system';
import { CfnAccessPoint } from './efs.generated';
Expand Down Expand Up @@ -218,6 +218,8 @@ export class AccessPoint extends AccessPointBase {
} : undefined,
});

Tags.of(this).add('Name', this.node.path);

this.accessPointId = resource.ref;
this.accessPointArn = Stack.of(scope).formatArn({
service: 'elasticfilesystem',
Expand Down
21 changes: 20 additions & 1 deletion packages/@aws-cdk/aws-efs/test/access-point.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Template } from '@aws-cdk/assertions';
import * as ec2 from '@aws-cdk/aws-ec2';
import { Stack } from '@aws-cdk/core';
import { Stack, Tags } from '@aws-cdk/core';
import { AccessPoint, FileSystem } from '../lib';

let stack: Stack;
Expand Down Expand Up @@ -31,6 +31,25 @@ test('new AccessPoint correctly', () => {
Template.fromStack(stack).resourceCountIs('AWS::EFS::AccessPoint', 1);
});

test('support tags for AccessPoint', () => {
// WHEN
const accessPoint = new AccessPoint(stack, 'MyAccessPoint', {
fileSystem,
});
Tags.of(accessPoint).add('key1', 'value1');
Tags.of(accessPoint).add('key2', 'value2');
Tags.of(accessPoint).add('Name', 'MyAccessPointName');

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::EFS::AccessPoint', {
AccessPointTags: [
{ Key: 'key1', Value: 'value1' },
{ Key: 'key2', Value: 'value2' },
{ Key: 'Name', Value: 'MyAccessPointName' },
],
});
});

test('import an AccessPoint using fromAccessPointId', () => {
// WHEN
const ap = new AccessPoint(stack, 'MyAccessPoint', {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "30.0.0",
"version": "30.1.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"30.0.0"}
{"version":"30.1.0"}
Loading

0 comments on commit f9af47f

Please sign in to comment.