@kensio/yulin 1.20.14 → 1.20.16

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.
Files changed (154) hide show
  1. package/README.md +13 -0
  2. package/{dist/config/oxlint/cffjs2.oxlintrc.json → cffjs2.oxlintrc.json} +1 -1
  3. package/dist/config/oxlint/cffjs2.oxlint.config.js +4 -3
  4. package/dist/sdk/module/sim-sdk-module-client-interceptor.d.ts +5 -0
  5. package/dist/sdk/module/sim-sdk-module-client-interceptor.js +14 -0
  6. package/dist/sdk/module/sim-sdk-static-client-factory.d.ts +26 -0
  7. package/dist/sdk/module/sim-sdk-static-client-factory.js +59 -0
  8. package/dist/sdk/send-patch.d.ts +8 -0
  9. package/dist/sdk/send-patch.js +11 -0
  10. package/dist/service/aws/caller/sim-aws-caller-resolver.d.ts +28 -6
  11. package/dist/service/aws/caller/sim-aws-caller-resolver.js +18 -11
  12. package/dist/service/aws/caller/sim-aws-caller.d.ts +9 -0
  13. package/dist/service/aws/caller/sim-aws-resolved-caller.d.ts +19 -0
  14. package/dist/service/aws/caller/sim-aws-resolved-caller.js +26 -0
  15. package/dist/service/aws/factory/sim-aws-account-region-service-builder.d.ts +6 -0
  16. package/dist/service/aws/factory/sim-aws-account-region-service-builder.js +3 -0
  17. package/dist/service/aws/factory/sim-aws-account-service-cache.d.ts +6 -0
  18. package/dist/service/aws/factory/sim-aws-account-service-cache.js +5 -0
  19. package/dist/service/aws/factory/sim-aws-service-factory.d.ts +5 -0
  20. package/dist/service/aws/factory/sim-aws-service-factory.js +6 -0
  21. package/dist/service/aws/sim-aws-properties.d.ts +15 -0
  22. package/dist/service/aws/sim-aws.js +2 -1
  23. package/dist/service/cloudformation/resource/resolve/property/sim-cfn-resource-property-resolver.d.ts +11 -4
  24. package/dist/service/cloudformation/resource/resolve/property/sim-cfn-resource-property-resolver.js +21 -8
  25. package/dist/service/cloudformation/resource/sim-cfn-resource.type.d.ts +9 -0
  26. package/dist/service/cloudformation/template/dynamic/make-sim-cfn-dynamic-references.d.ts +2 -0
  27. package/dist/service/cloudformation/template/dynamic/make-sim-cfn-dynamic-references.js +2 -2
  28. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-reference-resolvers.d.ts +10 -0
  29. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-reference-resolvers.js +4 -3
  30. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-reference-scan.d.ts +11 -0
  31. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-reference-scan.js +21 -0
  32. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-references.d.ts +24 -2
  33. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-references.js +50 -11
  34. package/dist/service/cloudformation/template/dynamic/sim-cfn-prefetched-dynamic-references.d.ts +42 -0
  35. package/dist/service/cloudformation/template/dynamic/sim-cfn-prefetched-dynamic-references.js +80 -0
  36. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-failures.d.ts +16 -0
  37. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-failures.js +19 -0
  38. package/dist/service/iam/authorize/context/sim-iam-auth-z-caller-context-builder.d.ts +30 -7
  39. package/dist/service/iam/authorize/context/sim-iam-auth-z-caller-context-builder.js +20 -11
  40. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.d.ts +2 -1
  41. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.js +5 -1
  42. package/dist/service/iam/authorize/match/sim-iam-policy-principal-matcher.d.ts +10 -0
  43. package/dist/service/iam/authorize/match/sim-iam-policy-principal-matcher.js +15 -3
  44. package/dist/service/iam/authorize/sim-iam-account-auth-z.d.ts +11 -4
  45. package/dist/service/iam/authorize/sim-iam-account-auth-z.js +5 -3
  46. package/dist/service/iam/authorize/sim-iam-authorizer.d.ts +2 -1
  47. package/dist/service/iam/authorize/sim-iam-authorizer.js +1 -0
  48. package/dist/service/iam/command/policy/create-policy/create-policy-input-resolver.js +4 -1
  49. package/dist/service/iam/command/policy/put-role-policy/put-role-policy.handler.js +5 -1
  50. package/dist/service/iam/command/policy/put-user-policy/put-user-policy.handler.js +5 -1
  51. package/dist/service/iam/policy/parse/sim-iam-document-parser.d.ts +4 -1
  52. package/dist/service/iam/policy/parse/sim-iam-document-parser.js +13 -15
  53. package/dist/service/iam/policy/sim-iam-statement-label.d.ts +28 -0
  54. package/dist/service/iam/policy/sim-iam-statement-label.js +17 -0
  55. package/dist/service/iam/policy/sim-iam-statement-strings.d.ts +11 -0
  56. package/dist/service/iam/policy/sim-iam-statement-strings.js +27 -0
  57. package/dist/service/iam/role/sim-iam-role-with-policy.factory.d.ts +9 -0
  58. package/dist/service/iam/role/sim-iam-role-with-policy.factory.js +4 -2
  59. package/dist/service/iam/sim-iam-account-parts.d.ts +8 -0
  60. package/dist/service/iam/sim-iam-account-parts.js +1 -0
  61. package/dist/service/iam/validate/sim-iam-policy-document-validator.d.ts +9 -2
  62. package/dist/service/iam/validate/sim-iam-policy-document-validator.js +37 -19
  63. package/dist/service/lambda/function/code/sim-lambda-vm-zip-function.factory.d.ts +7 -0
  64. package/dist/service/lambda/function/code/sim-lambda-vm-zip-function.factory.js +1 -0
  65. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-provided-sdk-module.d.ts +19 -0
  66. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-provided-sdk-module.js +78 -0
  67. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-sdk-packages-not-installed.error.d.ts +15 -0
  68. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-sdk-packages-not-installed.error.js +27 -0
  69. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-vm-sdk-module-provider.d.ts +9 -0
  70. package/dist/service/lambda/function/code/vm/sdk/sim-sdk-lambda-vm-module-provider.d.ts +10 -0
  71. package/dist/service/lambda/function/code/vm/sdk/sim-sdk-lambda-vm-module-provider.js +28 -34
  72. package/dist/service/lambda/function/code/vm/sim-lambda-host-modules.d.ts +15 -0
  73. package/dist/service/lambda/function/code/vm/sim-lambda-host-modules.js +31 -0
  74. package/dist/service/lambda/function/code/vm/sim-lambda-vm-module-resolver.d.ts +7 -0
  75. package/dist/service/lambda/function/code/vm/sim-lambda-vm-module-resolver.js +15 -0
  76. package/dist/service/lambda/function/code/vm/sim-lambda-vm-modules.js +5 -4
  77. package/dist/service/s3/command/put-bucket-policy/put-bucket-policy.handler.js +4 -1
  78. package/dist/service/scheduler/delivery/sim-scheduler-delivery-failures.d.ts +16 -0
  79. package/dist/service/scheduler/delivery/sim-scheduler-delivery-failures.js +19 -0
  80. package/dist/service/scheduler/index.d.ts +1 -1
  81. package/dist/service/scheduler/index.js +1 -1
  82. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-dynamic-reference-resolver.d.ts +13 -15
  83. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-dynamic-reference-resolver.js +22 -43
  84. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-reference-stand-in.d.ts +9 -0
  85. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-reference-stand-in.js +14 -0
  86. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-reference-value.d.ts +12 -0
  87. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-reference-value.js +29 -0
  88. package/dist/service/ssm/cfn/dynamic/sim-cfn-ssm-dynamic-reference-resolver.d.ts +22 -6
  89. package/dist/service/ssm/cfn/dynamic/sim-cfn-ssm-dynamic-reference-resolver.js +39 -24
  90. package/dist/service/ssm/cfn/dynamic/sim-cfn-ssm-secure-dynamic-reference-resolver.d.ts +10 -5
  91. package/dist/service/ssm/cfn/dynamic/sim-cfn-ssm-secure-dynamic-reference-resolver.js +10 -8
  92. package/dist/service/ssm/sim-ssm.d.ts +10 -2
  93. package/dist/service/ssm/sim-ssm.js +12 -4
  94. package/dist/service/sts/auth-z/assume-role-auth-z-coordinator.d.ts +9 -2
  95. package/dist/service/sts/auth-z/assume-role-auth-z-coordinator.js +2 -2
  96. package/dist/service/sts/auth-z/assume-role-source-account-auth-z.d.ts +10 -4
  97. package/dist/service/sts/auth-z/assume-role-source-account-auth-z.js +8 -7
  98. package/dist/service/sts/auth-z/assume-role-target-auth-z.d.ts +2 -2
  99. package/dist/service/sts/auth-z/assume-role-trust-policy-authorizer.d.ts +6 -2
  100. package/dist/service/sts/auth-z/assume-role-trust-policy-authorizer.js +14 -11
  101. package/dist/service/sts/command/assume-role/assume-role.handler.d.ts +5 -1
  102. package/dist/service/sts/command/assume-role/assume-role.handler.js +5 -2
  103. package/dist/service/sts/command/get-caller-identity/get-caller-identity.handler.d.ts +5 -1
  104. package/dist/service/sts/command/get-caller-identity/get-caller-identity.handler.js +4 -1
  105. package/dist/service/sts/service-role/sim-service-role.js +5 -1
  106. package/dist/service/sts/sim-sts.d.ts +9 -1
  107. package/dist/service/sts/sim-sts.js +4 -0
  108. package/docs/README.md +54 -0
  109. package/docs/ai-skill/README.md +69 -0
  110. package/docs/cli/README.md +284 -0
  111. package/docs/factories/README.md +140 -0
  112. package/docs/lint/README.md +176 -0
  113. package/docs/non-aws-dependencies/README.md +261 -0
  114. package/docs/sdk/README.md +272 -0
  115. package/docs/serve/README.md +1126 -0
  116. package/docs/services/acm/README.md +823 -0
  117. package/docs/services/apigateway/README.md +1919 -0
  118. package/docs/services/apigatewayv2/README.md +2678 -0
  119. package/docs/services/athena/README.md +1044 -0
  120. package/docs/services/bedrock/README.md +350 -0
  121. package/docs/services/cloudformation/README.md +3440 -0
  122. package/docs/services/cloudfront/README.md +2874 -0
  123. package/docs/services/cloudwatch/README.md +420 -0
  124. package/docs/services/cognito/README.md +4923 -0
  125. package/docs/services/dynamodb/README.md +3784 -0
  126. package/docs/services/ecr/README.md +302 -0
  127. package/docs/services/ecs/README.md +2010 -0
  128. package/docs/services/elbv2/README.md +1897 -0
  129. package/docs/services/eventbridge/README.md +1110 -0
  130. package/docs/services/firehose/README.md +805 -0
  131. package/docs/services/glue/README.md +501 -0
  132. package/docs/services/iam/README.md +1283 -0
  133. package/docs/services/kinesis/README.md +454 -0
  134. package/docs/services/kms/README.md +659 -0
  135. package/docs/services/lambda/README.md +3645 -0
  136. package/docs/services/logs/README.md +868 -0
  137. package/docs/services/organizations/README.md +574 -0
  138. package/docs/services/personalize/README.md +835 -0
  139. package/docs/services/rekognition/README.md +1070 -0
  140. package/docs/services/route53/README.md +1783 -0
  141. package/docs/services/s3/README.md +3024 -0
  142. package/docs/services/scheduler/README.md +806 -0
  143. package/docs/services/secretsmanager/README.md +667 -0
  144. package/docs/services/ses/README.md +1011 -0
  145. package/docs/services/sns/README.md +1904 -0
  146. package/docs/services/sqs/README.md +1185 -0
  147. package/docs/services/ssm/README.md +1072 -0
  148. package/docs/services/stepfunctions/README.md +1332 -0
  149. package/docs/services/sts/README.md +245 -0
  150. package/docs/services/wafv2/README.md +1378 -0
  151. package/docs/terraform/README.md +248 -0
  152. package/docs/time/README.md +284 -0
  153. package/llms.txt +59 -0
  154. package/package.json +9 -5
