1 | ;
|
2 | var _a;
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.Key = exports.KeyUsage = exports.KeySpec = void 0;
|
5 | const jsiiDeprecationWarnings = require("../.warnings.jsii.js");
|
6 | const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
|
7 | const iam = require("@aws-cdk/aws-iam");
|
8 | const cxschema = require("@aws-cdk/cloud-assembly-schema");
|
9 | const core_1 = require("@aws-cdk/core");
|
10 | const cxapi = require("@aws-cdk/cx-api");
|
11 | const constructs_1 = require("constructs");
|
12 | const alias_1 = require("./alias");
|
13 | const kms_generated_1 = require("./kms.generated");
|
14 | const perms = require("./private/perms");
|
15 | class KeyBase extends core_1.Resource {
|
16 | constructor() {
|
17 | super(...arguments);
|
18 | /**
|
19 | * Collection of aliases added to the key
|
20 | *
|
21 | * Tracked to determine whether or not the aliasName should be added to the end of its ID
|
22 | */
|
23 | this.aliases = [];
|
24 | }
|
25 | /**
|
26 | * Defines a new alias for the key.
|
27 | */
|
28 | addAlias(aliasName) {
|
29 | const aliasId = this.aliases.length > 0 ? `Alias${aliasName}` : 'Alias';
|
30 | const alias = new alias_1.Alias(this, aliasId, { aliasName, targetKey: this });
|
31 | this.aliases.push(alias);
|
32 | return alias;
|
33 | }
|
34 | /**
|
35 | * Adds a statement to the KMS key resource policy.
|
36 | * @param statement The policy statement to add
|
37 | * @param allowNoOp If this is set to `false` and there is no policy
|
38 | * defined (i.e. external key), the operation will fail. Otherwise, it will
|
39 | * no-op.
|
40 | */
|
41 | addToResourcePolicy(statement, allowNoOp = true) {
|
42 | const stack = core_1.Stack.of(this);
|
43 | if (!this.policy) {
|
44 | if (allowNoOp) {
|
45 | return { statementAdded: false };
|
46 | }
|
47 | throw new Error(`Unable to add statement to IAM resource policy for KMS key: ${JSON.stringify(stack.resolve(this.keyArn))}`);
|
48 | }
|
49 | this.policy.addStatements(statement);
|
50 | return { statementAdded: true, policyDependable: this.policy };
|
51 | }
|
52 | validate() {
|
53 | const errors = super.validate();
|
54 | errors.push(...this.policy?.validateForResourcePolicy() || []);
|
55 | return errors;
|
56 | }
|
57 | /**
|
58 | * Grant the indicated permissions on this key to the given principal
|
59 | *
|
60 | * This modifies both the principal's policy as well as the resource policy,
|
61 | * since the default CloudFormation setup for KMS keys is that the policy
|
62 | * must not be empty and so default grants won't work.
|
63 | */
|
64 | grant(grantee, ...actions) {
|
65 | // KMS verifies whether the principals included in its key policy actually exist.
|
66 | // This is a problem if the stack the grantee is part of depends on the key stack
|
67 | // (as it won't exist before the key policy is attempted to be created).
|
68 | // In that case, make the account the resource policy principal
|
69 | const granteeStackDependsOnKeyStack = this.granteeStackDependsOnKeyStack(grantee);
|
70 | const principal = granteeStackDependsOnKeyStack
|
71 | ? new iam.AccountPrincipal(granteeStackDependsOnKeyStack)
|
72 | : grantee.grantPrincipal;
|
73 | const crossAccountAccess = this.isGranteeFromAnotherAccount(grantee);
|
74 | const crossRegionAccess = this.isGranteeFromAnotherRegion(grantee);
|
75 | const crossEnvironment = crossAccountAccess || crossRegionAccess;
|
76 | const grantOptions = {
|
77 | grantee,
|
78 | actions,
|
79 | resource: this,
|
80 | resourceArns: [this.keyArn],
|
81 | resourceSelfArns: crossEnvironment ? undefined : ['*'],
|
82 | };
|
83 | if (this.trustAccountIdentities && !crossEnvironment) {
|
84 | return iam.Grant.addToPrincipalOrResource(grantOptions);
|
85 | }
|
86 | else {
|
87 | return iam.Grant.addToPrincipalAndResource({
|
88 | ...grantOptions,
|
89 | // if the key is used in a cross-environment matter,
|
90 | // we can't access the Key ARN (they don't have physical names),
|
91 | // so fall back to using '*'. ToDo we need to make this better... somehow
|
92 | resourceArns: crossEnvironment ? ['*'] : [this.keyArn],
|
93 | resourcePolicyPrincipal: principal,
|
94 | });
|
95 | }
|
96 | }
|
97 | /**
|
98 | * Grant decryption permissions using this key to the given principal
|
99 | */
|
100 | grantDecrypt(grantee) {
|
101 | return this.grant(grantee, ...perms.DECRYPT_ACTIONS);
|
102 | }
|
103 | /**
|
104 | * Grant encryption permissions using this key to the given principal
|
105 | */
|
106 | grantEncrypt(grantee) {
|
107 | return this.grant(grantee, ...perms.ENCRYPT_ACTIONS);
|
108 | }
|
109 | /**
|
110 | * Grant encryption and decryption permissions using this key to the given principal
|
111 | */
|
112 | grantEncryptDecrypt(grantee) {
|
113 | return this.grant(grantee, ...[...perms.DECRYPT_ACTIONS, ...perms.ENCRYPT_ACTIONS]);
|
114 | }
|
115 | /**
|
116 | * Checks whether the grantee belongs to a stack that will be deployed
|
117 | * after the stack containing this key.
|
118 | *
|
119 | * @param grantee the grantee to give permissions to
|
120 | * @returns the account ID of the grantee stack if its stack does depend on this stack,
|
121 | * undefined otherwise
|
122 | */
|
123 | granteeStackDependsOnKeyStack(grantee) {
|
124 | const grantPrincipal = grantee.grantPrincipal;
|
125 | if (!isConstruct(grantPrincipal)) {
|
126 | return undefined;
|
127 | }
|
128 | // this logic should only apply to newly created
|
129 | // (= not imported) resources
|
130 | if (!this.principalIsANewlyCreatedResource(grantPrincipal)) {
|
131 | return undefined;
|
132 | }
|
133 | // return undefined;
|
134 | const keyStack = core_1.Stack.of(this);
|
135 | const granteeStack = core_1.Stack.of(grantPrincipal);
|
136 | if (keyStack === granteeStack) {
|
137 | return undefined;
|
138 | }
|
139 | return granteeStack.dependencies.includes(keyStack)
|
140 | ? granteeStack.account
|
141 | : undefined;
|
142 | }
|
143 | principalIsANewlyCreatedResource(principal) {
|
144 | // yes, this sucks
|
145 | // this is just a temporary stopgap to stem the bleeding while we work on a proper fix
|
146 | return principal instanceof iam.Role ||
|
147 | principal instanceof iam.User ||
|
148 | principal instanceof iam.Group;
|
149 | }
|
150 | isGranteeFromAnotherRegion(grantee) {
|
151 | if (!isConstruct(grantee)) {
|
152 | return false;
|
153 | }
|
154 | const bucketStack = core_1.Stack.of(this);
|
155 | const identityStack = core_1.Stack.of(grantee);
|
156 | return bucketStack.region !== identityStack.region;
|
157 | }
|
158 | isGranteeFromAnotherAccount(grantee) {
|
159 | if (!isConstruct(grantee)) {
|
160 | return false;
|
161 | }
|
162 | const bucketStack = core_1.Stack.of(this);
|
163 | const identityStack = core_1.Stack.of(grantee);
|
164 | return bucketStack.account !== identityStack.account;
|
165 | }
|
166 | }
|
167 | /**
|
168 | * The key spec, represents the cryptographic configuration of keys.
|
169 | */
|
170 | var KeySpec;
|
171 | (function (KeySpec) {
|
172 | /**
|
173 | * The default key spec.
|
174 | *
|
175 | * Valid usage: ENCRYPT_DECRYPT
|
176 | */
|
177 | KeySpec["SYMMETRIC_DEFAULT"] = "SYMMETRIC_DEFAULT";
|
178 | /**
|
179 | * RSA with 2048 bits of key.
|
180 | *
|
181 | * Valid usage: ENCRYPT_DECRYPT and SIGN_VERIFY
|
182 | */
|
183 | KeySpec["RSA_2048"] = "RSA_2048";
|
184 | /**
|
185 | * RSA with 3072 bits of key.
|
186 | *
|
187 | * Valid usage: ENCRYPT_DECRYPT and SIGN_VERIFY
|
188 | */
|
189 | KeySpec["RSA_3072"] = "RSA_3072";
|
190 | /**
|
191 | * RSA with 4096 bits of key.
|
192 | *
|
193 | * Valid usage: ENCRYPT_DECRYPT and SIGN_VERIFY
|
194 | */
|
195 | KeySpec["RSA_4096"] = "RSA_4096";
|
196 | /**
|
197 | * NIST FIPS 186-4, Section 6.4, ECDSA signature using the curve specified by the key and
|
198 | * SHA-256 for the message digest.
|
199 | *
|
200 | * Valid usage: SIGN_VERIFY
|
201 | */
|
202 | KeySpec["ECC_NIST_P256"] = "ECC_NIST_P256";
|
203 | /**
|
204 | * NIST FIPS 186-4, Section 6.4, ECDSA signature using the curve specified by the key and
|
205 | * SHA-384 for the message digest.
|
206 | *
|
207 | * Valid usage: SIGN_VERIFY
|
208 | */
|
209 | KeySpec["ECC_NIST_P384"] = "ECC_NIST_P384";
|
210 | /**
|
211 | * NIST FIPS 186-4, Section 6.4, ECDSA signature using the curve specified by the key and
|
212 | * SHA-512 for the message digest.
|
213 | *
|
214 | * Valid usage: SIGN_VERIFY
|
215 | */
|
216 | KeySpec["ECC_NIST_P521"] = "ECC_NIST_P521";
|
217 | /**
|
218 | * Standards for Efficient Cryptography 2, Section 2.4.1, ECDSA signature on the Koblitz curve.
|
219 | *
|
220 | * Valid usage: SIGN_VERIFY
|
221 | */
|
222 | KeySpec["ECC_SECG_P256K1"] = "ECC_SECG_P256K1";
|
223 | })(KeySpec = exports.KeySpec || (exports.KeySpec = {}));
|
224 | /**
|
225 | * The key usage, represents the cryptographic operations of keys.
|
226 | */
|
227 | var KeyUsage;
|
228 | (function (KeyUsage) {
|
229 | /**
|
230 | * Encryption and decryption.
|
231 | */
|
232 | KeyUsage["ENCRYPT_DECRYPT"] = "ENCRYPT_DECRYPT";
|
233 | /**
|
234 | * Signing and verification
|
235 | */
|
236 | KeyUsage["SIGN_VERIFY"] = "SIGN_VERIFY";
|
237 | })(KeyUsage = exports.KeyUsage || (exports.KeyUsage = {}));
|
238 | /**
|
239 | * Defines a KMS key.
|
240 | *
|
241 | * @resource AWS::KMS::Key
|
242 | */
|
243 | class Key extends KeyBase {
|
244 | constructor(scope, id, props = {}) {
|
245 | super(scope, id);
|
246 | try {
|
247 | jsiiDeprecationWarnings._aws_cdk_aws_kms_KeyProps(props);
|
248 | }
|
249 | catch (error) {
|
250 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
251 | Error.captureStackTrace(error, Key);
|
252 | }
|
253 | throw error;
|
254 | }
|
255 | const denyLists = {
|
256 | [KeyUsage.ENCRYPT_DECRYPT]: [
|
257 | KeySpec.ECC_NIST_P256,
|
258 | KeySpec.ECC_NIST_P384,
|
259 | KeySpec.ECC_NIST_P521,
|
260 | KeySpec.ECC_SECG_P256K1,
|
261 | ],
|
262 | [KeyUsage.SIGN_VERIFY]: [
|
263 | KeySpec.SYMMETRIC_DEFAULT,
|
264 | ],
|
265 | };
|
266 | const keySpec = props.keySpec ?? KeySpec.SYMMETRIC_DEFAULT;
|
267 | const keyUsage = props.keyUsage ?? KeyUsage.ENCRYPT_DECRYPT;
|
268 | if (denyLists[keyUsage].includes(keySpec)) {
|
269 | throw new Error(`key spec '${keySpec}' is not valid with usage '${keyUsage}'`);
|
270 | }
|
271 | if (keySpec !== KeySpec.SYMMETRIC_DEFAULT && props.enableKeyRotation) {
|
272 | throw new Error('key rotation cannot be enabled on asymmetric keys');
|
273 | }
|
274 | const defaultKeyPoliciesFeatureEnabled = core_1.FeatureFlags.of(this).isEnabled(cxapi.KMS_DEFAULT_KEY_POLICIES);
|
275 | this.policy = props.policy ?? new iam.PolicyDocument();
|
276 | if (defaultKeyPoliciesFeatureEnabled) {
|
277 | if (props.trustAccountIdentities === false) {
|
278 | throw new Error('`trustAccountIdentities` cannot be false if the @aws-cdk/aws-kms:defaultKeyPolicies feature flag is set');
|
279 | }
|
280 | this.trustAccountIdentities = true;
|
281 | // Set the default key policy if one hasn't been provided by the user.
|
282 | if (!props.policy) {
|
283 | this.addDefaultAdminPolicy();
|
284 | }
|
285 | }
|
286 | else {
|
287 | this.trustAccountIdentities = props.trustAccountIdentities ?? false;
|
288 | if (this.trustAccountIdentities) {
|
289 | this.addDefaultAdminPolicy();
|
290 | }
|
291 | else {
|
292 | this.addLegacyAdminPolicy();
|
293 | }
|
294 | }
|
295 | let pendingWindowInDays;
|
296 | if (props.pendingWindow) {
|
297 | pendingWindowInDays = props.pendingWindow.toDays();
|
298 | if (pendingWindowInDays < 7 || pendingWindowInDays > 30) {
|
299 | throw new Error(`'pendingWindow' value must between 7 and 30 days. Received: ${pendingWindowInDays}`);
|
300 | }
|
301 | }
|
302 | const resource = new kms_generated_1.CfnKey(this, 'Resource', {
|
303 | description: props.description,
|
304 | enableKeyRotation: props.enableKeyRotation,
|
305 | enabled: props.enabled,
|
306 | keySpec: props.keySpec,
|
307 | keyUsage: props.keyUsage,
|
308 | keyPolicy: this.policy,
|
309 | pendingWindowInDays: pendingWindowInDays,
|
310 | });
|
311 | this.keyArn = resource.attrArn;
|
312 | this.keyId = resource.ref;
|
313 | resource.applyRemovalPolicy(props.removalPolicy);
|
314 | (props.admins ?? []).forEach((p) => this.grantAdmin(p));
|
315 | if (props.alias !== undefined) {
|
316 | this.addAlias(props.alias);
|
317 | }
|
318 | }
|
319 | /**
|
320 | * Import an externally defined KMS Key using its ARN.
|
321 | *
|
322 | * @param scope the construct that will "own" the imported key.
|
323 | * @param id the id of the imported key in the construct tree.
|
324 | * @param keyArn the ARN of an existing KMS key.
|
325 | */
|
326 | static fromKeyArn(scope, id, keyArn) {
|
327 | class Import extends KeyBase {
|
328 | constructor(keyId) {
|
329 | super(scope, id);
|
330 | this.keyArn = keyArn;
|
331 | this.policy = undefined;
|
332 | // defaulting true: if we are importing the key the key policy is
|
333 | // undefined and impossible to change here; this means updating identity
|
334 | // policies is really the only option
|
335 | this.trustAccountIdentities = true;
|
336 | this.keyId = keyId;
|
337 | }
|
338 | }
|
339 | const keyResourceName = core_1.Stack.of(scope).splitArn(keyArn, core_1.ArnFormat.SLASH_RESOURCE_NAME).resourceName;
|
340 | if (!keyResourceName) {
|
341 | throw new Error(`KMS key ARN must be in the format 'arn:aws:kms:<region>:<account>:key/<keyId>', got: '${keyArn}'`);
|
342 | }
|
343 | return new Import(keyResourceName);
|
344 | }
|
345 | /**
|
346 | * Create a mutable {@link IKey} based on a low-level {@link CfnKey}.
|
347 | * This is most useful when combined with the cloudformation-include module.
|
348 | * This method is different than {@link fromKeyArn()} because the {@link IKey}
|
349 | * returned from this method is mutable;
|
350 | * meaning, calling any mutating methods on it,
|
351 | * like {@link IKey.addToResourcePolicy()},
|
352 | * will actually be reflected in the resulting template,
|
353 | * as opposed to the object returned from {@link fromKeyArn()},
|
354 | * on which calling those methods would have no effect.
|
355 | */
|
356 | static fromCfnKey(cfnKey) {
|
357 | try {
|
358 | jsiiDeprecationWarnings._aws_cdk_aws_kms_CfnKey(cfnKey);
|
359 | }
|
360 | catch (error) {
|
361 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
362 | Error.captureStackTrace(error, this.fromCfnKey);
|
363 | }
|
364 | throw error;
|
365 | }
|
366 | // use a "weird" id that has a higher chance of being unique
|
367 | const id = '@FromCfnKey';
|
368 | // if fromCfnKey() was already called on this cfnKey,
|
369 | // return the same L2
|
370 | // (as different L2s would conflict, because of the mutation of the keyPolicy property of the L1 below)
|
371 | const existing = cfnKey.node.tryFindChild(id);
|
372 | if (existing) {
|
373 | return existing;
|
374 | }
|
375 | let keyPolicy;
|
376 | try {
|
377 | keyPolicy = iam.PolicyDocument.fromJson(cfnKey.keyPolicy);
|
378 | }
|
379 | catch (e) {
|
380 | // If the KeyPolicy contains any CloudFormation functions,
|
381 | // PolicyDocument.fromJson() throws an exception.
|
382 | // In that case, because we would have to effectively make the returned IKey immutable,
|
383 | // throw an exception suggesting to use the other importing methods instead.
|
384 | // We might make this parsing logic smarter later,
|
385 | // but let's start by erroring out.
|
386 | throw new Error('Could not parse the PolicyDocument of the passed AWS::KMS::Key resource because it contains CloudFormation functions. ' +
|
387 | 'This makes it impossible to create a mutable IKey from that Policy. ' +
|
388 | 'You have to use fromKeyArn instead, passing it the ARN attribute property of the low-level CfnKey');
|
389 | }
|
390 | // change the key policy of the L1, so that all changes done in the L2 are reflected in the resulting template
|
391 | cfnKey.keyPolicy = core_1.Lazy.any({ produce: () => keyPolicy.toJSON() });
|
392 | return new class extends KeyBase {
|
393 | constructor() {
|
394 | super(...arguments);
|
395 | this.keyArn = cfnKey.attrArn;
|
396 | this.keyId = cfnKey.ref;
|
397 | this.policy = keyPolicy;
|
398 | this.trustAccountIdentities = false;
|
399 | }
|
400 | }(cfnKey, id);
|
401 | }
|
402 | /**
|
403 | * Import an existing Key by querying the AWS environment this stack is deployed to.
|
404 | *
|
405 | * This function only needs to be used to use Keys not defined in your CDK
|
406 | * application. If you are looking to share a Key between stacks, you can
|
407 | * pass the `Key` object between stacks and use it as normal. In addition,
|
408 | * it's not necessary to use this method if an interface accepts an `IKey`.
|
409 | * In this case, `Alias.fromAliasName()` can be used which returns an alias
|
410 | * that extends `IKey`.
|
411 | *
|
412 | * Calling this method will lead to a lookup when the CDK CLI is executed.
|
413 | * You can therefore not use any values that will only be available at
|
414 | * CloudFormation execution time (i.e., Tokens).
|
415 | *
|
416 | * The Key information will be cached in `cdk.context.json` and the same Key
|
417 | * will be used on future runs. To refresh the lookup, you will have to
|
418 | * evict the value from the cache using the `cdk context` command. See
|
419 | * https://docs.aws.amazon.com/cdk/latest/guide/context.html for more information.
|
420 | */
|
421 | static fromLookup(scope, id, options) {
|
422 | try {
|
423 | jsiiDeprecationWarnings._aws_cdk_aws_kms_KeyLookupOptions(options);
|
424 | }
|
425 | catch (error) {
|
426 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
427 | Error.captureStackTrace(error, this.fromLookup);
|
428 | }
|
429 | throw error;
|
430 | }
|
431 | class Import extends KeyBase {
|
432 | constructor(keyId, keyArn) {
|
433 | super(scope, id);
|
434 | this.policy = undefined;
|
435 | // defaulting true: if we are importing the key the key policy is
|
436 | // undefined and impossible to change here; this means updating identity
|
437 | // policies is really the only option
|
438 | this.trustAccountIdentities = true;
|
439 | this.keyId = keyId;
|
440 | this.keyArn = keyArn;
|
441 | }
|
442 | }
|
443 | if (core_1.Token.isUnresolved(options.aliasName)) {
|
444 | throw new Error('All arguments to Key.fromLookup() must be concrete (no Tokens)');
|
445 | }
|
446 | const attributes = core_1.ContextProvider.getValue(scope, {
|
447 | provider: cxschema.ContextProvider.KEY_PROVIDER,
|
448 | props: {
|
449 | aliasName: options.aliasName,
|
450 | },
|
451 | dummyValue: {
|
452 | keyId: '1234abcd-12ab-34cd-56ef-1234567890ab',
|
453 | },
|
454 | }).value;
|
455 | return new Import(attributes.keyId, core_1.Arn.format({ resource: 'key', service: 'kms', resourceName: attributes.keyId }, core_1.Stack.of(scope)));
|
456 | }
|
457 | /**
|
458 | * Grant admins permissions using this key to the given principal
|
459 | *
|
460 | * Key administrators have permissions to manage the key (e.g., change permissions, revoke), but do not have permissions
|
461 | * to use the key in cryptographic operations (e.g., encrypt, decrypt).
|
462 | */
|
463 | grantAdmin(grantee) {
|
464 | return this.grant(grantee, ...perms.ADMIN_ACTIONS);
|
465 | }
|
466 | /**
|
467 | * Adds the default key policy to the key. This policy gives the AWS account (root user) full access to the CMK,
|
468 | * which reduces the risk of the CMK becoming unmanageable and enables IAM policies to allow access to the CMK.
|
469 | * This is the same policy that is default when creating a Key via the KMS API or Console.
|
470 | * @see https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html#key-policy-default
|
471 | */
|
472 | addDefaultAdminPolicy() {
|
473 | this.addToResourcePolicy(new iam.PolicyStatement({
|
474 | resources: ['*'],
|
475 | actions: ['kms:*'],
|
476 | principals: [new iam.AccountRootPrincipal()],
|
477 | }));
|
478 | }
|
479 | /**
|
480 | * Grants the account admin privileges -- not full account access -- plus the GenerateDataKey action.
|
481 | * The GenerateDataKey action was added for interop with S3 in https://github.com/aws/aws-cdk/issues/3458.
|
482 | *
|
483 | * This policy is discouraged and deprecated by the `@aws-cdk/aws-kms:defaultKeyPolicies` feature flag.
|
484 | *
|
485 | * @link https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html#key-policy-default
|
486 | * @deprecated
|
487 | */
|
488 | addLegacyAdminPolicy() {
|
489 | // This is equivalent to `[...perms.ADMIN_ACTIONS, 'kms:GenerateDataKey']`,
|
490 | // but keeping this explicit ordering for backwards-compatibility (changing the ordering causes resource updates)
|
491 | const actions = [
|
492 | 'kms:Create*',
|
493 | 'kms:Describe*',
|
494 | 'kms:Enable*',
|
495 | 'kms:List*',
|
496 | 'kms:Put*',
|
497 | 'kms:Update*',
|
498 | 'kms:Revoke*',
|
499 | 'kms:Disable*',
|
500 | 'kms:Get*',
|
501 | 'kms:Delete*',
|
502 | 'kms:ScheduleKeyDeletion',
|
503 | 'kms:CancelKeyDeletion',
|
504 | 'kms:GenerateDataKey',
|
505 | 'kms:TagResource',
|
506 | 'kms:UntagResource',
|
507 | ];
|
508 | this.addToResourcePolicy(new iam.PolicyStatement({
|
509 | resources: ['*'],
|
510 | actions,
|
511 | principals: [new iam.AccountRootPrincipal()],
|
512 | }));
|
513 | }
|
514 | }
|
515 | exports.Key = Key;
|
516 | _a = JSII_RTTI_SYMBOL_1;
|
517 | Key[_a] = { fqn: "@aws-cdk/aws-kms.Key", version: "1.204.0" };
|
518 | /**
|
519 | * Whether the given object is a Construct
|
520 | *
|
521 | * Normally we'd do `x instanceof Construct`, but that is not robust against
|
522 | * multiple copies of the `constructs` library on disk. This can happen
|
523 | * when upgrading and downgrading between v2 and v1, and in the use of CDK
|
524 | * Pipelines is going to an error that says "Can't use Pipeline/Pipeline/Role in
|
525 | * a cross-environment fashion", which is very confusing.
|
526 | */
|
527 | function isConstruct(x) {
|
528 | const sym = Symbol.for('constructs.Construct.node');
|
529 | return (typeof x === 'object' && x &&
|
530 | (x instanceof constructs_1.Construct // happy fast case
|
531 | || !!x.node // constructs v10
|
532 | || !!x[sym])); // constructs v3
|
533 | }
|
534 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia2V5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsia2V5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLHdDQUF3QztBQUN4QywyREFBMkQ7QUFDM0Qsd0NBQWdKO0FBQ2hKLHlDQUF5QztBQUN6QywyQ0FBbUQ7QUFDbkQsbUNBQWdDO0FBRWhDLG1EQUF5QztBQUN6Qyx5Q0FBeUM7QUF3RHpDLE1BQWUsT0FBUSxTQUFRLGVBQVE7SUFBdkM7O1FBeUJFOzs7O1dBSUc7UUFDYyxZQUFPLEdBQVksRUFBRSxDQUFDO0lBMkp6QyxDQUFDO0lBekpDOztPQUVHO0lBQ0ksUUFBUSxDQUFDLFNBQWlCO1FBQy9CLE1BQU0sT0FBTyxHQUFHLElBQUksQ0FBQyxPQUFPLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsUU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