Skip to content

Commit 282d9d9

Browse files
committed
fix(GuParameterStoreReadPolicy): Remove hard-coded PolicyName
In v64.0.0 `GuParameterStoreReadPolicy` became a singleton scoped to an `App`. This change stops hard-coding the `PolicyName` property, reverting to AWS default behaviour. This is because `AWS::IAM::Policy` resources in a CFN stack must have a unique policy name.
1 parent be22559 commit 282d9d9

7 files changed

Lines changed: 18 additions & 14 deletions

File tree

.changeset/plain-colts-jam.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@guardian/cdk": minor
3+
---
4+
5+
Update the `GuParameterStoreReadPolicy` construct to remove the hard-coded `PolicyName` property.
6+
This allows the `GuParameterStoreReadPolicy` singleton to be instantiated multiple times in a single `GuStack` when there are multiple apps.

src/constructs/iam/policies/parameter-store-read.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ describe("GuParameterStoreReadPolicy", () => {
1313
Template.fromStack(stack).resourceCountIs("AWS::IAM::Policy", 1);
1414

1515
Template.fromStack(stack).hasResourceProperties("AWS::IAM::Policy", {
16-
PolicyName: "parameter-store-read-policy",
1716
PolicyDocument: {
1817
Version: "2012-10-17",
1918
Statement: [

src/constructs/iam/policies/parameter-store-read.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export class GuParameterStoreReadPolicy extends GuAppAwareConstruct(GuPolicy) {
4747

4848
private constructor(scope: GuStack, props: AppIdentity) {
4949
super(scope, "ParameterStoreRead", {
50-
policyName: "parameter-store-read-policy",
5150
statements: [new ReadParametersByPath(scope, props), new ReadParametersByName(scope, props)],
5251
...props,
5352
});

src/constructs/iam/roles/__snapshots__/instance-role.test.ts.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ exports[`The GuInstanceRole construct should allow additional policies to be spe
192192
],
193193
"Version": "2012-10-17",
194194
},
195-
"PolicyName": "parameter-store-read-policy",
195+
"PolicyName": "ParameterStoreReadTesting0F3B634A",
196196
"Roles": [
197197
{
198198
"Ref": "InstanceRoleTestingCB7BD146",
@@ -541,7 +541,7 @@ exports[`The GuInstanceRole construct should be possible to create multiple inst
541541
],
542542
"Version": "2012-10-17",
543543
},
544-
"PolicyName": "parameter-store-read-policy",
544+
"PolicyName": "ParameterStoreReadMyfirstappE5C5C329",
545545
"Roles": [
546546
{
547547
"Ref": "InstanceRoleMyfirstapp5C11A22B",
@@ -600,7 +600,7 @@ exports[`The GuInstanceRole construct should be possible to create multiple inst
600600
],
601601
"Version": "2012-10-17",
602602
},
603-
"PolicyName": "parameter-store-read-policy",
603+
"PolicyName": "ParameterStoreReadMysecondapp76C0E32C",
604604
"Roles": [
605605
{
606606
"Ref": "InstanceRoleMysecondapp48DD15D7",
@@ -871,7 +871,7 @@ exports[`The GuInstanceRole construct should create an additional logging policy
871871
],
872872
"Version": "2012-10-17",
873873
},
874-
"PolicyName": "parameter-store-read-policy",
874+
"PolicyName": "ParameterStoreReadTesting0F3B634A",
875875
"Roles": [
876876
{
877877
"Ref": "InstanceRoleTestingCB7BD146",
@@ -1090,7 +1090,7 @@ exports[`The GuInstanceRole construct should create the correct resources with m
10901090
],
10911091
"Version": "2012-10-17",
10921092
},
1093-
"PolicyName": "parameter-store-read-policy",
1093+
"PolicyName": "ParameterStoreReadTesting0F3B634A",
10941094
"Roles": [
10951095
{
10961096
"Ref": "InstanceRoleTestingCB7BD146",

src/experimental/patterns/__snapshots__/ec2-app.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ exports[`The GuEc2AppExperimental pattern matches the snapshot 1`] = `
635635
],
636636
"Version": "2012-10-17",
637637
},
638-
"PolicyName": "parameter-store-read-policy",
638+
"PolicyName": "ParameterStoreReadTestguec2app072DCDE1",
639639
"Roles": [
640640
{
641641
"Ref": "InstanceRoleTestguec2appC325BE42",

src/experimental/patterns/__snapshots__/gu-load-balanced-app.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ exports[`the GuLoadBalancedAppExperimental pattern should support all existing G
591591
],
592592
"Version": "2012-10-17",
593593
},
594-
"PolicyName": "parameter-store-read-policy",
594+
"PolicyName": "ParameterStoreReadTestguec2app072DCDE1",
595595
"Roles": [
596596
{
597597
"Ref": "InstanceRoleTestguec2appC325BE42",
@@ -1463,7 +1463,7 @@ exports[`the GuLoadBalancedAppExperimental pattern should support all existing G
14631463
],
14641464
"Version": "2012-10-17",
14651465
},
1466-
"PolicyName": "parameter-store-read-policy",
1466+
"PolicyName": "ParameterStoreReadTestgu2D9B3F35",
14671467
"Roles": [
14681468
{
14691469
"Ref": "InstanceRoleTestguD5DB5D23",
@@ -2337,7 +2337,7 @@ exports[`the GuLoadBalancedAppExperimental pattern should support experimental E
23372337
],
23382338
"Version": "2012-10-17",
23392339
},
2340-
"PolicyName": "parameter-store-read-policy",
2340+
"PolicyName": "ParameterStoreReadTestgu2D9B3F35",
23412341
"Roles": [
23422342
{
23432343
"Ref": "InstanceRoleTestguD5DB5D23",
@@ -3519,7 +3519,7 @@ exports[`the GuLoadBalancedAppExperimental pattern should support new ECS and hy
35193519
],
35203520
"Version": "2012-10-17",
35213521
},
3522-
"PolicyName": "parameter-store-read-policy",
3522+
"PolicyName": "ParameterStoreReadTestgu2D9B3F35",
35233523
"Roles": [
35243524
{
35253525
"Ref": "EcsTaskDefinitionTaskRoleB7B6D8DD",

src/patterns/ec2-app/__snapshots__/base.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ exports[`the GuEC2App pattern can produce a restricted EC2 app locked to specifi
591591
],
592592
"Version": "2012-10-17",
593593
},
594-
"PolicyName": "parameter-store-read-policy",
594+
"PolicyName": "ParameterStoreReadTestguec2app072DCDE1",
595595
"Roles": [
596596
{
597597
"Ref": "InstanceRoleTestguec2appC325BE42",
@@ -1463,7 +1463,7 @@ exports[`the GuEC2App pattern should produce a functional EC2 app with minimal a
14631463
],
14641464
"Version": "2012-10-17",
14651465
},
1466-
"PolicyName": "parameter-store-read-policy",
1466+
"PolicyName": "ParameterStoreReadTestguec2app072DCDE1",
14671467
"Roles": [
14681468
{
14691469
"Ref": "InstanceRoleTestguec2appC325BE42",

0 commit comments

Comments
 (0)