@@ -0,0 +1,12 @@
1
+ import type { SimCfnResourceCallerOptions } from "../../../cloudformation/resource/caller/sim-cfn-resource-caller-options.js";
2
+ import type { SimSecretsManager } from "../../sim-secrets-manager.js";
3
+ import { type SimCfnSecretsManagerReference } from "./sim-cfn-secrets-manager-reference-body.js";
4
+ /**
5
+ * The secret value one parsed reference names.
6
+ *
7
+ * The version the reference selects, or the current one, read through the
8
+ * ordinary GetSecretValue command as the principal the deployment named. That
9
+ * decrypts the version through simulated KMS, which is why reading a secret
10
+ * has to be waited on.
11
+ */
12
+ export declare function simCfnSecretsManagerReferenceValue(secretsManager: SimSecretsManager, reference: SimCfnSecretsManagerReference, callerOptions: SimCfnResourceCallerOptions): Promise<string>;
@@ -0,0 +1,29 @@
1
+ import { simCfnSecretsManagerJsonKeyValue } from "./sim-cfn-secrets-manager-json-key.js";
2
+ import { SimCfnSecretsManagerReferenceProblem, } from "./sim-cfn-secrets-manager-reference-body.js";
3
+ /**
4
+ * The secret value one parsed reference names.
5
+ *
6
+ * The version the reference selects, or the current one, read through the
7
+ * ordinary GetSecretValue command as the principal the deployment named. That
8
+ * decrypts the version through simulated KMS, which is why reading a secret
9
+ * has to be waited on.
10
+ */
11
+ export async function simCfnSecretsManagerReferenceValue(secretsManager, reference, callerOptions) {
12
+ const { secretId, jsonKey, versionStage, versionId } = reference;
13
+ const read = await secretsManager.getSecretValue({
14
+ input: {
15
+ SecretId: secretId,
16
+ VersionStage: versionStage,
17
+ VersionId: versionId,
18
+ },
19
+ }, callerOptions);
20
+ const secretString = read.SecretString;
21
+ if (secretString === undefined) {
22
+ throw new SimCfnSecretsManagerReferenceProblem(`and '${secretId}' holds a binary value, which a dynamic reference ` +
23
+ `cannot read`);
24
+ }
25
+ if (jsonKey === undefined) {
26
+ return secretString;
27
+ }
28
+ return simCfnSecretsManagerJsonKeyValue(secretString, secretId, jsonKey);
29
+ }
@@ -1,16 +1,26 @@
1
+ import type { SimAwsCaller } from "../../../aws/caller/sim-aws-caller.js";
1
2
  import type { SimCfnDynamicReference, SimCfnDynamicReferenceResolution, SimCfnDynamicReferenceResolver } from "../../../cloudformation/template/dynamic/sim-cfn-dynamic-reference.type.js";
