@guardian/cdk 52.3.1 → 53.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bin/commands/account-readiness/ssm.js +1 -1
- package/lib/bin/commands/account-readiness/ssm.js.map +1 -1
- package/lib/bin/commands/new-project/utils/init.js +0 -1
- package/lib/bin/commands/new-project/utils/init.js.map +1 -1
- package/lib/constructs/core/stack.d.ts +2 -11
- package/lib/constructs/core/stack.d.ts.map +1 -1
- package/lib/constructs/core/stack.js +1 -17
- package/lib/constructs/core/stack.js.map +1 -1
- package/lib/riff-raff-yaml-file/deployments/cloudformation.js +3 -4
- package/lib/riff-raff-yaml-file/deployments/cloudformation.js.map +1 -1
- package/lib/riff-raff-yaml-file/index.d.ts.map +1 -1
- package/lib/riff-raff-yaml-file/index.js +3 -4
- package/lib/riff-raff-yaml-file/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/lib/constructs/stack-set/index.d.ts +0 -2
- package/lib/constructs/stack-set/index.d.ts.map +0 -1
- package/lib/constructs/stack-set/index.js +0 -18
- package/lib/constructs/stack-set/index.js.map +0 -1
- package/lib/constructs/stack-set/stack-set.d.ts +0 -137
- package/lib/constructs/stack-set/stack-set.d.ts.map +0 -1
- package/lib/constructs/stack-set/stack-set.js +0 -132
- package/lib/constructs/stack-set/stack-set.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guardian/cdk",
|
|
3
3
|
"description": "Generic Guardian flavoured AWS CDK components",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "53.0.1",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"cli:dev": "ts-node src/bin/index.ts"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@
|
|
31
|
+
"@changesets/cli": "2.27.1",
|
|
32
|
+
"@guardian/eslint-config-typescript": "8.0.0",
|
|
32
33
|
"@guardian/eslint-plugin-tsdoc-required": "^0.1.3",
|
|
33
34
|
"@guardian/tsconfig": "^0.2.0",
|
|
34
35
|
"@types/git-url-parse": "^9.0.3",
|
|
@@ -36,31 +37,30 @@
|
|
|
36
37
|
"@types/js-yaml": "^4.0.9",
|
|
37
38
|
"@types/lodash.camelcase": "^4.3.9",
|
|
38
39
|
"@types/lodash.kebabcase": "^4.1.9",
|
|
39
|
-
"@types/lodash.upperfirst": "^4.3.
|
|
40
|
-
"@types/node": "20.
|
|
40
|
+
"@types/lodash.upperfirst": "^4.3.9",
|
|
41
|
+
"@types/node": "20.11.2",
|
|
41
42
|
"@types/yargs": "^17.0.32",
|
|
42
43
|
"aws-cdk": "2.114.1",
|
|
43
44
|
"cz-conventional-changelog": "^3.3.0",
|
|
44
|
-
"eslint": "^8.
|
|
45
|
+
"eslint": "^8.56.0",
|
|
45
46
|
"eslint-plugin-custom-rules": "file:tools/eslint",
|
|
46
|
-
"gh-pages": "^6.
|
|
47
|
+
"gh-pages": "^6.1.1",
|
|
47
48
|
"jest": "^29.7.0",
|
|
48
|
-
"prettier": "^3.1.
|
|
49
|
+
"prettier": "^3.1.1",
|
|
49
50
|
"serve": "^14.2.1",
|
|
50
51
|
"ts-jest": "^29.1.1",
|
|
51
|
-
"ts-node": "^10.9.
|
|
52
|
-
"typedoc": "^0.25.
|
|
52
|
+
"ts-node": "^10.9.2",
|
|
53
|
+
"typedoc": "^0.25.7",
|
|
53
54
|
"typescript": "5.1.6"
|
|
54
55
|
},
|
|
55
56
|
"dependencies": {
|
|
56
|
-
"@changesets/cli": "^2.27.1",
|
|
57
57
|
"@oclif/core": "2.15.0",
|
|
58
58
|
"aws-cdk-lib": "2.114.1",
|
|
59
|
-
"aws-sdk": "^2.
|
|
59
|
+
"aws-sdk": "^2.1536.0",
|
|
60
60
|
"chalk": "^4.1.2",
|
|
61
|
-
"codemaker": "^1.
|
|
61
|
+
"codemaker": "^1.93.0",
|
|
62
62
|
"constructs": "10.3.0",
|
|
63
|
-
"git-url-parse": "^
|
|
63
|
+
"git-url-parse": "^14.0.0",
|
|
64
64
|
"js-yaml": "^4.1.0",
|
|
65
65
|
"lodash.camelcase": "^4.3.0",
|
|
66
66
|
"lodash.kebabcase": "^4.1.1",
|
|
@@ -78,4 +78,4 @@
|
|
|
78
78
|
"path": "./node_modules/cz-conventional-changelog"
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constructs/stack-set/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./stack-set"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constructs/stack-set/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B","sourcesContent":["export * from \"./stack-set\";\n"]}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { CfnStackSet } from "aws-cdk-lib";
|
|
2
|
-
import type { GuStack, GuStackForStackSetInstance } from "../core";
|
|
3
|
-
interface GuStackSetProps {
|
|
4
|
-
/**
|
|
5
|
-
* The contents for `TemplateBody` within a `AWS::CloudFormation::StackSet`.
|
|
6
|
-
*
|
|
7
|
-
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stackset.html#cfn-cloudformation-stackset-templatebody
|
|
8
|
-
*/
|
|
9
|
-
stackSetInstance: GuStackForStackSetInstance;
|
|
10
|
-
/**
|
|
11
|
-
* The name of the stack set. This will appear in the target account.
|
|
12
|
-
*/
|
|
13
|
-
name: string;
|
|
14
|
-
/**
|
|
15
|
-
* A description of the stack set. This will appear in the target account.
|
|
16
|
-
*/
|
|
17
|
-
description: string;
|
|
18
|
-
/**
|
|
19
|
-
* AWS Organisation Unit IDs to deploy the stack set into.
|
|
20
|
-
*
|
|
21
|
-
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudformation-stackset-deploymenttargets.html#cfn-cloudformation-stackset-deploymenttargets-organizationalunitids
|
|
22
|
-
*/
|
|
23
|
-
organisationUnitTargets: string[];
|
|
24
|
-
/**
|
|
25
|
-
* The contents for`Parameters` within a `AWS::CloudFormation::StackSet`.
|
|
26
|
-
*
|
|
27
|
-
* Typically, you'll only need parameters if the parent stack creates resources for use in the stack set instances.
|
|
28
|
-
*
|
|
29
|
-
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stackset.html#cfn-cloudformation-stackset-parameters
|
|
30
|
-
*/
|
|
31
|
-
stackSetInstanceParameters?: Record<string, string>;
|
|
32
|
-
/**
|
|
33
|
-
* Which regions to run the stack set in.
|
|
34
|
-
*
|
|
35
|
-
* @default The region of the parent stack.
|
|
36
|
-
*/
|
|
37
|
-
regions?: string[];
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* A construct to create a `AWS::CloudFormation::StackSet`.
|
|
41
|
-
*
|
|
42
|
-
* The stack set will be configured to automatically deploy into accounts when they join an AWS Organisation Unit.
|
|
43
|
-
* It's assumed stack sets are only provisioned for infrastructure, therefore the `STAGE` value will always be `INFRA`.
|
|
44
|
-
*
|
|
45
|
-
* Usage:
|
|
46
|
-
* ```typescript
|
|
47
|
-
* // the infrastructure to create in target accounts
|
|
48
|
-
* class AccountAlertTopic extends GuStackForStackSetInstance {
|
|
49
|
-
* constructor(id: string, props: GuStackProps) {
|
|
50
|
-
* super(id, props);
|
|
51
|
-
*
|
|
52
|
-
* new GuSnsTopic(this, "topic-for-alerts");
|
|
53
|
-
* }
|
|
54
|
-
* }
|
|
55
|
-
*
|
|
56
|
-
* class ParentStack extends GuStackForInfrastructure {
|
|
57
|
-
* constructor(scope: App, id: string, props: GuStackProps) {
|
|
58
|
-
* super(scope, id, props);
|
|
59
|
-
*
|
|
60
|
-
* new GuStackSet(this, `${id}StackSet`, {
|
|
61
|
-
* stackSetInstance: new AccountAlertTopic("Alerts", { stack: props.stack }),
|
|
62
|
-
* name: "centralised-alarms",
|
|
63
|
-
* description: "Provisioning of standard account alerting resources",
|
|
64
|
-
* organisationUnitTargets: [ "o-abcde12345" ]
|
|
65
|
-
* });
|
|
66
|
-
* }
|
|
67
|
-
* }
|
|
68
|
-
*
|
|
69
|
-
* // contents of `bin/cdk.ts`
|
|
70
|
-
* new ParentStack(new App(), "AccountAlarmResources", { stack: "alarms" })
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* This will produce a CloudFormation template like this:
|
|
74
|
-
* ```yaml
|
|
75
|
-
* Resources:
|
|
76
|
-
* AccountAlarmResourcesStackSet:
|
|
77
|
-
* Type: AWS::CloudFormation::StackSet
|
|
78
|
-
* Properties:
|
|
79
|
-
* PermissionModel: SERVICE_MANAGED
|
|
80
|
-
* StackSetName: centralised-alarms
|
|
81
|
-
* AutoDeployment:
|
|
82
|
-
* Enabled: true
|
|
83
|
-
* RetainStacksOnAccountRemoval: false
|
|
84
|
-
* Description: Provisioning of standard account alerting resources
|
|
85
|
-
* Parameters: []
|
|
86
|
-
* StackInstancesGroup:
|
|
87
|
-
* - DeploymentTargets:
|
|
88
|
-
* OrganizationalUnitIds:
|
|
89
|
-
* - o-abcde12345
|
|
90
|
-
* Regions:
|
|
91
|
-
* - Ref: AWS::Region
|
|
92
|
-
* Tags:
|
|
93
|
-
* - Key: gu:cdk:version
|
|
94
|
-
* Value: TEST
|
|
95
|
-
* - Key: gu:repo
|
|
96
|
-
* Value: guardian/cdk
|
|
97
|
-
* - Key: Stack
|
|
98
|
-
* Value: alarms
|
|
99
|
-
* - Key: Stage
|
|
100
|
-
* Value: INFRA
|
|
101
|
-
* TemplateBody: |-
|
|
102
|
-
* {
|
|
103
|
-
* "Resources": {
|
|
104
|
-
* "topicforalerts57330FBE": {
|
|
105
|
-
* "Type": "AWS::SNS::Topic",
|
|
106
|
-
* "Properties": {
|
|
107
|
-
* "Tags": [
|
|
108
|
-
* {
|
|
109
|
-
* "Key": "gu:cdk:version",
|
|
110
|
-
* "Value": "TEST"
|
|
111
|
-
* },
|
|
112
|
-
* {
|
|
113
|
-
* "Key": "gu:repo",
|
|
114
|
-
* "Value": "guardian/cdk"
|
|
115
|
-
* },
|
|
116
|
-
* {
|
|
117
|
-
* "Key": "Stack",
|
|
118
|
-
* "Value": "alarms"
|
|
119
|
-
* },
|
|
120
|
-
* {
|
|
121
|
-
* "Key": "Stage",
|
|
122
|
-
* "Value": "INFRA"
|
|
123
|
-
* }
|
|
124
|
-
* ]
|
|
125
|
-
* }
|
|
126
|
-
* }
|
|
127
|
-
* }
|
|
128
|
-
* }
|
|
129
|
-
* ```
|
|
130
|
-
*
|
|
131
|
-
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stackset.html
|
|
132
|
-
*/
|
|
133
|
-
export declare class GuStackSet extends CfnStackSet {
|
|
134
|
-
constructor(scope: GuStack, id: string, props: GuStackSetProps);
|
|
135
|
-
}
|
|
136
|
-
export {};
|
|
137
|
-
//# sourceMappingURL=stack-set.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stack-set.d.ts","sourceRoot":"","sources":["../../../src/constructs/stack-set/stack-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAEnE,UAAU,eAAe;IACvB;;;;OAIG;IACH,gBAAgB,EAAE,0BAA0B,CAAC;IAE7C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,uBAAuB,EAAE,MAAM,EAAE,CAAC;IAElC;;;;;;OAMG;IACH,0BAA0B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpD;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AACH,qBAAa,UAAW,SAAQ,WAAW;gBAC7B,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe;CAkC/D"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GuStackSet = void 0;
|
|
4
|
-
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
|
-
/**
|
|
6
|
-
* A construct to create a `AWS::CloudFormation::StackSet`.
|
|
7
|
-
*
|
|
8
|
-
* The stack set will be configured to automatically deploy into accounts when they join an AWS Organisation Unit.
|
|
9
|
-
* It's assumed stack sets are only provisioned for infrastructure, therefore the `STAGE` value will always be `INFRA`.
|
|
10
|
-
*
|
|
11
|
-
* Usage:
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // the infrastructure to create in target accounts
|
|
14
|
-
* class AccountAlertTopic extends GuStackForStackSetInstance {
|
|
15
|
-
* constructor(id: string, props: GuStackProps) {
|
|
16
|
-
* super(id, props);
|
|
17
|
-
*
|
|
18
|
-
* new GuSnsTopic(this, "topic-for-alerts");
|
|
19
|
-
* }
|
|
20
|
-
* }
|
|
21
|
-
*
|
|
22
|
-
* class ParentStack extends GuStackForInfrastructure {
|
|
23
|
-
* constructor(scope: App, id: string, props: GuStackProps) {
|
|
24
|
-
* super(scope, id, props);
|
|
25
|
-
*
|
|
26
|
-
* new GuStackSet(this, `${id}StackSet`, {
|
|
27
|
-
* stackSetInstance: new AccountAlertTopic("Alerts", { stack: props.stack }),
|
|
28
|
-
* name: "centralised-alarms",
|
|
29
|
-
* description: "Provisioning of standard account alerting resources",
|
|
30
|
-
* organisationUnitTargets: [ "o-abcde12345" ]
|
|
31
|
-
* });
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* // contents of `bin/cdk.ts`
|
|
36
|
-
* new ParentStack(new App(), "AccountAlarmResources", { stack: "alarms" })
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* This will produce a CloudFormation template like this:
|
|
40
|
-
* ```yaml
|
|
41
|
-
* Resources:
|
|
42
|
-
* AccountAlarmResourcesStackSet:
|
|
43
|
-
* Type: AWS::CloudFormation::StackSet
|
|
44
|
-
* Properties:
|
|
45
|
-
* PermissionModel: SERVICE_MANAGED
|
|
46
|
-
* StackSetName: centralised-alarms
|
|
47
|
-
* AutoDeployment:
|
|
48
|
-
* Enabled: true
|
|
49
|
-
* RetainStacksOnAccountRemoval: false
|
|
50
|
-
* Description: Provisioning of standard account alerting resources
|
|
51
|
-
* Parameters: []
|
|
52
|
-
* StackInstancesGroup:
|
|
53
|
-
* - DeploymentTargets:
|
|
54
|
-
* OrganizationalUnitIds:
|
|
55
|
-
* - o-abcde12345
|
|
56
|
-
* Regions:
|
|
57
|
-
* - Ref: AWS::Region
|
|
58
|
-
* Tags:
|
|
59
|
-
* - Key: gu:cdk:version
|
|
60
|
-
* Value: TEST
|
|
61
|
-
* - Key: gu:repo
|
|
62
|
-
* Value: guardian/cdk
|
|
63
|
-
* - Key: Stack
|
|
64
|
-
* Value: alarms
|
|
65
|
-
* - Key: Stage
|
|
66
|
-
* Value: INFRA
|
|
67
|
-
* TemplateBody: |-
|
|
68
|
-
* {
|
|
69
|
-
* "Resources": {
|
|
70
|
-
* "topicforalerts57330FBE": {
|
|
71
|
-
* "Type": "AWS::SNS::Topic",
|
|
72
|
-
* "Properties": {
|
|
73
|
-
* "Tags": [
|
|
74
|
-
* {
|
|
75
|
-
* "Key": "gu:cdk:version",
|
|
76
|
-
* "Value": "TEST"
|
|
77
|
-
* },
|
|
78
|
-
* {
|
|
79
|
-
* "Key": "gu:repo",
|
|
80
|
-
* "Value": "guardian/cdk"
|
|
81
|
-
* },
|
|
82
|
-
* {
|
|
83
|
-
* "Key": "Stack",
|
|
84
|
-
* "Value": "alarms"
|
|
85
|
-
* },
|
|
86
|
-
* {
|
|
87
|
-
* "Key": "Stage",
|
|
88
|
-
* "Value": "INFRA"
|
|
89
|
-
* }
|
|
90
|
-
* ]
|
|
91
|
-
* }
|
|
92
|
-
* }
|
|
93
|
-
* }
|
|
94
|
-
* }
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stackset.html
|
|
98
|
-
*/
|
|
99
|
-
class GuStackSet extends aws_cdk_lib_1.CfnStackSet {
|
|
100
|
-
constructor(scope, id, props) {
|
|
101
|
-
const stackSetInstanceParameters = props.stackSetInstanceParameters ?? {};
|
|
102
|
-
const params = Object.keys(stackSetInstanceParameters);
|
|
103
|
-
const parameterKeys = Object.keys(props.stackSetInstance.parameters);
|
|
104
|
-
const undefinedStackSetParams = parameterKeys.filter((_) => !params.includes(_));
|
|
105
|
-
if (undefinedStackSetParams.length !== 0) {
|
|
106
|
-
throw new Error(`There are undefined stack set parameters: ${undefinedStackSetParams.join(", ")}`);
|
|
107
|
-
}
|
|
108
|
-
super(scope, id, {
|
|
109
|
-
stackSetName: props.name,
|
|
110
|
-
description: props.description,
|
|
111
|
-
permissionModel: "SERVICE_MANAGED",
|
|
112
|
-
autoDeployment: {
|
|
113
|
-
enabled: true,
|
|
114
|
-
retainStacksOnAccountRemoval: false,
|
|
115
|
-
},
|
|
116
|
-
stackInstancesGroup: [
|
|
117
|
-
{
|
|
118
|
-
regions: props.regions ?? [scope.region],
|
|
119
|
-
deploymentTargets: {
|
|
120
|
-
organizationalUnitIds: props.organisationUnitTargets,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
templateBody: props.stackSetInstance.cfnJson,
|
|
125
|
-
parameters: Object.entries(stackSetInstanceParameters).map(([key, value]) => {
|
|
126
|
-
return { parameterKey: key, parameterValue: value };
|
|
127
|
-
}),
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.GuStackSet = GuStackSet;
|
|
132
|
-
//# sourceMappingURL=stack-set.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stack-set.js","sourceRoot":"","sources":["../../../src/constructs/stack-set/stack-set.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AA6C1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AACH,MAAa,UAAW,SAAQ,yBAAW;IACzC,YAAY,KAAc,EAAE,EAAU,EAAE,KAAsB;QAC5D,MAAM,0BAA0B,GAAG,KAAK,CAAC,0BAA0B,IAAI,EAAE,CAAC;QAE1E,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACvD,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAErE,MAAM,uBAAuB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjF,IAAI,uBAAuB,CAAC,MAAM,KAAK,CAAC,EAAE;YACxC,MAAM,IAAI,KAAK,CAAC,6CAA6C,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACpG;QAED,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE;YACf,YAAY,EAAE,KAAK,CAAC,IAAI;YACxB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,eAAe,EAAE,iBAAiB;YAClC,cAAc,EAAE;gBACd,OAAO,EAAE,IAAI;gBACb,4BAA4B,EAAE,KAAK;aACpC;YACD,mBAAmB,EAAE;gBACnB;oBACE,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;oBACxC,iBAAiB,EAAE;wBACjB,qBAAqB,EAAE,KAAK,CAAC,uBAAuB;qBACrD;iBACF;aACF;YACD,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,OAAO;YAC5C,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;gBAC1E,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;YACtD,CAAC,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF;AAnCD,gCAmCC","sourcesContent":["import { CfnStackSet } from \"aws-cdk-lib\";\nimport type { GuStack, GuStackForStackSetInstance } from \"../core\";\n\ninterface GuStackSetProps {\n /**\n * The contents for `TemplateBody` within a `AWS::CloudFormation::StackSet`.\n *\n * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stackset.html#cfn-cloudformation-stackset-templatebody\n */\n stackSetInstance: GuStackForStackSetInstance;\n\n /**\n * The name of the stack set. This will appear in the target account.\n */\n name: string;\n\n /**\n * A description of the stack set. This will appear in the target account.\n */\n description: string;\n\n /**\n * AWS Organisation Unit IDs to deploy the stack set into.\n *\n * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudformation-stackset-deploymenttargets.html#cfn-cloudformation-stackset-deploymenttargets-organizationalunitids\n */\n organisationUnitTargets: string[];\n\n /**\n * The contents for`Parameters` within a `AWS::CloudFormation::StackSet`.\n *\n * Typically, you'll only need parameters if the parent stack creates resources for use in the stack set instances.\n *\n * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stackset.html#cfn-cloudformation-stackset-parameters\n */\n stackSetInstanceParameters?: Record<string, string>;\n\n /**\n * Which regions to run the stack set in.\n *\n * @default The region of the parent stack.\n */\n regions?: string[];\n}\n\n/**\n * A construct to create a `AWS::CloudFormation::StackSet`.\n *\n * The stack set will be configured to automatically deploy into accounts when they join an AWS Organisation Unit.\n * It's assumed stack sets are only provisioned for infrastructure, therefore the `STAGE` value will always be `INFRA`.\n *\n * Usage:\n * ```typescript\n * // the infrastructure to create in target accounts\n * class AccountAlertTopic extends GuStackForStackSetInstance {\n * constructor(id: string, props: GuStackProps) {\n * super(id, props);\n *\n * new GuSnsTopic(this, \"topic-for-alerts\");\n * }\n * }\n *\n * class ParentStack extends GuStackForInfrastructure {\n * constructor(scope: App, id: string, props: GuStackProps) {\n * super(scope, id, props);\n *\n * new GuStackSet(this, `${id}StackSet`, {\n * stackSetInstance: new AccountAlertTopic(\"Alerts\", { stack: props.stack }),\n * name: \"centralised-alarms\",\n * description: \"Provisioning of standard account alerting resources\",\n * organisationUnitTargets: [ \"o-abcde12345\" ]\n * });\n * }\n * }\n *\n * // contents of `bin/cdk.ts`\n * new ParentStack(new App(), \"AccountAlarmResources\", { stack: \"alarms\" })\n * ```\n *\n * This will produce a CloudFormation template like this:\n * ```yaml\n * Resources:\n * AccountAlarmResourcesStackSet:\n * Type: AWS::CloudFormation::StackSet\n * Properties:\n * PermissionModel: SERVICE_MANAGED\n * StackSetName: centralised-alarms\n * AutoDeployment:\n * Enabled: true\n * RetainStacksOnAccountRemoval: false\n * Description: Provisioning of standard account alerting resources\n * Parameters: []\n * StackInstancesGroup:\n * - DeploymentTargets:\n * OrganizationalUnitIds:\n * - o-abcde12345\n * Regions:\n * - Ref: AWS::Region\n * Tags:\n * - Key: gu:cdk:version\n * Value: TEST\n * - Key: gu:repo\n * Value: guardian/cdk\n * - Key: Stack\n * Value: alarms\n * - Key: Stage\n * Value: INFRA\n * TemplateBody: |-\n * {\n * \"Resources\": {\n * \"topicforalerts57330FBE\": {\n * \"Type\": \"AWS::SNS::Topic\",\n * \"Properties\": {\n * \"Tags\": [\n * {\n * \"Key\": \"gu:cdk:version\",\n * \"Value\": \"TEST\"\n * },\n * {\n * \"Key\": \"gu:repo\",\n * \"Value\": \"guardian/cdk\"\n * },\n * {\n * \"Key\": \"Stack\",\n * \"Value\": \"alarms\"\n * },\n * {\n * \"Key\": \"Stage\",\n * \"Value\": \"INFRA\"\n * }\n * ]\n * }\n * }\n * }\n * }\n * ```\n *\n * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stackset.html\n */\nexport class GuStackSet extends CfnStackSet {\n constructor(scope: GuStack, id: string, props: GuStackSetProps) {\n const stackSetInstanceParameters = props.stackSetInstanceParameters ?? {};\n\n const params = Object.keys(stackSetInstanceParameters);\n const parameterKeys = Object.keys(props.stackSetInstance.parameters);\n\n const undefinedStackSetParams = parameterKeys.filter((_) => !params.includes(_));\n\n if (undefinedStackSetParams.length !== 0) {\n throw new Error(`There are undefined stack set parameters: ${undefinedStackSetParams.join(\", \")}`);\n }\n\n super(scope, id, {\n stackSetName: props.name,\n description: props.description,\n permissionModel: \"SERVICE_MANAGED\",\n autoDeployment: {\n enabled: true,\n retainStacksOnAccountRemoval: false,\n },\n stackInstancesGroup: [\n {\n regions: props.regions ?? [scope.region],\n deploymentTargets: {\n organizationalUnitIds: props.organisationUnitTargets,\n },\n },\n ],\n templateBody: props.stackSetInstance.cfnJson,\n parameters: Object.entries(stackSetInstanceParameters).map(([key, value]) => {\n return { parameterKey: key, parameterValue: value };\n }),\n });\n }\n}\n"]}
|