@kensio/yulin 1.20.12 → 1.20.13

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 (132) hide show
  1. package/dist/service/acm/command/delete-certificate/delete-certificate-authorizer.js +1 -0
  2. package/dist/service/acm/command/describe-certificate/describe-certificate-authorizer.js +1 -0
  3. package/dist/service/acm/command/list-certificates/list-certificates-authorizer.js +1 -0
  4. package/dist/service/acm/command/request-certificate/request-certificate-authorizer.js +1 -0
  5. package/dist/service/apigateway/serve/auth/sim-rest-api-authorizer-policy.js +3 -0
  6. package/dist/service/apigatewayv2/serve/auth/sim-http-api-authorizer-policy.js +3 -0
  7. package/dist/service/aws/factory/sim-aws-account-service-cache.d.ts +3 -0
  8. package/dist/service/aws/factory/sim-aws-account-service-cache.js +5 -0
  9. package/dist/service/aws/factory/sim-aws-service-factory.d.ts +9 -0
  10. package/dist/service/aws/factory/sim-aws-service-factory.js +10 -0
  11. package/dist/service/aws/sim-aws.d.ts +18 -0
  12. package/dist/service/aws/sim-aws.js +19 -0
  13. package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn-value-adapter.d.ts +6 -0
  14. package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn-value-adapter.js +23 -0
  15. package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn.d.ts +66 -0
  16. package/dist/service/cloudformation/resource/cfn/organizations/sim-organizations-cfn.js +136 -0
  17. package/dist/service/cloudformation/resource/cfn/sim-cfn-service-value-adapters.js +2 -0
  18. package/dist/service/cloudformation/resource/resolve/service/sim-cfn-service-factories.js +7 -0
  19. package/dist/service/cloudfront/command/create-distribution/create-distribution-authorizer.js +1 -0
  20. package/dist/service/cloudfront/command/create-function/create-function-authorizer.js +1 -0
  21. package/dist/service/cloudfront/command/delete-distribution/delete-distribution-authorizer.js +1 -0
  22. package/dist/service/cloudfront/command/delete-function/delete-function-authorizer.js +1 -0
  23. package/dist/service/cloudfront/command/get-distribution/get-distribution-authorizer.js +1 -0
  24. package/dist/service/cloudfront/command/update-distribution/update-distribution-authorizer.js +1 -0
  25. package/dist/service/cloudfront/edge/sim-cf-edge-association-auth-z.js +1 -0
  26. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-access.js +1 -0
  27. package/dist/service/cloudwatch/command/authorize/sim-cloudwatch-decide.js +1 -0
  28. package/dist/service/cognito/command/authorize/sim-cognito-authorizer.js +1 -0
  29. package/dist/service/dynamodb/command/authorize/sim-dynamodb-authorizer.js +1 -0
  30. package/dist/service/firehose/command/authorize/sim-firehose-authorizer.js +1 -0
  31. package/dist/service/glue/command/authorize/sim-glue-authorize-resources.js +1 -0
  32. package/dist/service/iam/authorize/allow/sim-iam-policy-evaluation.d.ts +45 -0
  33. package/dist/service/iam/authorize/allow/sim-iam-policy-evaluation.js +59 -0
  34. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.d.ts +15 -4
  35. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.js +15 -4
  36. package/dist/service/iam/authorize/context/sim-iam-auth-z-context.d.ts +31 -1
  37. package/dist/service/iam/authorize/context/sim-iam-auth-z-context.factory.js +1 -0
  38. package/dist/service/iam/authorize/context/sim-iam-auth-z-scp-source-builder.d.ts +46 -0
  39. package/dist/service/iam/authorize/context/sim-iam-auth-z-scp-source-builder.js +71 -0
  40. package/dist/service/iam/authorize/scp/sim-iam-scp-gate.d.ts +96 -0
  41. package/dist/service/iam/authorize/scp/sim-iam-scp-gate.js +148 -0
  42. package/dist/service/iam/authorize/scp/sim-iam-scp-resolver.d.ts +53 -0
  43. package/dist/service/iam/authorize/scp/sim-iam-scp-resolver.js +1 -0
  44. package/dist/service/iam/authorize/sim-iam-account-auth-z.d.ts +8 -0
  45. package/dist/service/iam/authorize/sim-iam-account-auth-z.js +1 -0
  46. package/dist/service/iam/authorize/sim-iam-action-authorizer.js +1 -0
  47. package/dist/service/iam/authorize/sim-iam-authorizer.d.ts +2 -0
  48. package/dist/service/iam/authorize/sim-iam-authorizer.js +1 -0
  49. package/dist/service/iam/authorize/sim-iam-decision-value.d.ts +13 -0
  50. package/dist/service/iam/authorize/sim-iam-decision-value.js +12 -0
  51. package/dist/service/iam/authorize/sim-iam-decision.d.ts +33 -16
  52. package/dist/service/iam/authorize/sim-iam-decision.js +64 -49
  53. package/dist/service/iam/authorize/sim-iam-inter-service-auth-z.d.ts +8 -0
  54. package/dist/service/iam/authorize/sim-iam-inter-service-auth-z.js +1 -0
  55. package/dist/service/iam/error/sim-iam.error.d.ts +8 -0
  56. package/dist/service/iam/error/sim-iam.error.js +2 -1
  57. package/dist/service/iam/sim-iam-account-parts.d.ts +9 -0
  58. package/dist/service/iam/sim-iam-account-parts.js +1 -0
  59. package/dist/service/kinesis/command/authorize/sim-kinesis-authorizer.js +1 -0
  60. package/dist/service/kms/command/authorize/sim-kms-authorizer.js +2 -0
  61. package/dist/service/lambda/command/create-function/create-function-authorizer.js +1 -0
  62. package/dist/service/lambda/command/delete-function/delete-function-authorizer.js +1 -0
  63. package/dist/service/lambda/command/event-invoke-config/event-invoke-config-authorizer.js +1 -0
  64. package/dist/service/lambda/command/function-url/function-url-authorizer.js +1 -0
  65. package/dist/service/lambda/command/get-function/get-function-authorizer.js +1 -0
  66. package/dist/service/lambda/command/invoke/invoke-authorizer.js +1 -0
  67. package/dist/service/lambda/command/list-functions/list-functions-authorizer.js +1 -0
  68. package/dist/service/lambda/command/update-function-code/update-function-code-authorizer.js +1 -0
  69. package/dist/service/lambda/command/update-function-configuration/update-function-configuration-authorizer.js +1 -0
  70. package/dist/service/lambda/command/version/version-authorizer.js +1 -0
  71. package/dist/service/logs/command/authorize/sim-logs-authorizer.js +1 -0
  72. package/dist/service/organizations/cfn/sim-cfn-organization-creator.d.ts +19 -0
  73. package/dist/service/organizations/cfn/sim-cfn-organization-creator.js +25 -0
  74. package/dist/service/organizations/cfn/sim-cfn-organizational-unit-creator.d.ts +16 -0
  75. package/dist/service/organizations/cfn/sim-cfn-organizational-unit-creator.js +21 -0
  76. package/dist/service/organizations/cfn/sim-cfn-organizations-account-creator.d.ts +20 -0
  77. package/dist/service/organizations/cfn/sim-cfn-organizations-account-creator.js +34 -0
  78. package/dist/service/organizations/cfn/sim-cfn-organizations-policy-creator.d.ts +21 -0
  79. package/dist/service/organizations/cfn/sim-cfn-organizations-policy-creator.js +40 -0
  80. package/dist/service/organizations/cfn/sim-cfn-organizations-policy-input.d.ts +20 -0
  81. package/dist/service/organizations/cfn/sim-cfn-organizations-policy-input.js +33 -0
  82. package/dist/service/organizations/cfn/sim-cfn-organizations-properties.d.ts +36 -0
  83. package/dist/service/organizations/cfn/sim-cfn-organizations-properties.js +78 -0
  84. package/dist/service/organizations/cfn/sim-cfn-organizations-record.d.ts +40 -0
  85. package/dist/service/organizations/cfn/sim-cfn-organizations-record.js +54 -0
  86. package/dist/service/organizations/cfn/sim-cfn-organizations-remover.d.ts +17 -0
  87. package/dist/service/organizations/cfn/sim-cfn-organizations-remover.js +40 -0
  88. package/dist/service/organizations/cfn/sim-organizations-cfn-resource-factory.d.ts +24 -0
  89. package/dist/service/organizations/cfn/sim-organizations-cfn-resource-factory.js +50 -0
  90. package/dist/service/organizations/index.d.ts +6 -0
  91. package/dist/service/organizations/index.js +6 -0
  92. package/dist/service/organizations/policy/sim-organizations-effective-policies.d.ts +43 -0
  93. package/dist/service/organizations/policy/sim-organizations-effective-policies.js +58 -0
  94. package/dist/service/organizations/policy/sim-organizations-scp-store.d.ts +61 -0
  95. package/dist/service/organizations/policy/sim-organizations-scp-store.js +103 -0
  96. package/dist/service/organizations/sim-organizations-structure.d.ts +94 -0
  97. package/dist/service/organizations/sim-organizations-structure.js +140 -0
  98. package/dist/service/organizations/sim-organizations.d.ts +95 -0
  99. package/dist/service/organizations/sim-organizations.js +99 -0
  100. package/dist/service/organizations/tree/sim-organizations-node.d.ts +57 -0
  101. package/dist/service/organizations/tree/sim-organizations-node.js +58 -0
  102. package/dist/service/organizations/tree/sim-organizations-tree.d.ts +91 -0
  103. package/dist/service/organizations/tree/sim-organizations-tree.js +154 -0
  104. package/dist/service/route53/command/change-resource-record-sets/change-resource-record-sets-authorizer.js +1 -0
  105. package/dist/service/route53/command/create-hosted-zone/create-hosted-zone-authorizer.js +1 -0
  106. package/dist/service/route53/command/delete-hosted-zone/delete-hosted-zone-authorizer.js +1 -0
  107. package/dist/service/route53/command/dnssec/sim-route53-dnssec-authorizer.js +1 -0
  108. package/dist/service/route53/command/get-hosted-zone/get-hosted-zone-authorizer.js +1 -0
  109. package/dist/service/route53/command/list-hosted-zones-by-name/list-hosted-zones-by-name-authorizer.js +1 -0
  110. package/dist/service/route53/command/list-resource-record-sets/list-resource-record-sets-authorizer.js +1 -0
  111. package/dist/service/s3/command/create-bucket/create-bucket.handler.js +1 -0
  112. package/dist/service/s3/command/delete-bucket/delete-bucket-authorizer.js +1 -0
  113. package/dist/service/s3/command/delete-bucket-policy/delete-bucket-policy-authorizer.js +1 -0
  114. package/dist/service/s3/command/delete-object/delete-object-authorizer.js +1 -0
  115. package/dist/service/s3/command/get-bucket-policy/get-bucket-policy-authorizer.js +1 -0
  116. package/dist/service/s3/command/get-object/get-object-authorizer.js +1 -0
  117. package/dist/service/s3/command/head-bucket/head-bucket-authorizer.js +1 -0
  118. package/dist/service/s3/command/lifecycle/sim-s3-lifecycle-authorizer.js +1 -0
  119. package/dist/service/s3/command/list-buckets/list-buckets-authorizer.js +1 -0
  120. package/dist/service/s3/command/list-objects/list-objects-authorizer.js +1 -0
  121. package/dist/service/s3/command/multipart/sim-s3-multipart-authorizer.js +1 -0
  122. package/dist/service/s3/command/notification/sim-s3-notification-authorizer.js +1 -0
  123. package/dist/service/s3/command/public-access-block/sim-s3-public-access-block-authorizer.js +1 -0
  124. package/dist/service/s3/command/put-bucket-policy/put-bucket-policy-authorizer.js +1 -0
  125. package/dist/service/s3/command/put-bucket-website/put-bucket-website-authorizer.js +1 -0
  126. package/dist/service/s3/command/put-object/put-object-authorizer.js +1 -0
  127. package/dist/service/secretsmanager/command/authorize/sim-secrets-manager-authorizer.js +1 -0
  128. package/dist/service/ses/command/authorize/sim-ses-authorizer.js +1 -0
  129. package/dist/service/sqs/command/authorize/sim-sqs-authorizer.js +1 -0
  130. package/dist/service/ssm/command/authorize/sim-ssm-authorizer.js +1 -0
  131. package/dist/service/wafv2/command/authorize/sim-wafv2-authorizer.js +1 -0
  132. package/package.json +5 -1