2
3
  import type { SimSsm } from "../../sim-ssm.js";
3
4
  interface SimCfnSsmDynamicReferenceResolverProperties {
4
5
  readonly ssm: SimSsm;
6
+ /** The principal the deployment runs as, which the parameter is read as. */
7
+ readonly caller?: SimAwsCaller | undefined;
5
8
  }
6
9
  /**
7
10
  * Answers `{{resolve:ssm:...}}` references from the simulated Parameter Store.
8
11
  *
9
- * A reference is read as the caller deploying the Stack would read it, at the
10
- * point the Resource holding it is created. Real CloudFormation makes no
11
- * dependency out of a dynamic reference, so a parameter another Resource of
12
- * the same Stack creates is only there in time if the template says
13
- * `DependsOn`.
12
+ * The parameter is read the way `GetParameter` reads it, as the principal the
13
+ * deployment names, so a caller that may not read it is denied here and the
14
+ * Resource fails. That is the failure a real deployment hits, where the read
15
+ * runs under the Stack's execution role. A deployment naming no principal
16
+ * reads as the Account root, which is Parameter Store's own default. Reading
17
+ * through the Command means waiting on it, so the answer comes back as a
18
+ * promise for the CloudFormation engine to wait on.
19
+ *
20
+ * A reference is read at the point the Resource holding it is created. Real
21
+ * CloudFormation makes no dependency out of a dynamic reference, so a
22
+ * parameter another Resource of the same Stack creates is only there in time
23
+ * if the template says `DependsOn`.
14
24
  *
15
25
  * Anything Parameter Store cannot answer becomes a stand-in value carrying a
16
26
  * reason. A template naming parameters a test never created still deploys, and
@@ -18,14 +28,20 @@ interface SimCfnSsmDynamicReferenceResolverProperties {
18
28
  */
19
29
  export declare class SimCfnSsmDynamicReferenceResolver implements SimCfnDynamicReferenceResolver {
20
30
  private readonly ssm;
31
+ private readonly callerOptions;
21
32
  constructor(properties: SimCfnSsmDynamicReferenceResolverProperties);
22
33
  /**
23
34
  * Resolve one reference to the parameter value it names.
24
35
  */
25
- resolve(reference: SimCfnDynamicReference): SimCfnDynamicReferenceResolution;
36
+ resolve(reference: SimCfnDynamicReference): SimCfnDynamicReferenceResolution | Promise<SimCfnDynamicReferenceResolution>;
26
37
  /**
27
38
  * Read the version the reference selects, or the current one.
28
39
  */
29
40
  private parameterValue;
41
+ /**
42
+ * The value the read reports, unless it is a ciphertext this reference has
43
+ * no business handing to a Resource.
44
+ */
45
+ private readValue;
30
46
  }
31
47
  export {};
@@ -1,14 +1,25 @@
1
- import { SimSsmParameterVersionNotFound } from "../../error/sim-ssm.error.js";
1
+ import { assertDefined } from "../../../../util/type-guard/defined.js";
2
+ import { simCfnResourceCallerOptions, } from "../../../cloudformation/resource/caller/sim-cfn-resource-caller-options.js";
3
+ import { SimSsmError } from "../../error/sim-ssm.error.js";
2
4
  import { parseSimCfnSsmReferenceBody } from "./sim-cfn-ssm-reference-body.js";
