@guardian/cdk 57.0.0 → 58.0.0
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/constructs/core/stack.d.ts +0 -8
- package/lib/constructs/core/stack.d.ts.map +1 -1
- package/lib/constructs/core/stack.js +1 -5
- package/lib/constructs/core/stack.js.map +1 -1
- package/lib/constructs/dynamodb/dynamodb.d.ts +31 -0
- package/lib/constructs/dynamodb/dynamodb.d.ts.map +1 -0
- package/lib/constructs/dynamodb/dynamodb.js +18 -0
- package/lib/constructs/dynamodb/dynamodb.js.map +1 -0
- package/lib/constructs/dynamodb/index.d.ts +2 -0
- package/lib/constructs/dynamodb/index.d.ts.map +1 -0
- package/lib/constructs/dynamodb/index.js +18 -0
- package/lib/constructs/dynamodb/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/test/assertions.d.ts +1 -0
- package/lib/utils/test/assertions.d.ts.map +1 -1
- package/lib/utils/test/assertions.js +5 -0
- package/lib/utils/test/assertions.js.map +1 -1
- package/package.json +4 -4
- package/lib/aspects/aws-backup.d.ts +0 -15
- package/lib/aspects/aws-backup.d.ts.map +0 -1
- package/lib/aspects/aws-backup.js +0 -25
- package/lib/aspects/aws-backup.js.map +0 -1
|
@@ -18,6 +18,7 @@ export declare class GuTemplate {
|
|
|
18
18
|
findResourceByLogicalId(type: string, logicalId: string | RegExp): Record<string, Resource> | undefined;
|
|
19
19
|
hasResourceWithLogicalId(type: string, logicalId: string | RegExp): void;
|
|
20
20
|
hasGuTaggedResource(type: string, props?: GuTagMatcherProps): void;
|
|
21
|
+
hasResourceWithTag(type: string, tag: Tag): void;
|
|
21
22
|
}
|
|
22
23
|
export {};
|
|
23
24
|
//# sourceMappingURL=assertions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../../src/utils/test/assertions.ts"],"names":[],"mappings":"AACA,OAAO,KA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AAC,EAAE,GAAG,EAAE,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAcD,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;IAEhC,OAAO;IAKP,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO;IAI/B,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,SAAS;IAgBvG,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAQjE,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,iBAAiB;IAyC3D,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG;CAK1C"}
|
|
@@ -74,6 +74,11 @@ class GuTemplate {
|
|
|
74
74
|
}
|
|
75
75
|
this.template.hasResourceProperties(type, { Tags: sortTagsByKey(Array.from(tagMap.values())) });
|
|
76
76
|
}
|
|
77
|
+
hasResourceWithTag(type, tag) {
|
|
78
|
+
this.template.hasResourceProperties(type, {
|
|
79
|
+
Tags: assertions_1.Match.arrayWith([tag]),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
77
82
|
}
|
|
78
83
|
exports.GuTemplate = GuTemplate;
|
|
79
84
|
//# sourceMappingURL=assertions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../../src/utils/test/assertions.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../../src/utils/test/assertions.ts"],"names":[],"mappings":";;;AAAA,uDAAyD;AAEzD,+CAA4D;AAe5D,SAAS,aAAa,CAAC,IAAW;IAChC,OAAO,CAAC,GAAG,IA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C;SAC3D;QAED,iDAAiD;QACjD,IAAI,iBAAiB,KAAK,SAAS,EAAE;YACnC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACrB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC,CAAC;YACxE,CAAC,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAClG,CAAC;IAED,kBAAkB,CAAC,IAAY,EAAE,GAAQ;QACvC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,EAAE;YACxC,IAAI,EAAE,kBAAK,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC;SAC7B,CAAC,CAAC;IACL,CAAC;CACF;AAnFD,gCAmFC","sourcesContent":["import { Match, Template } from \"aws-cdk-lib/assertions\";\nimport type { Resource } from \"aws-cdk-lib/assertions/lib/private/template\";\nimport { MetadataKeys, TrackingTag } from \"../../constants\";\nimport type { AppIdentity, GuStack } from \"../../constructs/core\";\n\ninterface Tag {\n Key: string;\n Value: unknown;\n PropagateAtLaunch?: boolean;\n}\n\ninterface GuTagMatcherProps {\n appIdentity?: AppIdentity;\n additionalTags?: Tag[];\n propagateAtLaunch?: boolean;\n}\n\nfunction sortTagsByKey(tags: Tag[]): Tag[] {\n return [...tags].sort((first, second) => {\n if (first.Key.toLowerCase() < second.Key.toLowerCase()) {\n return -1;\n }\n if (first.Key.toLowerCase() > second.Key.toLowerCase()) {\n return 1;\n }\n return 0;\n });\n}\n\nexport class GuTemplate {\n private readonly template: Template;\n private readonly stack: GuStack;\n\n private constructor(scope: GuStack) {\n this.stack = scope;\n this.template = Template.fromStack(scope);\n }\n\n static fromStack(stack: GuStack) {\n return new GuTemplate(stack);\n }\n\n findResourceByLogicalId(type: string, logicalId: string | RegExp): Record<string, Resource> | undefined {\n const resources = this.template.findResources(type) as Record<string, Resource>;\n\n const match = Object.entries(resources).find(([id, resource]) => {\n const idMatch = logicalId instanceof RegExp ? logicalId.test(id) : id === logicalId;\n return idMatch && resource;\n });\n\n if (match) {\n const [logicalId, resource] = match;\n return { [logicalId]: resource };\n }\n\n return undefined;\n }\n\n hasResourceWithLogicalId(type: string, logicalId: string | RegExp) {\n const result = this.findResourceByLogicalId(type, logicalId);\n\n if (!result) {\n throw new Error(`No resource found matching logicalId ${logicalId.toString()} and Type ${type}`);\n }\n }\n\n hasGuTaggedResource(type: string, props?: GuTagMatcherProps) {\n const { stack, stage } = this.stack;\n const { appIdentity, additionalTags, propagateAtLaunch } = props ?? {};\n\n const coreTags = [\n {\n Key: \"Stack\",\n Value: stack,\n },\n {\n Key: \"Stage\",\n Value: stage,\n },\n TrackingTag,\n {\n Key: MetadataKeys.REPOSITORY_NAME,\n Value: \"guardian/cdk\",\n },\n ];\n\n const tagMap = new Map<string, Tag>();\n coreTags.forEach((tag) => tagMap.set(tag.Key, tag));\n\n if (appIdentity) {\n tagMap.set(\"App\", { Key: \"App\", Value: appIdentity.app });\n }\n\n if (additionalTags) {\n additionalTags.forEach((tag) => tagMap.set(tag.Key, tag));\n }\n\n // set `PropagateAtLaunch` if the prop is defined\n if (propagateAtLaunch !== undefined) {\n tagMap.forEach((tag) => {\n tagMap.set(tag.Key, { ...tag, PropagateAtLaunch: propagateAtLaunch });\n });\n }\n\n this.template.hasResourceProperties(type, { Tags: sortTagsByKey(Array.from(tagMap.values())) });\n }\n\n hasResourceWithTag(type: string, tag: Tag) {\n this.template.hasResourceProperties(type, {\n Tags: Match.arrayWith([tag]),\n });\n }\n}\n"]}
|
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": "58.0.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
"gh-pages": "^6.1.1",
|
|
50
50
|
"jest": "^29.7.0",
|
|
51
51
|
"prettier": "^3.2.5",
|
|
52
|
-
"serve": "^14.2.
|
|
52
|
+
"serve": "^14.2.2",
|
|
53
53
|
"ts-jest": "^29.1.2",
|
|
54
54
|
"ts-node": "^10.9.2",
|
|
55
55
|
"typedoc": "^0.25.13",
|
|
56
56
|
"typescript": "5.1.6"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@oclif/core": "3.26.
|
|
60
|
-
"aws-sdk": "^2.
|
|
59
|
+
"@oclif/core": "3.26.4",
|
|
60
|
+
"aws-sdk": "^2.1605.0",
|
|
61
61
|
"chalk": "^4.1.2",
|
|
62
62
|
"codemaker": "^1.97.0",
|
|
63
63
|
"git-url-parse": "^14.0.0",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { IAspect } from "aws-cdk-lib";
|
|
2
|
-
import type { IConstruct } from "constructs";
|
|
3
|
-
/**
|
|
4
|
-
* Applies the tags that enable backups for supported resources.
|
|
5
|
-
*
|
|
6
|
-
* @see https://github.com/guardian/aws-backup
|
|
7
|
-
*/
|
|
8
|
-
export declare class AwsBackupTag implements IAspect {
|
|
9
|
-
/**
|
|
10
|
-
* These resources are backed up by https://github.com/guardian/aws-backup.
|
|
11
|
-
*/
|
|
12
|
-
static resourceTypes: string[];
|
|
13
|
-
visit(node: IConstruct): void;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=aws-backup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aws-backup.d.ts","sourceRoot":"","sources":["../../src/aspects/aws-backup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;GAIG;AACH,qBAAa,YAAa,YAAW,OAAO;IAC1C;;OAEG;IACH,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,CAAoD;IAE3E,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;CASrC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AwsBackupTag = void 0;
|
|
4
|
-
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
|
-
/**
|
|
6
|
-
* Applies the tags that enable backups for supported resources.
|
|
7
|
-
*
|
|
8
|
-
* @see https://github.com/guardian/aws-backup
|
|
9
|
-
*/
|
|
10
|
-
class AwsBackupTag {
|
|
11
|
-
visit(node) {
|
|
12
|
-
if (node instanceof aws_cdk_lib_1.CfnResource) {
|
|
13
|
-
const { cfnResourceType } = node;
|
|
14
|
-
if (AwsBackupTag.resourceTypes.includes(cfnResourceType) && aws_cdk_lib_1.TagManager.isTaggable(node)) {
|
|
15
|
-
node.tags.setTag("devx-backup-enabled", "true");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.AwsBackupTag = AwsBackupTag;
|
|
21
|
-
/**
|
|
22
|
-
* These resources are backed up by https://github.com/guardian/aws-backup.
|
|
23
|
-
*/
|
|
24
|
-
AwsBackupTag.resourceTypes = ["AWS::RDS::DBInstance", "AWS::DynamoDB::Table"];
|
|
25
|
-
//# sourceMappingURL=aws-backup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aws-backup.js","sourceRoot":"","sources":["../../src/aspects/aws-backup.ts"],"names":[],"mappings":";;;AACA,6CAAsD;AAGtD;;;;GAIG;AACH,MAAa,YAAY;IAMhB,KAAK,CAAC,IAAgB;QAC3B,IAAI,IAAI,YAAY,yBAAW,EAAE;YAC/B,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;YAEjC,IAAI,YAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,wBAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBACvF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;aACjD;SACF;IACH,CAAC;;AAdH,oCAeC;AAdC;;GAEG;AACI,0BAAa,GAAa,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import type { IAspect } from \"aws-cdk-lib\";\nimport { CfnResource, TagManager } from \"aws-cdk-lib\";\nimport type { IConstruct } from \"constructs\";\n\n/**\n * Applies the tags that enable backups for supported resources.\n *\n * @see https://github.com/guardian/aws-backup\n */\nexport class AwsBackupTag implements IAspect {\n /**\n * These resources are backed up by https://github.com/guardian/aws-backup.\n */\n static resourceTypes: string[] = [\"AWS::RDS::DBInstance\", \"AWS::DynamoDB::Table\"];\n\n public visit(node: IConstruct): void {\n if (node instanceof CfnResource) {\n const { cfnResourceType } = node;\n\n if (AwsBackupTag.resourceTypes.includes(cfnResourceType) && TagManager.isTaggable(node)) {\n node.tags.setTag(\"devx-backup-enabled\", \"true\");\n }\n }\n }\n}\n"]}
|