@@ -27,6 +27,7 @@ export class DeleteCertificateAuthorizer {
27
27
  if (decision.isDenied) {
28
28
  throw new SimIamAccessDenied({
29
29
  principal: decision.caller.principal,
30
+ reason: decision.denialReason,
30
31
  action: DeleteCertificateAuthorizer.action,
31
32
  resource: certificateArn,
32
33
  });
@@ -32,6 +32,7 @@ export class DescribeCertificateAuthorizer {
32
32
  if (decision.isDenied) {
33
33
  throw new SimIamAccessDenied({
34
34
  principal: decision.caller.principal,
35
+ reason: decision.denialReason,
35
36
  action: DescribeCertificateAuthorizer.action,
36
37
  resource: certificateArn,
37
38
  });
@@ -32,6 +32,7 @@ export class ListCertificatesAuthorizer {
32
32
  if (decision.isDenied) {
33
33
  throw new SimIamAccessDenied({
34
34
  principal: decision.caller.principal,
35
+ reason: decision.denialReason,
35
36
  action: ListCertificatesAuthorizer.action,
36
37
  resource: ListCertificatesAuthorizer.resource,
37
38
  });
@@ -29,6 +29,7 @@ export class RequestCertificateAuthorizer {
29
29
  if (decision.isDenied) {
30
30
  throw new SimIamAccessDenied({
31
31
  principal: decision.caller.principal,
32
+ reason: decision.denialReason,
32
33
  action: RequestCertificateAuthorizer.action,
33
34
  resource: this.resource,
34
35
  });
@@ -49,6 +49,9 @@ export class SimRestApiAuthorizerPolicy {
49
49
  },
50
50
  ],
51
51
  resourcePolicies: [],
52
+ // An authorizer's policy document is evaluated on its own. No Account
53
+ // boundary is being crossed here, so no service control policy applies.
54
+ serviceControlPolicies: { applies: false, levels: [] },
52
55
  allowRequirement: new SimIamEitherSideAllowRequirement(),
53
56
  action: simExecuteApiInvokeAction,
54
57
  resource: methodArn,
@@ -39,6 +39,9 @@ export class SimHttpApiAuthorizerPolicy {
39
39
  },
40
40
  ],
41
41
  resourcePolicies: [],
42
+ // An authorizer's policy document is evaluated on its own. No Account
43
+ // boundary is being crossed here, so no service control policy applies.
44
+ serviceControlPolicies: { applies: false, levels: [] },
42
45
  allowRequirement: new SimIamEitherSideAllowRequirement(),
43
46
  action: simExecuteApiInvokeAction,
44
47
  resource: routeArn,
@@ -9,6 +9,7 @@ import type { SimRoute53Registry } from "../../route53/registry/sim-route53-regi
9
9
  import type { SimKmsRegistry } from "../../kms/registry/sim-kms-registry.js";
10
10
  import { SimIam } from "../../iam/index.js";
11
11
  import type { SimIamRegistry } from "../../iam/registry/sim-iam-registry.js";
12
+ import type { SimIamServiceControlPolicyResolver } from "../../iam/authorize/scp/sim-iam-scp-resolver.js";
12
13
  import { type SimIamAccessKeyRegistry } from "../../iam/registry/sim-iam-access-key-registry.js";
13
14
  import type { SimAwsServiceHosts } from "../../../serve/controller/host/sim-aws-service-hosts.js";
14
15
  import type { SimAwsScopedServiceProperties } from "./sim-aws-scoped-service-properties.js";
@@ -23,6 +24,7 @@ interface SimAwsAccountServiceCacheProperties {
23
24
  readonly shadowableServiceHosts: SimAwsServiceHosts;
24
25
  readonly iamRegistry: SimIamRegistry;
25
26
  readonly accessKeyRegistry: SimIamAccessKeyRegistry;
27
+ readonly scpResolver: SimIamServiceControlPolicyResolver;
26
28
  }
27
29
  /**
28
30
  * Account-level cache for simulated AWS service instances.
@@ -52,6 +54,7 @@ export declare class SimAwsAccountServiceCache {
52
54
  private readonly cloudFrontRegistry;
53
55
  private readonly iamRegistry;
54
56
  private readonly accessKeyRegistry;
57
+ private readonly scpResolver;
55
58
  private readonly route53Registry;
56
59
  private readonly kmsRegistry;
57
60
  private readonly serviceHosts;
@@ -37,6 +37,7 @@ export class SimAwsAccountServiceCache {
37
37
  cloudFrontRegistry;
38
38
  iamRegistry;
39
39
  accessKeyRegistry;
40
+ scpResolver;
40
41
  route53Registry;
41
42
  kmsRegistry;
42
43
  serviceHosts;
@@ -55,6 +56,7 @@ export class SimAwsAccountServiceCache {
55
56
  this.acmRegistry = properties.acmRegistry;
56
57
  this.cloudFrontRegistry = properties.cloudFrontRegistry;
57
58
  this.iamRegistry = properties.iamRegistry;
59
+ this.scpResolver = properties.scpResolver;
58
60
  this.accessKeyRegistry = properties.accessKeyRegistry;
59
61
  this.route53Registry = properties.route53Registry;
60
62
  this.kmsRegistry = properties.kmsRegistry;
@@ -109,6 +111,9 @@ export class SimAwsAccountServiceCache {
109
111
  // A cross-Account request is decided in both Accounts, so this IAM
110
112
  // needs to be able to reach the IAM of the caller's own Account.
111
113
  iamResolver: this.iamRegistry,
114
+ // What the Account's organization allows it to do is decided outside
115
+ // the Account, so IAM asks simulated Organizations about it.
116
+ scpResolver: this.scpResolver,
112
117
  // Access keys are indexed simulation-wide as they are issued, so a
113
118
  // signed request naming only a key id can be traced to this Account.
114
119
  credentialRegistry: new SimIamCredentialRegistry({
@@ -22,6 +22,7 @@ import type { SimScheduler } from "../../scheduler/index.js";
22
22
  import type { SimElbV2 } from "../../elbv2/index.js";
23
23
  import type { SimIam } from "../../iam/index.js";
24
24
  import { SimIamRegistry } from "../../iam/registry/sim-iam-registry.js";
25
+ import { SimOrganizations } from "../../organizations/index.js";
25
26
  import type { SimFirehose } from "../../firehose/index.js";
26
27
  import type { SimGlue } from "../../glue/index.js";
27
28
  import type { SimKinesis } from "../../kinesis/index.js";
@@ -77,6 +78,14 @@ export declare class SimAwsServiceFactory {
77
78
  * instance so cross-account services can resolve Account-owned IAM state.
78
79
  */
79
80
  readonly iamRegistry: SimIamRegistry;
81
+ /**
82
+ * Simulated AWS Organizations for this simulation.
83
+ *
84
+ * An organization spans Accounts, so one belongs to the simulation rather
85
+ * than to any scope in it. Sim IAM reads the service control policies it
86
+ * holds when it decides a request.
87
+ */
88
+ readonly organizations: SimOrganizations;
80
89
  /**
81
90
  * Shared request authentication collaborators for this simulation.
82
91
  * @internal
@@ -1,5 +1,6 @@
1
1
  import { SimCloudFrontRegistry } from "../../cloudfront/registry/sim-cloud-front-registry.js";
2
2
  import { SimIamRegistry } from "../../iam/registry/sim-iam-registry.js";
3
+ import { SimOrganizations } from "../../organizations/index.js";
3
4
  import { SimLambdaUrlRegistry } from "../../lambda/registry/sim-lambda-url-registry.js";
4
5
  import { SimAwsAccountRegionServiceBuilder } from "./sim-aws-account-region-service-builder.js";
5
6
  import { SimAwsRegisteredServiceBuilder } from "./sim-aws-registered-service-builder.js";
@@ -40,6 +41,14 @@ export class SimAwsServiceFactory {
40
41
  * instance so cross-account services can resolve Account-owned IAM state.
41
42
  */
42
43
  iamRegistry = new SimIamRegistry();
44
+ /**
45
+ * Simulated AWS Organizations for this simulation.
46
+ *
47
+ * An organization spans Accounts, so one belongs to the simulation rather
48
+ * than to any scope in it. Sim IAM reads the service control policies it
49
+ * holds when it decides a request.
50
+ */
51
+ organizations = new SimOrganizations();
43
52
  /**
44
53
  * Shared request authentication collaborators for this simulation.
45
54
  * @internal
@@ -94,6 +103,7 @@ export class SimAwsServiceFactory {
94
103
  shadowableServiceHosts: this.registries.shadowableServiceHosts,
95
104
  iamRegistry: this.iamRegistry,
96
105
  accessKeyRegistry: this.requestAuth.accessKeyRegistry,
106
+ scpResolver: this.organizations,
97
107
  });
98
108
  this.accountRegionServices = new SimAwsAccountRegionServiceBuilder({
99
109
  simAws: properties.simAws,
@@ -4,6 +4,7 @@ import type { SimAwsAccountRegionContainer } from "./sim-aws-account-region-scop
4
4
  import { SimAwsServiceFactory } from "./factory/sim-aws-service-factory.js";
5
5
  import { SimAwsServiceAccessors } from "./sim-aws-service-accessors.js";
6
6
  import type { SimIamRegistry } from "../iam/registry/sim-iam-registry.js";
7
+ import type { SimOrganizations } from "../organizations/index.js";
7
8
  import type { SimAwsPrincipal } from "./caller/sim-aws-caller.js";
8
9
  import type { SimClockControl } from "../../util/clock/sim-clock-control.js";
9
10
  import type { SimAwsProperties, SimAwsRequestCallerOptions } from "./sim-aws-properties.js";
@@ -36,6 +37,23 @@ export declare class SimAws extends SimAwsServiceAccessors {
36
37
  private readonly timekeeping;
37
38
  private readonly requestAuthentication;
38
39
  constructor(properties?: SimAwsProperties);
40
+ /**
41
+ * Get simulated AWS Organizations for this simulated AWS environment.
42
+ *
43
+ * An organization spans Accounts, so this one belongs to the whole
44
+ * simulation and is reached here rather than from an Account scope. The
45
+ * service control policies attached through it filter what the Accounts in
46
+ * this simulation may do, whether a request arrives through a CloudFormation
47
+ * deployment, an intercepted SDK client, or a service call in a handler.
48
+ *
49
+ * ```typescript
50
+ * simAws.organizations().attachServiceControlPolicy("123456789012", {
51
+ * Version: "2012-10-17",
52
+ * Statement: { Effect: "Deny", Action: "s3:CreateBucket", Resource: "*" },
53
+ * });
54
+ * ```
55
+ */
56
+ organizations(): SimOrganizations;
39
57
  /**
40
58
  * Get the current time in this simulated AWS environment.
41
59
  *
@@ -55,6 +55,25 @@ export class SimAws extends SimAwsServiceAccessors {
55
55
  clock: background,
56
56
  });
57
57
  }
58
+ /**
59
+ * Get simulated AWS Organizations for this simulated AWS environment.
60
+ *
61
+ * An organization spans Accounts, so this one belongs to the whole
62
+ * simulation and is reached here rather than from an Account scope. The
63
+ * service control policies attached through it filter what the Accounts in
64
+ * this simulation may do, whether a request arrives through a CloudFormation
65
+ * deployment, an intercepted SDK client, or a service call in a handler.
66
+ *
67
+ * ```typescript
68
+ * simAws.organizations().attachServiceControlPolicy("123456789012", {
69
+ * Version: "2012-10-17",
70
+ * Statement: { Effect: "Deny", Action: "s3:CreateBucket", Resource: "*" },
71
+ * });
72
+ * ```
73
+ */
74
+ organizations() {
75
+ return this.serviceFactory.organizations;
76
+ }
58
77
  /**
59
78
  * Get the current time in this simulated AWS environment.
60
79
  *
@@ -0,0 +1,6 @@
1
+ import type { SimCfnResourceValueAdapterProperties, SimCfnServiceValueAdapter } from "../sim-cfn-resource-value-adapter.js";
2
+ /**
3
+ * The CloudFormation-facing value adapter for a simulated Organizations
4
+ * Resource.
5
+ */
6
+ export declare function organizationsValueAdapter(properties: SimCfnResourceValueAdapterProperties): SimCfnServiceValueAdapter;
@@ -0,0 +1,23 @@
1
+ import { SimCfnOrganization, SimCfnOrganizationsAccount, SimCfnOrganizationsPolicy, } from "../../../../organizations/cfn/sim-cfn-organizations-record.js";
2
+ import { SimOrganizationsOrganizationalUnit } from "../../../../organizations/tree/sim-organizations-node.js";
3
+ import { SimOrganizationalUnitCfn, SimOrganizationCfn, SimOrganizationsAccountCfn, SimOrganizationsPolicyCfn, } from "./sim-organizations-cfn.js";
4
+ /**
5
+ * The CloudFormation-facing value adapter for a simulated Organizations
6
+ * Resource.
7
+ */
8
+ export function organizationsValueAdapter(properties) {
9
+ const { simResource } = properties;
10
+ if (simResource instanceof SimCfnOrganization) {
11
+ return new SimOrganizationCfn(simResource);
12
+ }
13
+ if (simResource instanceof SimOrganizationsOrganizationalUnit) {
14
+ return new SimOrganizationalUnitCfn(simResource);
15
+ }
16
+ if (simResource instanceof SimCfnOrganizationsAccount) {
17
+ return new SimOrganizationsAccountCfn(simResource);
18
+ }
19
+ if (simResource instanceof SimCfnOrganizationsPolicy) {
20
+ return new SimOrganizationsPolicyCfn(simResource);
21
+ }
22
+ return undefined;
23
+ }
@@ -0,0 +1,66 @@
1
+ import type { SimCfnOrganization, SimCfnOrganizationsAccount, SimCfnOrganizationsPolicy } from "../../../../organizations/cfn/sim-cfn-organizations-record.js";
2
+ import type { SimOrganizationsOrganizationalUnit } from "../../../../organizations/tree/sim-organizations-node.js";
3
+ import type { SimCfnTemplateValue } from "../../../template/value/sim-cfn-template-value.js";
4
+ import type { SimCfnResourceValueAdapter } from "../sim-cfn-resource-value-adapter.js";
5
+ /**
6
+ * CloudFormation-facing values for a simulated organization.
7
+ */
8
+ export declare class SimOrganizationCfn implements SimCfnResourceValueAdapter {
9
+ private readonly organization;
10
+ constructor(organization: SimCfnOrganization);
11
+ /**
12
+ * AWS::Organizations::Organization Ref returns the organization id.
13
+ */
14
+ refValue(): SimCfnTemplateValue;
15
+ /**
16
+ * The attributes the AWS Resource reference lists, less the management
17
+ * account email, which a simulation has no address for.
18
+ */
19
+ attributeValue(attributeName: string): SimCfnTemplateValue;
20
+ }
21
+ /**
22
+ * CloudFormation-facing values for a simulated organizational unit.
23
+ */
24
+ export declare class SimOrganizationalUnitCfn implements SimCfnResourceValueAdapter {
25
+ private readonly unit;
26
+ constructor(unit: SimOrganizationsOrganizationalUnit);
27
+ /**
28
+ * AWS::Organizations::OrganizationalUnit Ref returns the unit id.
29
+ */
30
+ refValue(): SimCfnTemplateValue;
31
+ /**
32
+ * Id, Arn and Name, as the AWS Resource reference lists.
33
+ */
34
+ attributeValue(attributeName: string): SimCfnTemplateValue;
35
+ }
36
+ /**
37
+ * CloudFormation-facing values for an Account a template put in the
38
+ * organization.
39
+ */
40
+ export declare class SimOrganizationsAccountCfn implements SimCfnResourceValueAdapter {
41
+ private readonly account;
42
+ constructor(account: SimCfnOrganizationsAccount);
43
+ /**
44
+ * AWS::Organizations::Account Ref returns the Account id.
45
+ */
46
+ refValue(): SimCfnTemplateValue;
47
+ /**
48
+ * The attributes the AWS Resource reference lists.
49
+ */
50
+ attributeValue(attributeName: string): SimCfnTemplateValue;
51
+ }
52
+ /**
53
+ * CloudFormation-facing values for a simulated service control policy.
54
+ */
55
+ export declare class SimOrganizationsPolicyCfn implements SimCfnResourceValueAdapter {
56
+ private readonly policy;
57
+ constructor(policy: SimCfnOrganizationsPolicy);
58
+ /**
59
+ * AWS::Organizations::Policy Ref returns the policy id.
60
+ */
61
+ refValue(): SimCfnTemplateValue;
62
+ /**
63
+ * Id, Arn and AwsManaged, as the AWS Resource reference lists.
64
+ */
65
+ attributeValue(attributeName: string): SimCfnTemplateValue;
66
+ }
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Refuse an attribute the AWS Resource reference does not list.
3
+ */
4
+ function unknownAttribute(resourceType, attributeName) {
5
+ throw new Error(`AWS::Organizations::${resourceType} has no attribute ${attributeName}`);
6
+ }
7
+ /**
8
+ * CloudFormation-facing values for a simulated organization.
9
+ */
10
+ export class SimOrganizationCfn {
11
+ organization;
12
+ constructor(organization) {
13
+ this.organization = organization;
14
+ }
15
+ /**
16
+ * AWS::Organizations::Organization Ref returns the organization id.
17
+ */
18
+ refValue() {
19
+ return this.organization.id;
20
+ }
21
+ /**
22
+ * The attributes the AWS Resource reference lists, less the management
23
+ * account email, which a simulation has no address for.
24
+ */
25
+ attributeValue(attributeName) {
26
+ const { organization } = this;
27
+ const values = new Map([
28
+ ["Id", organization.id],
29
+ [
30
+ "Arn",
31
+ `arn:aws:organizations::${organization.managementAccountId}:organization/${organization.id}`,
32
+ ],
33
+ ["RootId", organization.rootId],
34
+ ["ManagementAccountId", organization.managementAccountId],
35
+ [
36
+ "ManagementAccountArn",
37
+ `arn:aws:organizations::${organization.managementAccountId}:account/${organization.id}/${organization.managementAccountId}`,
38
+ ],
39
+ ]);
40
+ return (values.get(attributeName) ??
41
+ unknownAttribute("Organization", attributeName));
42
+ }
43
+ }
44
+ /**
45
+ * CloudFormation-facing values for a simulated organizational unit.
46
+ */
47
+ export class SimOrganizationalUnitCfn {
48
+ unit;
49
+ constructor(unit) {
50
+ this.unit = unit;
51
+ }
52
+ /**
53
+ * AWS::Organizations::OrganizationalUnit Ref returns the unit id.
54
+ */
55
+ refValue() {
56
+ return this.unit.id;
57
+ }
58
+ /**
59
+ * Id, Arn and Name, as the AWS Resource reference lists.
60
+ */
61
+ attributeValue(attributeName) {
62
+ const { unit } = this;
63
+ const values = new Map([
64
+ ["Id", unit.id],
65
+ ["Arn", `arn:aws:organizations::organizational-unit/${unit.id}`],
66
+ ["Name", unit.name],
67
+ ]);
68
+ return (values.get(attributeName) ??
69
+ unknownAttribute("OrganizationalUnit", attributeName));
70
+ }
71
+ }
72
+ /**
73
+ * CloudFormation-facing values for an Account a template put in the
74
+ * organization.
75
+ */
76
+ export class SimOrganizationsAccountCfn {
77
+ account;
78
+ constructor(account) {
79
+ this.account = account;
80
+ }
81
+ /**
82
+ * AWS::Organizations::Account Ref returns the Account id.
83
+ */
84
+ refValue() {
85
+ return this.account.accountId;
86
+ }
87
+ /**
88
+ * The attributes the AWS Resource reference lists.
89
+ */
90
+ attributeValue(attributeName) {
91
+ const { account } = this;
92
+ const values = new Map([
93
+ ["AccountId", account.accountId],
94
+ [
95
+ "Arn",
96
+ `arn:aws:organizations::${account.accountId}:account/${account.accountId}`,
97
+ ],
98
+ ["Email", account.email],
99
+ ["AccountName", account.accountName],
100
+ ["JoinedMethod", "CREATED"],
101
+ ["JoinedTimestamp", account.joinedTimestamp.toISOString()],
102
+ ["Status", "ACTIVE"],
103
+ ]);
104
+ return (values.get(attributeName) ?? unknownAttribute("Account", attributeName));
105
+ }
106
+ }
107
+ /**
108
+ * CloudFormation-facing values for a simulated service control policy.
109
+ */
110
+ export class SimOrganizationsPolicyCfn {
111
+ policy;
112
+ constructor(policy) {
113
+ this.policy = policy;
114
+ }
115
+ /**
116
+ * AWS::Organizations::Policy Ref returns the policy id.
117
+ */
118
+ refValue() {
119
+ return this.policy.id;
120
+ }
121
+ /**
122
+ * Id, Arn and AwsManaged, as the AWS Resource reference lists.
123
+ */
124
+ attributeValue(attributeName) {
125
+ const { policy } = this;
126
+ const values = new Map([
127
+ ["Id", policy.id],
128
+ [
129
+ "Arn",
130
+ `arn:aws:organizations::policy/service_control_policy/${policy.id}`,
131
+ ],
132
+ ["AwsManaged", false],
133
+ ]);
134
+ return (values.get(attributeName) ?? unknownAttribute("Policy", attributeName));
135
+ }
136
+ }
@@ -18,6 +18,7 @@ import { iamValueAdapter } from "./iam/sim-iam-cfn-value-adapter.js";
18
18
  import { kinesisValueAdapter } from "./kinesis/sim-kinesis-cfn-value-adapter.js";
19
19
  import { kmsValueAdapter } from "./kms/sim-kms-cfn-value-adapter.js";
20
20
  import { lambdaValueAdapter } from "./lambda/sim-lambda-cfn-value-adapter.js";
21
+ import { organizationsValueAdapter } from "./organizations/sim-organizations-cfn-value-adapter.js";
21
22
  import { personalizeValueAdapter } from "./personalize/sim-personalize-cfn-value-adapter.js";
22
23
  import { route53ValueAdapter } from "./route53/sim-route53-cfn-value-adapter.js";
23
24
  import { s3ValueAdapter } from "./s3/sim-s3-cfn-value-adapter.js";
@@ -60,6 +61,7 @@ export const simCfnServiceValueAdapters = [
60
61
  kinesisValueAdapter,
61
62
  kmsValueAdapter,
62
63
  lambdaValueAdapter,
64
+ organizationsValueAdapter,
63
65
  personalizeValueAdapter,
64
66
  route53ValueAdapter,
65
67
  s3ValueAdapter,
@@ -1,4 +1,5 @@
1
1
  import { SimCfnCfnResourceFactory } from "../../factory/sim-cfn-cfn-resource-factory.js";
2
+ import { SimOrganizationsCfnResourceFactory } from "../../../../organizations/cfn/sim-organizations-cfn-resource-factory.js";
2
3
  /**
3
4
  * Certificates arrive under two service names. `AWS::CertificateManager::*` is
4
5
  * the real one, and `AWS::ACM::*` is the shorthand some templates use, so both
@@ -34,6 +35,12 @@ export const simCfnServiceResourceFactories = new Map([
34
35
  "CloudFormation",
35
36
  () => new SimCfnCfnResourceFactory(),
36
37
  ],
38
+ // An organization spans Accounts, so this factory reads the one on the
39
+ // creation context rather than the Account and Region scope it deploys into.
40
+ [
41
+ "Organizations",
42
+ () => new SimOrganizationsCfnResourceFactory(),
43
+ ],
37
44
  [
38
45
  "CloudFront",
39
46
  (scopedAws) => scopedAws.cloudFront().cfnResourceFactory(),
@@ -28,6 +28,7 @@ export class CreateDistributionAuthorizer {
28
28
  if (decision.isDenied) {
29
29
  throw new SimIamAccessDenied({
30
30
  principal: decision.caller.principal,
31
+ reason: decision.denialReason,
31
32
  action: CreateDistributionAuthorizer.action,
32
33
  resource: CreateDistributionAuthorizer.resource,
33
34
  });
@@ -26,6 +26,7 @@ export class CreateFunctionAuthorizer {
26
26
  if (decision.isDenied) {
27
27
  throw new SimIamAccessDenied({
28
28
  principal: decision.caller.principal,
29
+ reason: decision.denialReason,
29
30
  action: CreateFunctionAuthorizer.action,
30
31
  resource,
31
32
  });
@@ -31,6 +31,7 @@ export class DeleteDistributionAuthorizer {
31
31
  if (decision.isDenied) {
32
32
  throw new SimIamAccessDenied({
33
33
  principal: decision.caller.principal,
34
+ reason: decision.denialReason,
34
35
  action: DeleteDistributionAuthorizer.action,
35
36
  resource,
36
37
  });
@@ -27,6 +27,7 @@ export class DeleteFunctionAuthorizer {
27
27
  if (decision.isDenied) {
28
28
  throw new SimIamAccessDenied({
29
29
  principal: decision.caller.principal,
30
+ reason: decision.denialReason,
30
31
  action: DeleteFunctionAuthorizer.action,
31
32
  resource,
32
33
  });
@@ -27,6 +27,7 @@ export class GetDistributionAuthorizer {
27
27
  if (decision.isDenied) {
28
28
  throw new SimIamAccessDenied({
29
29
  principal: decision.caller.principal,
30
+ reason: decision.denialReason,
30
31
  action: GetDistributionAuthorizer.action,
31
32
  resource,
32
33
  });
@@ -27,6 +27,7 @@ export class UpdateDistributionAuthorizer {
27
27
  if (decision.isDenied) {
28
28
  throw new SimIamAccessDenied({
29
29
  principal: decision.caller.principal,
30
+ reason: decision.denialReason,
30
31
  action: UpdateDistributionAuthorizer.action,
31
32
  resource,
32
33
  });
@@ -18,6 +18,7 @@ export function authorizeEdgeAssociation(iam, functionArn, caller) {
18
18
  if (decision.isDenied) {
19
19
  throw new SimIamAccessDenied({
20
20
  principal: decision.caller.principal,
21
+ reason: decision.denialReason,
21
22
  action,
22
23
  resource: functionArn,
23
24
  });
@@ -25,6 +25,7 @@ export class SimCfKeyValueStoreAccess {
25
25
  if (decision.isDenied) {
26
26
  throw new SimIamAccessDenied({
27
27
  principal: decision.caller.principal,
28
+ reason: decision.denialReason,
28
29
  action,
29
30
  resource,
30
31
  });
@@ -21,6 +21,7 @@ export function decideSimCloudWatchRequest(iam, request) {
21
21
  if (decision.isDenied) {
22
22
  throw new SimIamAccessDenied({
23
23
  principal: decision.caller.principal,
24
+ reason: decision.denialReason,
24
25
  action,
25
26
  resource,
26
27
  });
@@ -45,6 +45,7 @@ export class SimCognitoAuthorizer {
45
45
  if (decision.isDenied) {
46
46
  throw new SimIamAccessDenied({
47
47
  principal: decision.caller.principal,
48
+ reason: decision.denialReason,
48
49
  action,
49
50
  resource,
50
51
  });
@@ -56,6 +56,7 @@ export class SimDynamoDbAuthorizer {
56
56
  if (decision.isDenied) {
57
57
  throw new SimIamAccessDenied({
58
58
  principal: decision.caller.principal,
59
+ reason: decision.denialReason,
59
60
  action,
60
61
  resource,
61
62
  });
@@ -39,6 +39,7 @@ export class SimFirehoseAuthorizer {
39
39
  if (decision.isDenied) {
40
40
  throw new SimIamAccessDenied({
41
41
  principal: decision.caller.principal,
42
+ reason: decision.denialReason,
42
43
  action,
43
44
  resource,
44
45
  });
@@ -14,6 +14,7 @@ export function authorizeSimGlueResources(properties) {
14
14
  if (decision.isDenied) {
15
15
  throw new SimIamAccessDenied({
16
16
  principal: decision.caller.principal,
17
+ reason: decision.denialReason,
17
18
  action,
18
19
  resource,
19
20
  });