3
5
  import { simCfnSsmReferenceStandIn } from "./sim-cfn-ssm-reference-stand-in.js";
6
+ /** The parameter type a plain `ssm` reference leaves to `ssm-secure`. */
7
+ const secureString = "SecureString";
4
8
  /**
5
9
  * Answers `{{resolve:ssm:...}}` references from the simulated Parameter Store.
6
10
  *
7
- * A reference is read as the caller deploying the Stack would read it, at the
8
- * point the Resource holding it is created. Real CloudFormation makes no
9
- * dependency out of a dynamic reference, so a parameter another Resource of
10
- * the same Stack creates is only there in time if the template says
11
- * `DependsOn`.
11
+ * The parameter is read the way `GetParameter` reads it, as the principal the
12
+ * deployment names, so a caller that may not read it is denied here and the
13
+ * Resource fails. That is the failure a real deployment hits, where the read
14
+ * runs under the Stack's execution role. A deployment naming no principal
15
+ * reads as the Account root, which is Parameter Store's own default. Reading
16
+ * through the Command means waiting on it, so the answer comes back as a
17
+ * promise for the CloudFormation engine to wait on.
18
+ *
19
+ * A reference is read at the point the Resource holding it is created. Real
20
+ * CloudFormation makes no dependency out of a dynamic reference, so a
21
+ * parameter another Resource of the same Stack creates is only there in time
22
+ * if the template says `DependsOn`.
12
23
  *
13
24
  * Anything Parameter Store cannot answer becomes a stand-in value carrying a
14
25
  * reason. A template naming parameters a test never created still deploys, and
@@ -16,8 +27,10 @@ import { simCfnSsmReferenceStandIn } from "./sim-cfn-ssm-reference-stand-in.js";
16
27
  */
