1 | ;
|
2 | var _a;
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.UnknownPrincipal = void 0;
|
5 | const jsiiDeprecationWarnings = require("../.warnings.jsii.js");
|
6 | const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
|
7 | const core_1 = require("@aws-cdk/core");
|
8 | const constructs_1 = require("constructs");
|
9 | /**
|
10 | * A principal for use in resources that need to have a role but it's unknown
|
11 | *
|
12 | * Some resources have roles associated with them which they assume, such as
|
13 | * Lambda Functions, CodeBuild projects, StepFunctions machines, etc.
|
14 | *
|
15 | * When those resources are imported, their actual roles are not always
|
16 | * imported with them. When that happens, we use an instance of this class
|
17 | * instead, which will add user warnings when statements are attempted to be
|
18 | * added to it.
|
19 | */
|
20 | class UnknownPrincipal {
|
21 | constructor(props) {
|
22 | this.assumeRoleAction = 'sts:AssumeRole';
|
23 | try {
|
24 | jsiiDeprecationWarnings._aws_cdk_aws_iam_UnknownPrincipalProps(props);
|
25 | }
|
26 | catch (error) {
|
27 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
28 | Error.captureStackTrace(error, UnknownPrincipal);
|
29 | }
|
30 | throw error;
|
31 | }
|
32 | this.resource = props.resource;
|
33 | this.grantPrincipal = this;
|
34 | }
|
35 | get policyFragment() {
|
36 | throw new Error(`Cannot get policy fragment of ${constructs_1.Node.of(this.resource).path}, resource imported without a role`);
|
37 | }
|
38 | addToPrincipalPolicy(statement) {
|
39 | try {
|
40 | jsiiDeprecationWarnings._aws_cdk_aws_iam_PolicyStatement(statement);
|
41 | }
|
42 | catch (error) {
|
43 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
44 | Error.captureStackTrace(error, this.addToPrincipalPolicy);
|
45 | }
|
46 | throw error;
|
47 | }
|
48 | const stack = core_1.Stack.of(this.resource);
|
49 | const repr = JSON.stringify(stack.resolve(statement));
|
50 | core_1.Annotations.of(this.resource).addWarning(`Add statement to this resource's role: ${repr}`);
|
51 | // Pretend we did the work. The human will do it for us, eventually.
|
52 | return { statementAdded: true, policyDependable: new core_1.ConcreteDependable() };
|
53 | }
|
54 | addToPolicy(statement) {
|
55 | try {
|
56 | jsiiDeprecationWarnings._aws_cdk_aws_iam_PolicyStatement(statement);
|
57 | }
|
58 | catch (error) {
|
59 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
60 | Error.captureStackTrace(error, this.addToPolicy);
|
61 | }
|
62 | throw error;
|
63 | }
|
64 | return this.addToPrincipalPolicy(statement).statementAdded;
|
65 | }
|
66 | }
|
67 | exports.UnknownPrincipal = UnknownPrincipal;
|
68 | _a = JSII_RTTI_SYMBOL_1;
|
69 | UnknownPrincipal[_a] = { fqn: "@aws-cdk/aws-iam.UnknownPrincipal", version: "1.204.0" };
|
70 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW5rbm93bi1wcmluY2lwYWwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ1bmtub3duLXByaW5jaXBhbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSx3Q0FBdUU7QUFDdkUsMkNBQThDO0FBYzlDOzs7Ozs7Ozs7O0dBVUc7QUFDSCxNQUFhLGdCQUFnQjtJQUszQixZQUFZLEtBQTRCO1FBSnhCLHFCQUFnQixHQUFXLGdCQUFnQixDQUFDOzs7Ozs7K0NBRGpELGdCQUFnQjs7OztRQU16QixJQUFJLENBQUMsUUFBUSxHQUFHLEtBQUssQ0FBQyxRQUFRLENBQUM7UUFDL0IsSUFBSSxDQUFDLGNBQWMsR0FBRyxJQUFJLENBQUM7S0FDNUI7SUFFRCxJQUFXLGNBQWM7UUFDdkIsTUFBTSxJQUFJLEtBQUssQ0FBQyxpQ0FBaUMsaUJBQUksQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxDQUFDLElBQUksb0NBQW9DLENBQUMsQ0FBQzt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