@guardian/cdk 61.1.4 → 61.3.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/iam/policies/index.d.ts +1 -0
- package/lib/constructs/iam/policies/index.d.ts.map +1 -1
- package/lib/constructs/iam/policies/index.js +1 -0
- package/lib/constructs/iam/policies/index.js.map +1 -1
- package/lib/constructs/iam/policies/kcl.d.ts +17 -0
- package/lib/constructs/iam/policies/kcl.d.ts.map +1 -0
- package/lib/constructs/iam/policies/kcl.js +58 -0
- package/lib/constructs/iam/policies/kcl.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/constructs/iam/policies/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/constructs/iam/policies/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,OAAO,CAAC"}
|
|
@@ -20,6 +20,7 @@ __exportStar(require("./base-policy"), exports);
|
|
|
20
20
|
__exportStar(require("./cloudwatch"), exports);
|
|
21
21
|
__exportStar(require("./describe-ec2"), exports);
|
|
22
22
|
__exportStar(require("./dynamodb"), exports);
|
|
23
|
+
__exportStar(require("./kcl"), exports);
|
|
23
24
|
__exportStar(require("./log-shipping"), exports);
|
|
24
25
|
__exportStar(require("./parameter-store-read"), exports);
|
|
25
26
|
__exportStar(require("./s3-get-object"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/constructs/iam/policies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,+CAA6B;AAC7B,iDAA+B;AAC/B,6CAA2B;AAC3B,iDAA+B;AAC/B,yDAAuC;AACvC,kDAAgC;AAChC,kDAAgC;AAChC,wCAAsB","sourcesContent":["export * from \"./anghammarad\";\nexport * from \"./assume-role\";\nexport * from \"./base-policy\";\nexport * from \"./cloudwatch\";\nexport * from \"./describe-ec2\";\nexport * from \"./dynamodb\";\nexport * from \"./log-shipping\";\nexport * from \"./parameter-store-read\";\nexport * from \"./s3-get-object\";\nexport * from \"./s3-put-object\";\nexport * from \"./ses\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/constructs/iam/policies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,+CAA6B;AAC7B,iDAA+B;AAC/B,6CAA2B;AAC3B,wCAAsB;AACtB,iDAA+B;AAC/B,yDAAuC;AACvC,kDAAgC;AAChC,kDAAgC;AAChC,wCAAsB","sourcesContent":["export * from \"./anghammarad\";\nexport * from \"./assume-role\";\nexport * from \"./base-policy\";\nexport * from \"./cloudwatch\";\nexport * from \"./describe-ec2\";\nexport * from \"./dynamodb\";\nexport * from \"./kcl\";\nexport * from \"./log-shipping\";\nexport * from \"./parameter-store-read\";\nexport * from \"./s3-get-object\";\nexport * from \"./s3-put-object\";\nexport * from \"./ses\";\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GuStack } from "../../core";
|
|
2
|
+
import { GuPolicy } from "./base-policy";
|
|
3
|
+
export interface KCLApplication {
|
|
4
|
+
streamName: string;
|
|
5
|
+
applicationName: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Creates an `AWS::IAM::Policy` to grant all the required permissions for the Kinesis Client Library
|
|
9
|
+
* (https://github.com/awslabs/amazon-kinesis-client) - specifically for KCL v3, which requires many
|
|
10
|
+
* additional permissions over KCL v2.
|
|
11
|
+
*
|
|
12
|
+
* @see https://docs.aws.amazon.com/streams/latest/dev/kcl-iam-permissions.html
|
|
13
|
+
*/
|
|
14
|
+
export declare class GuKCLPolicy extends GuPolicy {
|
|
15
|
+
constructor(scope: GuStack, id: string, props: KCLApplication);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=kcl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kcl.d.ts","sourceRoot":"","sources":["../../../../src/constructs/iam/policies/kcl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACzB;AAuBD;;;;;;GAMG;AACH,qBAAa,WAAY,SAAQ,QAAQ;gBAC3B,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc;CAgC9D"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuKCLPolicy = void 0;
|
|
4
|
+
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
|
5
|
+
const base_policy_1 = require("./base-policy");
|
|
6
|
+
const kinesisActions = [
|
|
7
|
+
"DescribeStream",
|
|
8
|
+
"DescribeStreamSummary",
|
|
9
|
+
"RegisterStreamConsumer",
|
|
10
|
+
"GetRecords",
|
|
11
|
+
"GetShardIterator",
|
|
12
|
+
"ListShards",
|
|
13
|
+
];
|
|
14
|
+
const kinesisEnhancedFanOutActions = ["SubscribeToShard", "DescribeStreamConsumer"];
|
|
15
|
+
const actionsOnAllTables = [
|
|
16
|
+
"Scan",
|
|
17
|
+
"CreateTable",
|
|
18
|
+
"DescribeTable",
|
|
19
|
+
"GetItem",
|
|
20
|
+
"PutItem",
|
|
21
|
+
];
|
|
22
|
+
const additionalLeaseTableActions = ["UpdateTable", "UpdateItem", "DeleteItem"];
|
|
23
|
+
/**
|
|
24
|
+
* Creates an `AWS::IAM::Policy` to grant all the required permissions for the Kinesis Client Library
|
|
25
|
+
* (https://github.com/awslabs/amazon-kinesis-client) - specifically for KCL v3, which requires many
|
|
26
|
+
* additional permissions over KCL v2.
|
|
27
|
+
*
|
|
28
|
+
* @see https://docs.aws.amazon.com/streams/latest/dev/kcl-iam-permissions.html
|
|
29
|
+
*/
|
|
30
|
+
class GuKCLPolicy extends base_policy_1.GuPolicy {
|
|
31
|
+
constructor(scope, id, props) {
|
|
32
|
+
function allow(actionType, actions, resources) {
|
|
33
|
+
return new aws_iam_1.PolicyStatement({
|
|
34
|
+
effect: aws_iam_1.Effect.ALLOW,
|
|
35
|
+
actions: actions.map((a) => `${actionType}:${a}`),
|
|
36
|
+
resources: resources.map((r) => `arn:aws:${actionType}:${scope.region}:${scope.account}:${r}`),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function allowDynamoDB(actions, tableOrIndexNames) {
|
|
40
|
+
return allow("dynamodb", actions, tableOrIndexNames.map((name) => `table/${name}`));
|
|
41
|
+
}
|
|
42
|
+
const leaseTable = props.applicationName;
|
|
43
|
+
const metricsTable = `${props.applicationName}-WorkerMetricStats`;
|
|
44
|
+
const coordinatorTable = `${props.applicationName}-CoordinatorState`;
|
|
45
|
+
super(scope, id, {
|
|
46
|
+
statements: [
|
|
47
|
+
allow("kinesis", kinesisActions, [`stream/${props.streamName}`]),
|
|
48
|
+
allow("kinesis", kinesisEnhancedFanOutActions, [`stream/${props.streamName}/consumer/*`]),
|
|
49
|
+
allowDynamoDB(actionsOnAllTables, [leaseTable, metricsTable, coordinatorTable]),
|
|
50
|
+
allowDynamoDB(additionalLeaseTableActions, [leaseTable]),
|
|
51
|
+
allowDynamoDB(["Query"], [`${leaseTable}/index/*`]),
|
|
52
|
+
allow("cloudwatch", ["PutMetricData"], ["*"]),
|
|
53
|
+
],
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.GuKCLPolicy = GuKCLPolicy;
|
|
58
|
+
//# sourceMappingURL=kcl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kcl.js","sourceRoot":"","sources":["../../../../src/constructs/iam/policies/kcl.ts"],"names":[],"mappings":";;;AAAA,iDAA8D;AAE9D,+CAAyC;AAOzC,MAAM,cAAc,GAAa;IAC/B,gBAAgB;IAChB,uBAAuB;IACvB,wBAAwB;IACxB,YAAY;IACZ,kBAAkB;IAClB,YAAY;CACb,CAAC;AAEF,MAAM,4BAA4B,GAAa,CAAC,kBAAkB,EAAE,wBAAwB,CAAC,CAAC;AAE9F,MAAM,kBAAkB,GAAa;IACnC,MAAM;IACN,aAAa;IACb,eAAe;IACf,SAAS;IACT,SAAS;CACV,CAAC;AAEF,MAAM,2BAA2B,GAAa,CAAC,aAAa,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;AAE1F;;;;;;GAMG;AACH,MAAa,WAAY,SAAQ,sBAAQ;IACvC,YAAY,KAAc,EAAE,EAAU,EAAE,KAAqB;QAC3D,SAAS,KAAK,CAAC,UAAkB,EAAE,OAAiB,EAAE,SAAmB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,CAAC,eAAe,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;aAC9C;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAjCD,kCAiCC","sourcesContent":["import { Effect, PolicyStatement } from \"aws-cdk-lib/aws-iam\";\nimport type { GuStack } from \"../../core\";\nimport { GuPolicy } from \"./base-policy\";\n\nexport interface KCLApplication {\n streamName: string;\n applicationName: string;\n}\n\nconst kinesisActions: string[] = [\n \"DescribeStream\",\n \"DescribeStreamSummary\",\n \"RegisterStreamConsumer\",\n \"GetRecords\",\n \"GetShardIterator\",\n \"ListShards\",\n];\n\nconst kinesisEnhancedFanOutActions: string[] = [\"SubscribeToShard\", \"DescribeStreamConsumer\"];\n\nconst actionsOnAllTables: string[] = [\n \"Scan\",\n \"CreateTable\", // Allow KCL creating the lease, metrics, and coordinator tables - see https://github.com/guardian/cdk/pull/2578#discussion_r1954061397\n \"DescribeTable\",\n \"GetItem\",\n \"PutItem\",\n];\n\nconst additionalLeaseTableActions: string[] = [\"UpdateTable\", \"UpdateItem\", \"DeleteItem\"];\n\n/**\n * Creates an `AWS::IAM::Policy` to grant all the required permissions for the Kinesis Client Library\n * (https://github.com/awslabs/amazon-kinesis-client) - specifically for KCL v3, which requires many\n * additional permissions over KCL v2.\n *\n * @see https://docs.aws.amazon.com/streams/latest/dev/kcl-iam-permissions.html\n */\nexport class GuKCLPolicy extends GuPolicy {\n constructor(scope: GuStack, id: string, props: KCLApplication) {\n function allow(actionType: string, actions: string[], resources: string[]): PolicyStatement {\n return new PolicyStatement({\n effect: Effect.ALLOW,\n actions: actions.map((a) => `${actionType}:${a}`),\n resources: resources.map((r) => `arn:aws:${actionType}:${scope.region}:${scope.account}:${r}`),\n });\n }\n\n function allowDynamoDB(actions: string[], tableOrIndexNames: string[]): PolicyStatement {\n return allow(\n \"dynamodb\",\n actions,\n tableOrIndexNames.map((name) => `table/${name}`),\n );\n }\n\n const leaseTable = props.applicationName;\n const metricsTable = `${props.applicationName}-WorkerMetricStats`;\n const coordinatorTable = `${props.applicationName}-CoordinatorState`;\n\n super(scope, id, {\n statements: [\n allow(\"kinesis\", kinesisActions, [`stream/${props.streamName}`]),\n allow(\"kinesis\", kinesisEnhancedFanOutActions, [`stream/${props.streamName}/consumer/*`]),\n allowDynamoDB(actionsOnAllTables, [leaseTable, metricsTable, coordinatorTable]),\n allowDynamoDB(additionalLeaseTableActions, [leaseTable]),\n allowDynamoDB([\"Query\"], [`${leaseTable}/index/*`]),\n allow(\"cloudwatch\", [\"PutMetricData\"], [\"*\"]),\n ],\n });\n }\n}\n"]}
|