17
28
  export class SimCfnSsmDynamicReferenceResolver {
18
29
  ssm;
30
+ callerOptions;
19
31
  constructor(properties) {
20
32
  this.ssm = properties.ssm;
33
+ this.callerOptions = simCfnResourceCallerOptions(properties.caller);
21
34
  }
22
35
  /**
23
36
  * Resolve one reference to the parameter value it names.
@@ -28,33 +41,35 @@ export class SimCfnSsmDynamicReferenceResolver {
28
41
  return simCfnSsmReferenceStandIn(reference, reference.body, `which is not the parameter name, optionally followed by an integer ` +
29
42
  `version, that an ssm dynamic reference takes`);
30
43
  }
31
- const { name, version } = parsed;
32
- const parameter = this.ssm.findParameter(name);
33
- if (parameter === undefined) {
34
- return simCfnSsmReferenceStandIn(reference, name, `and simulated Parameter Store holds no parameter '${name}'`);
35
- }
36
- if (parameter.type.value === "SecureString") {
37
- return simCfnSsmReferenceStandIn(reference, name, `and '${name}' is a SecureString, which real CloudFormation reads ` +
38
- `through an ssm-secure reference`);
39
- }
40
- return this.parameterValue(reference, parameter, name, version);
44
+ return this.parameterValue(reference, parsed.name, parsed.version);
41
45
  }
42
46
  /**
43
47
  * Read the version the reference selects, or the current one.
44
48
  */
45
- parameterValue(reference, parameter, name, version) {
46
- if (version === undefined) {
47
- return { value: parameter.currentVersion.value.value };
48
- }
49
+ async parameterValue(reference, name, version) {
50
+ const selector = version === undefined ? name : `${name}:${version}`;
49
51
  try {
50
- return { value: parameter.versionNumbered(Number(version)).value.value };
52
+ const read = await this.ssm.getParameter({ input: { Name: selector } }, this.callerOptions);
53
+ assertDefined(read.Parameter, `the parameter read for '${name}'`);
54
+ return this.readValue(reference, name, read.Parameter);
51
55
  }
52
56
  catch (error) {
53
- /* v8 ignore next 3 -- defensive: only a missing version reaches here */
54
- if (!(error instanceof SimSsmParameterVersionNotFound)) {
57
+ if (!(error instanceof SimSsmError)) {
55
58
  throw error;
56
59
  }
57
- return simCfnSsmReferenceStandIn(reference, name, `and '${name}' has no version ${version}`);
60
+ return simCfnSsmReferenceStandIn(reference, name, `and simulated Parameter Store could not read it (${error.message})`);
61
+ }
62
+ }
63
+ /**
64
+ * The value the read reports, unless it is a ciphertext this reference has
65
+ * no business handing to a Resource.
66
+ */
67
+ readValue(reference, name, parameter) {
68
+ if (parameter.Type === secureString) {
69
+ return simCfnSsmReferenceStandIn(reference, name, `and '${name}' is a SecureString, which real CloudFormation reads ` +
70
+ `through an ssm-secure reference`);
58
71
  }
72
+ assertDefined(parameter.Value, `the value read for '${name}'`);
73
+ return { value: parameter.Value };
59
74
  }
60
75
  }
@@ -1,18 +1,22 @@
1
+ import type { SimAwsCaller } from "../../../aws/caller/sim-aws-caller.js";
1
2
  import type { SimCfnDynamicReference, SimCfnDynamicReferenceResolution, SimCfnDynamicReferenceResolver, SimCfnDynamicReferenceSite } from "../../../cloudformation/template/dynamic/sim-cfn-dynamic-reference.type.js";
2
3
  import type { SimSsm } from "../../sim-ssm.js";
3
4
  interface SimCfnSsmSecureDynamicReferenceResolverProperties {
4
5
  readonly ssm: SimSsm;
6
+ /** The principal the deployment runs as, which the parameter is read as. */
7
+ readonly caller?: SimAwsCaller | undefined;
5
8
  }
6
9
  /**
7
10
  * Answers `{{resolve:ssm-secure:...}}` references from the simulated Parameter
8
11
  * Store.
9
12
  *
10
13
  * The parameter is read the way `GetParameter` with `WithDecryption` reads it,
11
- * as the caller deploying the Stack, so the value comes back decrypted through
12
- * the simulated KMS key it was written under. A caller the key does not admit
13
- * is denied here, which is the failure a real deployment hits. Decrypting
14
- * cannot be done synchronously, so the answer comes back as a promise for the
15
- * CloudFormation engine to wait on.
14
+ * as the principal the deployment names, so the value comes back decrypted
15
+ * through the simulated KMS key it was written under. A caller the key does
16
+ * not admit is denied here, which is the failure a real deployment hits. A
17
+ * deployment naming no principal reads as the Account root, which is Parameter
18
+ * Store's own default. Decrypting cannot be done synchronously, so the answer
19
+ * comes back as a promise for the CloudFormation engine to wait on.
16
20
  *
17
21
  * A reference the template had no business writing fails the Resource, which
18
22
  * `sim-cfn-ssm-secure-refusals.ts` holds the rules for. Everything else
@@ -22,6 +26,7 @@ interface SimCfnSsmSecureDynamicReferenceResolverProperties {
22
26
  */
23
27
  export declare class SimCfnSsmSecureDynamicReferenceResolver implements SimCfnDynamicReferenceResolver {
24
28
  private readonly ssm;
29
+ private readonly callerOptions;
25
30
  constructor(properties: SimCfnSsmSecureDynamicReferenceResolverProperties);
26
31
  /**
27
32
  * Resolve one reference to the decrypted parameter value it names.
@@ -1,4 +1,5 @@
1
1
  import { assertDefined } from "../../../../util/type-guard/defined.js";
2
+ import { simCfnResourceCallerOptions, } from "../../../cloudformation/resource/caller/sim-cfn-resource-caller-options.js";
2
3
  import { SimSsmError } from "../../error/sim-ssm.error.js";
3
4
  import { parseSimCfnSsmReferenceBody } from "./sim-cfn-ssm-reference-body.js";
4
5
  import { simCfnSsmReferenceStandIn } from "./sim-cfn-ssm-reference-stand-in.js";
@@ -8,11 +9,12 @@ import { requireSecureStringParameter, requireSsmSecureReferenceProperty, } from
8
9
  * Store.
9
10
  *
10
11
  * The parameter is read the way `GetParameter` with `WithDecryption` reads it,
11
- * as the caller deploying the Stack, so the value comes back decrypted through
12
- * the simulated KMS key it was written under. A caller the key does not admit
13
- * is denied here, which is the failure a real deployment hits. Decrypting
14
- * cannot be done synchronously, so the answer comes back as a promise for the
15
- * CloudFormation engine to wait on.
12
+ * as the principal the deployment names, so the value comes back decrypted
13
+ * through the simulated KMS key it was written under. A caller the key does
14
+ * not admit is denied here, which is the failure a real deployment hits. A
15
+ * deployment naming no principal reads as the Account root, which is Parameter
16
+ * Store's own default. Decrypting cannot be done synchronously, so the answer
17
+ * comes back as a promise for the CloudFormation engine to wait on.
16
18
  *
17
19
  * A reference the template had no business writing fails the Resource, which
18
20
  * `sim-cfn-ssm-secure-refusals.ts` holds the rules for. Everything else
@@ -22,8 +24,10 @@ import { requireSecureStringParameter, requireSsmSecureReferenceProperty, } from
22
24
  */
23
25
  export class SimCfnSsmSecureDynamicReferenceResolver {
24
26
  ssm;
27
+ callerOptions;
25
28
  constructor(properties) {
26
29
  this.ssm = properties.ssm;
30
+ this.callerOptions = simCfnResourceCallerOptions(properties.caller);
27
31
  }
28
32
  /**
29
33
  * Resolve one reference to the decrypted parameter value it names.
@@ -47,9 +51,7 @@ export class SimCfnSsmSecureDynamicReferenceResolver {
47
51
  async decrypted(reference, name, version) {
48
52
  const selector = version === undefined ? name : `${name}:${version}`;
49
53
  try {
50
- const read = await this.ssm.getParameter({
51
- input: { Name: selector, WithDecryption: true },
52
- });
54
+ const read = await this.ssm.getParameter({ input: { Name: selector, WithDecryption: true } }, this.callerOptions);
53
55
  const parameter = read.Parameter;
54
56
  assertDefined(parameter, `the parameter read for '${name}'`);
55
57
  requireSecureStringParameter(name, parameter);
@@ -86,12 +86,20 @@ export declare class SimSsm {
86
86
  cfnResourceFactory(): SimSsmCfnResourceFactory;
87
87
  /**
88
88
  * Get the resolver for `{{resolve:ssm:...}}` dynamic references.
89
+ *
90
+ * The caller is the principal the deployment holding the reference runs as,
91
+ * which the parameter is read as. Left out where the deployment named none,
92
+ * leaving the read as the Account root.
89
93
  */
90
- cfnDynamicReferenceResolver(): SimCfnSsmDynamicReferenceResolver;
94
+ cfnDynamicReferenceResolver(caller?: SimAwsCaller): SimCfnSsmDynamicReferenceResolver;
91
95
  /**
92
96
  * Get the resolver for `{{resolve:ssm-secure:...}}` dynamic references.
97
+ *
98
+ * The caller is the principal the deployment holding the reference runs as,
99
+ * which the parameter is read as. Left out where the deployment named none,
100
+ * leaving the read as the Account root.
93
101
  */
94
- cfnSecureDynamicReferenceResolver(): SimCfnSsmSecureDynamicReferenceResolver;
102
+ cfnSecureDynamicReferenceResolver(caller?: SimAwsCaller): SimCfnSsmSecureDynamicReferenceResolver;
95
103
  /**
96
104
  * Get the reader for `AWS::SSM::Parameter::Value<...>` template Parameters.
97
105
  */
@@ -140,15 +140,23 @@ export class SimSsm {
140
140
  }
141
141
  /**
142
142
  * Get the resolver for `{{resolve:ssm:...}}` dynamic references.
143
+ *
144
+ * The caller is the principal the deployment holding the reference runs as,
145
+ * which the parameter is read as. Left out where the deployment named none,
146
+ * leaving the read as the Account root.
143
147
  */
144
- cfnDynamicReferenceResolver() {
145
- return new SimCfnSsmDynamicReferenceResolver({ ssm: this });
148
+ cfnDynamicReferenceResolver(caller) {
149
+ return new SimCfnSsmDynamicReferenceResolver({ ssm: this, caller });
146
150
  }
147
151
  /**
148
152
  * Get the resolver for `{{resolve:ssm-secure:...}}` dynamic references.
153
+ *
154
+ * The caller is the principal the deployment holding the reference runs as,
155
+ * which the parameter is read as. Left out where the deployment named none,
156
+ * leaving the read as the Account root.
149
157
  */
150
- cfnSecureDynamicReferenceResolver() {
151
- return new SimCfnSsmSecureDynamicReferenceResolver({ ssm: this });
158
+ cfnSecureDynamicReferenceResolver(caller) {
159
+ return new SimCfnSsmSecureDynamicReferenceResolver({ ssm: this, caller });
152
160
  }
153
161
  /**
154
162
  * Get the reader for `AWS::SSM::Parameter::Value<...>` template Parameters.
@@ -1,4 +1,4 @@
1
- import type { SimArnPrincipal } from "../../aws/caller/sim-aws-caller.js";
1
+ import type { SimAwsResolvedCaller } from "../../aws/caller/sim-aws-caller-resolver.js";
2
2
  import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
3
3
  import type { AwsRegionName } from "../../aws/sim-aws-region.js";
4
4
  import type { SimGetRoleCommandOutput } from "../../iam/command/role/get-role/get-role.command.js";
@@ -14,7 +14,14 @@ interface AssumeRoleAuthorizationCoordinatorProperties {
14
14
  interface AssumeRoleAuthorizationInput {
15
15
  readonly roleArn: string;
16
16
  readonly roleArnParts: IamRoleArnParts;
17
- readonly caller: SimArnPrincipal;
17
+ /**
18
+ * The caller as the request boundary resolved it.
19
+ *
20
+ * Both sides of an AssumeRole decision need the identity whose policies
21
+ * apply, which is the Role behind an assumed-role session. Passing the
22
+ * resolved caller whole is what carries it here.
23
+ */
24
+ readonly caller: SimAwsResolvedCaller;
18
25
  readonly conditionContext?: Readonly<Record<string, SimIamConditionValue>> | undefined;
19
26
  }
20
27
  type AssumeRoleAuthorizedRole = SimGetRoleCommandOutput["Role"];
@@ -38,8 +38,8 @@ export class AssumeRoleAuthorizationCoordinator {
38
38
  });
39
39
  this.sourcePrincipalAuthorizer.authorize({
40
40
  roleArn: input.roleArn,
41
- callerPrincipal: input.caller,
42
- identityPolicyAllowRequired: !this.hasDirectSameAccountUserGrant(input.caller, input.roleArnParts.accountId, targetAuthorization.trust.isDirectPrincipalGrant),
41
+ caller: input.caller,
42
+ identityPolicyAllowRequired: !this.hasDirectSameAccountUserGrant(input.caller.principal, input.roleArnParts.accountId, targetAuthorization.trust.isDirectPrincipalGrant),
43
43
  });
44
44
  return targetAuthorization.role;
45
45
  }
@@ -1,7 +1,7 @@
1
1
  import type { SimIamAccountResolver } from "../../iam/registry/sim-iam-account-resolver.js";
2
2
  import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
3
3
  import type { AwsRegionName } from "../../aws/sim-aws-region.js";
4
- import type { SimAwsPrincipal } from "../../aws/caller/sim-aws-caller.js";
4
+ import type { SimAwsResolvedCaller } from "../../aws/caller/sim-aws-caller-resolver.js";
5
5
  interface AssumeRoleSourceAccountAuthorizerProperties {
6
6
  readonly sourceAccountId: SimAwsAccountId;
7
7
  readonly iamResolver: SimIamAccountResolver;
@@ -12,7 +12,13 @@ interface AssumeRoleSourceAccountAuthorizerProperties {
12
12
  }
13
13
  export interface AssumeRoleSourceAuthorizationInput {
14
14
  readonly roleArn: string;
15
- readonly callerPrincipal?: SimAwsPrincipal | undefined;
15
+ /**
16
+ * The caller as the request boundary resolved it.
17
+ *
18
+ * The identity policies deciding this are the ones held by the Role behind
19
+ * an assumed-role session, so the resolved caller travels here whole.
20
+ */
21
+ readonly caller?: SimAwsResolvedCaller | undefined;
16
22
  /**
17
23
  * Whether the caller must have an identity-policy Allow for sts:AssumeRole.
18
24
  *
@@ -31,8 +37,8 @@ export interface AssumeRoleSourceAuthorizationInput {
31
37
  * trust authorization is a separate responsibility and must be performed even
32
38
  * when the source and target Account are the same.
33
39
  *
34
- * When no caller principal is supplied, Sim IAM applies its normal default
35
- * caller behavior for the source Account.
40
+ * When no caller principal is supplied, sim IAM applies its own default caller
41
+ * behaviour for the source Account.
36
42
  */
37
43
  export declare class AssumeRoleSourcePrincipalAuthorizer {
38
44
  private readonly sourceAccountId;
@@ -1,4 +1,4 @@
1
- import { makeSimAwsAccountRootPrincipal } from "../../aws/caller/sim-aws-account-root-principal.js";
1
+ import { simAwsCallerFor } from "../../aws/caller/sim-aws-resolved-caller.js";
2
2
  import { SimIamAccessDenied } from "../../iam/error/sim-iam.error.js";
3
3
  /**
4
4
  * Authorizes the caller's request to assume a role against IAM in the source
@@ -10,8 +10,8 @@ import { SimIamAccessDenied } from "../../iam/error/sim-iam.error.js";
10
10
  * trust authorization is a separate responsibility and must be performed even
11
11
  * when the source and target Account are the same.
12
12
  *
13
- * When no caller principal is supplied, Sim IAM applies its normal default
14
- * caller behavior for the source Account.
13
+ * When no caller principal is supplied, sim IAM applies its own default caller
14
+ * behaviour for the source Account.
15
15
  */
16
16
  export class AssumeRoleSourcePrincipalAuthorizer {
17
17
  sourceAccountId;
@@ -30,18 +30,19 @@ export class AssumeRoleSourcePrincipalAuthorizer {
30
30
  */
31
31
  authorize(input) {
32
32
  const sourceIam = this.iamResolver.iamForAccount(this.sourceAccountId);
33
- const callerPrincipal = input.callerPrincipal ??
34
- makeSimAwsAccountRootPrincipal(this.sourceAccountId);
33
+ // A request with no caller of its own is left for sim IAM to attribute.
34
+ // The simulation's default caller reaches this decision the way it reaches
35
+ // every other one.
35
36
  const decision = sourceIam.authorize({
36
37
  action: "sts:AssumeRole",
37
38
  resource: input.roleArn,
38
39
  region: this.regionName,
39
- caller: callerPrincipal,
40
+ caller: input.caller === undefined ? undefined : simAwsCallerFor(input.caller),
40
41
  });
41
42
  if (decision.isExplicitDeny ||
42
43
  (decision.isImplicitDeny && Boolean(input.identityPolicyAllowRequired))) {
43
44
  throw new SimIamAccessDenied({
44
- principal: callerPrincipal,
45
+ principal: decision.caller.principal,
45
46
  action: "sts:AssumeRole",
46
47
  resource: input.roleArn,
47
48
  });
@@ -1,4 +1,4 @@
1
- import type { SimAwsPrincipal } from "../../aws/caller/sim-aws-caller.js";
1
+ import type { SimAwsResolvedCaller } from "../../aws/caller/sim-aws-caller-resolver.js";
2
2
  import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
3
3
  import type { AwsRegionName } from "../../aws/sim-aws-region.js";
4
4
  import type { SimIamAccountResolver } from "../../iam/registry/sim-iam-account-resolver.js";
@@ -17,7 +17,7 @@ type AssumeRoleTargetRole = SimGetRoleCommandOutput["Role"];
17
17
  interface AssumeRoleTargetAuthorizationInput {
18
18
  readonly roleArn: string;
19
19
  readonly target: IamRoleArnParts | SimAwsAccountId;
20
- readonly caller: SimAwsPrincipal;
20
+ readonly caller: SimAwsResolvedCaller;
21
21
  readonly conditionContext?: Readonly<Record<string, SimIamConditionValue>> | undefined;
22
22
  }
23
23
  interface AssumeRoleTargetAuthorization {
@@ -1,4 +1,4 @@
1
- import type { SimAwsPrincipal } from "../../aws/caller/sim-aws-caller.js";
1
+ import type { SimAwsResolvedCaller } from "../../aws/caller/sim-aws-caller-resolver.js";
2
2
  import type { AwsRegionName } from "../../aws/sim-aws-region.js";
3
3
  import type { SimGetRoleCommandOutput } from "../../iam/command/role/get-role/get-role.command.js";
4
4
  import type { SimIamConditionValue } from "../../iam/policy/sim-iam-policy.js";
@@ -14,7 +14,7 @@ interface AssumeRoleTrustPolicyAuthorizationInput {
14
14
  * target Account's service control policies can be conditioned on.
15
15
  */
16
16
  readonly region?: AwsRegionName | undefined;
17
- readonly caller: SimAwsPrincipal;
17
+ readonly caller: SimAwsResolvedCaller;
18
18
  readonly conditionContext?: Readonly<Record<string, SimIamConditionValue>> | undefined;
19
19
  }
20
20
  export interface AssumeRoleTrustPolicyAuthorization {
@@ -46,5 +46,9 @@ export declare class AssumeRoleTrustPolicyAuthorizer {
46
46
  * no trust-policy statement grants access, even if no explicit Deny matched.
47
47
  */
48
48
  authorize(input: AssumeRoleTrustPolicyAuthorizationInput): AssumeRoleTrustPolicyAuthorization;
49
+ /**
50
+ * Refuse the request as the caller that made it.
51
+ */
52
+ private refuse;
49
53
  }
50
54
  export {};
@@ -1,4 +1,5 @@
1
1
  import { jsonParse } from "../../../util/type-guard/json.js";
2
+ import { simAwsCallerFor } from "../../aws/caller/sim-aws-resolved-caller.js";
2
3
  import { SimIamAccessDenied } from "../../iam/error/sim-iam.error.js";
3
4
  import { AssumeRoleTrustGrantClassifier } from "./assume-role-trust-grant-classifier.js";
4
5
  /**
@@ -27,18 +28,14 @@ export class AssumeRoleTrustPolicyAuthorizer {
27
28
  */
28
29
  authorize(input) {
29
30
  if (input.role.AssumeRolePolicyDocument === undefined) {
30
- throw new SimIamAccessDenied({
31
- principal: input.caller,
32
- action: "sts:AssumeRole",
33
- resource: input.roleArn,
34
- });
31
+ this.refuse(input);
35
32
  }
36
33
  const trustPolicy = jsonParse(input.role.AssumeRolePolicyDocument);
37
34
  const decision = input.targetIam.authorize({
38
35
  action: "sts:AssumeRole",
39
36
  resource: input.roleArn,
40
37
  region: input.region,
41
- caller: input.caller,
38
+ caller: simAwsCallerFor(input.caller),
42
39
  conditionContext: input.conditionContext,
43
40
  resourcePolicies: [
44
41
  {
@@ -50,15 +47,21 @@ export class AssumeRoleTrustPolicyAuthorizer {
50
47
  ],
51
48
  });
52
49
  if (decision.isDenied || !decision.isAllowedByTrustPolicy) {
53
- throw new SimIamAccessDenied({
54
- principal: input.caller,
55
- action: "sts:AssumeRole",
56
- resource: input.roleArn,
57
- });
50
+ this.refuse(input);
58
51
  }
59
52
  return {
60
53
  decision,
61
54
  isDirectPrincipalGrant: this.trustGrantClassifier.hasDirectPrincipalGrant(decision.trustAllowStatements),
62
55
  };
63
56
  }
57
+ /**
58
+ * Refuse the request as the caller that made it.
59
+ */
60
+ refuse(input) {
61
+ throw new SimIamAccessDenied({
62
+ principal: input.caller.principal,
63
+ action: "sts:AssumeRole",
64
+ resource: input.roleArn,
65
+ });
66
+ }
64
67
  }
@@ -4,7 +4,7 @@ import type { SimAssumeRoleCommand, SimAssumeRoleCommandOutput } from "./assume-
4
4
  import { type BackgroundScheduler } from "../../../../util/background/background.js";
5
5
  import type { SimAwsAccountId } from "../../../aws/sim-aws-account.js";
6
6
  import type { AwsRegionName } from "../../../aws/sim-aws-region.js";
7
- import type { SimAwsCaller } from "../../../aws/caller/sim-aws-caller.js";
7
+ import type { SimAwsCaller, SimAwsDefaultCaller } from "../../../aws/caller/sim-aws-caller.js";
8
8
  interface AssumeRoleCommandHandlerProperties {
9
9
  readonly sourceAccountId: SimAwsAccountId;
10
10
  /**
@@ -13,6 +13,10 @@ interface AssumeRoleCommandHandlerProperties {
13
13
  readonly regionName: AwsRegionName;
14
14
  readonly iamResolver: SimIamAccountResolver;
15
15
  readonly background?: BackgroundScheduler;
16
+ /**
17
+ * The caller this simulation attributes a request naming none to.
18
+ */
19
+ readonly defaultCaller?: SimAwsDefaultCaller | undefined;
16
20
  }
17
21
  /**
18
22
  * STS AssumeRoleCommand handler.
@@ -16,7 +16,7 @@ import { AssumeRoleAuthorizationCoordinator } from "../../auth-z/assume-role-aut
16
16
  */
17
17
  export class AssumeRoleCommandHandler {
18
18
  background;
19
- callerResolver = new SimAwsCallerResolver();
19
+ callerResolver;
20
20
  requestParser = new SimStsAssumeRoleRequestParser();
21
21
  authorizationCoordinator;
22
22
  sessionCreator;
@@ -25,6 +25,9 @@ export class AssumeRoleCommandHandler {
25
25
  const { sourceAccountId, regionName, iamResolver, background = new BackgroundTasks(), } = properties;
26
26
  this.sourceAccountId = sourceAccountId;
27
27
  this.background = background;
28
+ this.callerResolver = new SimAwsCallerResolver({
29
+ defaultCaller: properties.defaultCaller,
30
+ });
28
31
  this.authorizationCoordinator = new AssumeRoleAuthorizationCoordinator({
29
32
  sourceAccountId,
30
33
  iamResolver,
@@ -56,7 +59,7 @@ export class AssumeRoleCommandHandler {
56
59
  const role = await this.authorizationCoordinator.authorize({
57
60
  roleArn: request.roleArn,
58
61
  roleArnParts: request.roleArnParts,
59
- caller: caller.principal,
62
+ caller,
60
63
  conditionContext: request.conditionContext,
61
64
  });
62
65
  return this.sessionCreator.create({
@@ -1,11 +1,15 @@
1
1
  import type { CommandHandler } from "../../../../command/command-handler.js";
2
- import type { SimAwsCaller } from "../../../aws/caller/sim-aws-caller.js";
2
+ import type { SimAwsCaller, SimAwsDefaultCaller } from "../../../aws/caller/sim-aws-caller.js";
3
3
  import type { SimAwsAccountId } from "../../../aws/sim-aws-account.js";
4
4
  import type { SimIamAccountResolver } from "../../../iam/registry/sim-iam-account-resolver.js";
5
5
  import type { SimGetCallerIdentityCommand, SimGetCallerIdentityCommandOutput } from "./get-caller-identity.command.js";
6
6
  interface GetCallerIdentityCommandHandlerProperties {
7
7
  readonly sourceAccountId: SimAwsAccountId;
8
8
  readonly iamResolver: SimIamAccountResolver;
9
+ /**
10
+ * The caller this simulation attributes a request naming none to.
11
+ */
12
+ readonly defaultCaller?: SimAwsDefaultCaller | undefined;
9
13
  }
10
14
  /**
11
15
  * Simulated STS GetCallerIdentity handler.
@@ -13,12 +13,15 @@ import { simStsCallerUserId } from "./sim-sts-caller-user-id.js";
13
13
  * https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/sts/command/GetCallerIdentityCommand/
14
14
  */
15
15
  export class GetCallerIdentityCommandHandler {
16
- callerResolver = new SimAwsCallerResolver();
16
+ callerResolver;
17
17
  sourceAccountId;
18
18
  iamResolver;
19
19
  constructor(properties) {
20
20
  this.sourceAccountId = properties.sourceAccountId;
21
21
  this.iamResolver = properties.iamResolver;
22
+ this.callerResolver = new SimAwsCallerResolver({
23
+ defaultCaller: properties.defaultCaller,
24
+ });
22
25
  }
23
26
  /**
24
27
  * Report the identity behind this request.
@@ -1,3 +1,4 @@
1
+ import { simAwsResolvedCallerOf } from "../../aws/caller/sim-aws-resolved-caller.js";
1
2
  import { SimIamAccessDenied } from "../../iam/error/sim-iam.error.js";
2
3
  import { AssumeRoleTrustPolicyAuthorizer } from "../auth-z/assume-role-trust-policy-authorizer.js";
3
4
  import { simServiceRoleConditionContext, } from "./sim-service-role-source.js";
@@ -25,7 +26,10 @@ export async function assumeSimServiceRole(assumption) {
25
26
  role,
26
27
  targetIam: iam,
27
28
  region: scope.accountRegionScope.regionName,
28
- caller: { kind: "service", service: servicePrincipal },
29
+ caller: simAwsResolvedCallerOf({
30
+ kind: "service",
31
+ service: servicePrincipal,
32
+ }),
29
33
  conditionContext: simServiceRoleConditionContext(source),
30
34
  });
31
35
  }