@kensio/yulin 1.21.4 → 1.21.6

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 (97) hide show
  1. package/dist/service/cloudformation/cdk/assets/sim-cdk-assets-publisher.d.ts +18 -13
  2. package/dist/service/cloudformation/cdk/assets/sim-cdk-assets-publisher.js +16 -24
  3. package/dist/service/cloudformation/cdk/sim-cdk-cloud-assembly.factory.d.ts +12 -0
  4. package/dist/service/cloudformation/cdk/sim-cdk-cloud-assembly.factory.js +16 -7
  5. package/dist/service/cloudformation/command/create-stack/create-stack.handler.d.ts +3 -0
  6. package/dist/service/cloudformation/command/create-stack/create-stack.handler.js +4 -1
  7. package/dist/service/cloudformation/command/update-stack/update-stack.handler.d.ts +6 -0
  8. package/dist/service/cloudformation/command/update-stack/update-stack.handler.js +7 -1
  9. package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-deployer.js +2 -1
  10. package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-options-deployed.d.ts +10 -0
  11. package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-options-deployed.js +14 -0
  12. package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-plan.d.ts +11 -1
  13. package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-plan.js +3 -2
  14. package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-stack-options.d.ts +5 -8
  15. package/dist/service/cloudformation/deploy/sim-cfn-cdk-out-stack-options.js +0 -14
  16. package/dist/service/cloudformation/deploy/sim-cfn-template-deployer.d.ts +9 -0
  17. package/dist/service/cloudformation/deploy/sim-cfn-template-deployer.js +2 -0
  18. package/dist/service/cloudformation/deploy/sim-cfn-template-file-loader.d.ts +10 -0
  19. package/dist/service/cloudformation/deploy/sim-cfn-template-file-loader.js +2 -1
  20. package/dist/service/cloudformation/deploy/sim-cfn-template-file-updater.js +1 -0
  21. package/dist/service/cloudformation/resource/cfn/sim-cfn-default-resource-value-adapter.d.ts +8 -1
  22. package/dist/service/cloudformation/resource/cfn/sim-cfn-default-resource-value-adapter.js +9 -2
  23. package/dist/service/cloudformation/resource/cfn/sim-cfn-resource-value-adapter.d.ts +6 -1
  24. package/dist/service/cloudformation/resource/cfn/sim-cfn-resource-value-adapter.js +2 -1
  25. package/dist/service/cloudformation/resource/create/sim-cfn-resource-create-operation.d.ts +4 -0
  26. package/dist/service/cloudformation/resource/create/sim-cfn-resource-create-operation.js +6 -0
  27. package/dist/service/cloudformation/resource/sim-cfn-resource-record.d.ts +19 -0
  28. package/dist/service/cloudformation/resource/sim-cfn-resource-record.js +26 -0
  29. package/dist/service/cloudformation/resource/sim-cfn-resource.js +1 -0
  30. package/dist/service/cloudformation/resource/unsupported/sim-cfn-named-skip.d.ts +26 -0
  31. package/dist/service/cloudformation/resource/unsupported/sim-cfn-named-skip.js +31 -0
  32. package/dist/service/cloudformation/stack/sim-cfn-stack-deploy-context.d.ts +47 -0
  33. package/dist/service/cloudformation/stack/sim-cfn-stack-deploy-context.js +46 -0
  34. package/dist/service/cloudformation/stack/sim-cfn-stack-resource-operations.d.ts +9 -19
  35. package/dist/service/cloudformation/stack/sim-cfn-stack-resource-operations.js +12 -26
  36. package/dist/service/cloudformation/stack/sim-cfn-stack.js +2 -1
  37. package/dist/service/cloudformation/stack/sim-cfn-stack.type.d.ts +14 -0
  38. package/dist/service/cloudfront/cfn/cache-policy/sim-cfn-cf-cache-policy-creator.d.ts +5 -2
  39. package/dist/service/cloudfront/cfn/cache-policy/sim-cfn-cf-cache-policy-creator.js +10 -2
  40. package/dist/service/cloudfront/cfn/origin-access-control/sim-cfn-cf-oac-creator.d.ts +5 -2
  41. package/dist/service/cloudfront/cfn/origin-access-control/sim-cfn-cf-oac-creator.js +10 -2
  42. package/dist/service/cloudfront/cfn/origin-request-policy/sim-cfn-cf-orp-creator.d.ts +5 -2
  43. package/dist/service/cloudfront/cfn/origin-request-policy/sim-cfn-cf-orp-creator.js +10 -2
  44. package/dist/service/cloudfront/cfn/policy/sim-cfn-cf-policy-creators.d.ts +33 -0
  45. package/dist/service/cloudfront/cfn/policy/sim-cfn-cf-policy-creators.js +39 -0
  46. package/dist/service/cloudfront/cfn/response-headers-policy/sim-cfn-cf-rh-policy-creator.d.ts +5 -2
  47. package/dist/service/cloudfront/cfn/response-headers-policy/sim-cfn-cf-rh-policy-creator.js +10 -2
  48. package/dist/service/cloudfront/cfn/sim-cfn-cf-authorizer.d.ts +40 -0
  49. package/dist/service/cloudfront/cfn/sim-cfn-cf-authorizer.js +50 -0
  50. package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.d.ts +1 -4
  51. package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.js +14 -46
  52. package/dist/service/cloudfront/sim-cloudfront-commands.d.ts +6 -0
  53. package/dist/service/cloudfront/sim-cloudfront-commands.js +7 -0
  54. package/dist/service/cloudfront/sim-cloudfront.d.ts +6 -0
  55. package/dist/service/cloudfront/sim-cloudfront.js +7 -0
  56. package/dist/service/dynamodb/document/sim-dynamodb-document-command-paths.d.ts +8 -0
  57. package/dist/service/dynamodb/document/sim-dynamodb-document-command-paths.js +62 -0
  58. package/dist/service/dynamodb/document/sim-dynamodb-document-routes.d.ts +1 -1
  59. package/dist/service/dynamodb/document/sim-dynamodb-document-routes.js +3 -1
  60. package/dist/service/iam/authorize/sim-iam-action-authorizer.d.ts +8 -3
  61. package/dist/service/iam/authorize/sim-iam-action-authorizer.js +13 -4
  62. package/dist/service/iam/cfn/role/sim-cfn-iam-role-creator.js +1 -0
  63. package/dist/service/iam/cfn/role/sim-cfn-iam-role-properties-parser.d.ts +1 -0
  64. package/dist/service/iam/cfn/role/sim-cfn-iam-role-properties-parser.js +21 -14
  65. package/dist/service/iam/cfn/{sim-cfn-iam-optional-string.d.ts → sim-cfn-iam-property.d.ts} +10 -2
  66. package/dist/service/iam/cfn/sim-cfn-iam-property.js +31 -0
  67. package/dist/service/iam/cfn/user/sim-cfn-iam-user-properties-parser.js +1 -1
  68. package/dist/service/iam/command/role/create-role/create-role-record-factory.js +3 -0
  69. package/dist/service/iam/command/role/create-role/create-role.command.d.ts +10 -0
  70. package/dist/service/iam/command/role/get-role/get-role.command.d.ts +2 -0
  71. package/dist/service/iam/command/role/get-role/get-role.handler.js +2 -0
  72. package/dist/service/iam/command/role/sim-iam-role-command-handlers.js +15 -1
  73. package/dist/service/iam/role/sim-iam-role-boundary.d.ts +24 -0
  74. package/dist/service/iam/role/sim-iam-role-boundary.js +24 -0
  75. package/dist/service/iam/role/sim-iam-role-with-policy.factory.d.ts +1 -0
  76. package/dist/service/iam/role/sim-iam-role.d.ts +10 -0
  77. package/dist/service/iam/serve/sim-iam-query-entity.d.ts +6 -1
  78. package/dist/service/iam/serve/sim-iam-query-entity.js +10 -4
  79. package/dist/service/iam/serve/sim-iam-query-role-operations.js +15 -3
  80. package/dist/service/lambda/cfn/function/sim-cfn-lambda-runtime-skip.d.ts +6 -0
  81. package/dist/service/lambda/cfn/function/sim-cfn-lambda-runtime-skip.js +9 -2
  82. package/dist/service/route53/command/create-hosted-zone/sim-route53-zone-id.js +23 -1
  83. package/dist/service/s3/bucket/sim-s3-bucket-maker.d.ts +31 -0
  84. package/dist/service/s3/bucket/sim-s3-bucket-maker.js +41 -0
  85. package/dist/service/s3/command/create-bucket/create-bucket.handler.d.ts +2 -2
  86. package/dist/service/s3/command/create-bucket/create-bucket.handler.js +4 -12
  87. package/dist/service/s3/sim-s3-commands.d.ts +6 -0
  88. package/dist/service/s3/sim-s3-commands.js +7 -0
  89. package/dist/service/s3/sim-s3.d.ts +16 -0
  90. package/dist/service/s3/sim-s3.js +25 -0
  91. package/docs/services/cloudformation/README.md +144 -25
  92. package/docs/services/cloudfront/README.md +109 -0
  93. package/docs/services/dynamodb/README.md +128 -8
  94. package/docs/services/iam/README.md +125 -2
  95. package/docs/services/route53/README.md +11 -0
  96. package/package.json +2 -2
  97. package/dist/service/iam/cfn/sim-cfn-iam-optional-string.js +0 -17
@@ -4,6 +4,8 @@ import { SimCfnCfOriginRequestPolicyConfig } from "./sim-cfn-cf-orp-config.js";
4
4
  * AWS::CloudFront::OriginRequestPolicy Resources.
5
5
  */
6
6
  export class SimCfnCfOriginRequestPolicyCreator {
7
+ static createAction = "cloudfront:CreateOriginRequestPolicy";
8
+ static deleteAction = "cloudfront:DeleteOriginRequestPolicy";
7
9
  cloudFront;
8
10
  constructor(properties) {
9
11
  this.cloudFront = properties.cloudFront;
@@ -11,7 +13,10 @@ export class SimCfnCfOriginRequestPolicyCreator {
11
13
  /**
12
14
  * Create and store the policy one Resource describes.
13
15
  */
14
- create(resource, properties) {
16
+ create(resource, properties, options) {
17
+ this.cloudFront
18
+ .cfnAuthorizer()
19
+ .authorizeAny(SimCfnCfOriginRequestPolicyCreator.createAction, options);
15
20
  const policy = new SimCfnCfOriginRequestPolicyConfig({
16
21
  resource,
17
22
  properties,
@@ -22,11 +27,14 @@ export class SimCfnCfOriginRequestPolicyCreator {
22
27
  /**
23
28
  * Remove a policy created from a Resource.
24
29
  */
25
- delete(resource) {
30
+ delete(resource, options) {
26
31
  const policy = resource.simResource;
27
32
  if (policy === undefined) {
28
33
  return;
29
34
  }
35
+ this.cloudFront
36
+ .cfnAuthorizer()
37
+ .authorizeResource(SimCfnCfOriginRequestPolicyCreator.deleteAction, `origin-request-policy/${policy.id}`, options);
30
38
  this.cloudFront.removeOriginRequestPolicy(policy.id);
31
39
  }
32
40
  }
@@ -0,0 +1,33 @@
1
+ import type { SimCfnResourceCallerOptions } from "../../../cloudformation/resource/caller/sim-cfn-resource-caller-options.js";
2
+ import type { SimCfnResource } from "../../../cloudformation/resource/sim-cfn-resource.js";
3
+ import type { SimCfnTemplateValueRecord } from "../../../cloudformation/template/value/sim-cfn-template-value.js";
4
+ import type { SimCloudFront } from "../../sim-cloudfront.js";
5
+ /**
6
+ * What the four creators in here have in common.
7
+ *
8
+ * Each builds its own kind of policy from a Resource's properties and stores
9
+ * it on the simulated CloudFront, and each authorizes the deployment's caller
10
+ * for its own pair of actions.
11
+ */
12
+ interface SimCfnCfPolicyCreator {
13
+ create(resource: SimCfnResource, properties: SimCfnTemplateValueRecord, options?: SimCfnResourceCallerOptions): object;
14
+ delete(resource: SimCfnResource, options?: SimCfnResourceCallerOptions): void;
15
+ }
16
+ /**
17
+ * The CloudFront Resource types a template is the only way to make.
18
+ *
19
+ * A cache policy, an origin request policy, a response headers policy and an
20
+ * origin access control have no SDK command here. The Resource factory hands
21
+ * all four to this one lookup, and its own switch stays about the Resource
22
+ * types a command creates.
23
+ */
24
+ export declare class SimCfnCfPolicyCreators {
25
+ private readonly creators;
26
+ constructor(cloudFront: SimCloudFront);
27
+ /**
28
+ * The creator owning one Resource type, or nothing where another part of
29
+ * the factory owns it.
30
+ */
31
+ creatorFor(resourceTypeName: string): SimCfnCfPolicyCreator | undefined;
32
+ }
33
+ export {};
@@ -0,0 +1,39 @@
1
+ import { SimCfnCfCachePolicyCreator } from "../cache-policy/sim-cfn-cf-cache-policy-creator.js";
2
+ import { SimCfnCfOriginAccessControlCreator } from "../origin-access-control/sim-cfn-cf-oac-creator.js";
3
+ import { SimCfnCfOriginRequestPolicyCreator } from "../origin-request-policy/sim-cfn-cf-orp-creator.js";
4
+ import { SimCfnCfResponseHeadersPolicyCreator } from "../response-headers-policy/sim-cfn-cf-rh-policy-creator.js";
5
+ /**
6
+ * The CloudFront Resource types a template is the only way to make.
7
+ *
8
+ * A cache policy, an origin request policy, a response headers policy and an
9
+ * origin access control have no SDK command here. The Resource factory hands
10
+ * all four to this one lookup, and its own switch stays about the Resource
11
+ * types a command creates.
12
+ */
13
+ export class SimCfnCfPolicyCreators {
14
+ creators;
15
+ constructor(cloudFront) {
16
+ this.creators = new Map([
17
+ [
18
+ "ResponseHeadersPolicy",
19
+ new SimCfnCfResponseHeadersPolicyCreator({ cloudFront }),
20
+ ],
21
+ ["CachePolicy", new SimCfnCfCachePolicyCreator({ cloudFront })],
22
+ [
23
+ "OriginRequestPolicy",
24
+ new SimCfnCfOriginRequestPolicyCreator({ cloudFront }),
25
+ ],
26
+ [
27
+ "OriginAccessControl",
28
+ new SimCfnCfOriginAccessControlCreator({ cloudFront }),
29
+ ],
30
+ ]);
31
+ }
32
+ /**
33
+ * The creator owning one Resource type, or nothing where another part of
34
+ * the factory owns it.
35
+ */
36
+ creatorFor(resourceTypeName) {
37
+ return this.creators.get(resourceTypeName);
38
+ }
39
+ }
@@ -1,3 +1,4 @@
1
+ import type { SimCfnResourceCallerOptions } from "../../../cloudformation/resource/caller/sim-cfn-resource-caller-options.js";
1
2
  import type { SimCfnResource } from "../../../cloudformation/resource/sim-cfn-resource.js";
2
3
  import type { SimCfnTemplateValueRecord } from "../../../cloudformation/template/value/sim-cfn-template-value.js";
3
4
  import type { SimCloudFront } from "../../sim-cloudfront.js";
@@ -10,15 +11,17 @@ interface SimCfnCfResponseHeadersPolicyCreatorProperties {
10
11
  * AWS::CloudFront::ResponseHeadersPolicy Resources.
11
12
  */
12
13
  export declare class SimCfnCfResponseHeadersPolicyCreator {
14
+ private static readonly createAction;
15
+ private static readonly deleteAction;
13
16
  private readonly cloudFront;
14
17
  constructor(properties: SimCfnCfResponseHeadersPolicyCreatorProperties);
15
18
  /**
16
19
  * Create and store the policy one Resource describes.
17
20
  */
18
- create(resource: SimCfnResource, properties: SimCfnTemplateValueRecord): SimCloudFrontResponseHeadersPolicy;
21
+ create(resource: SimCfnResource, properties: SimCfnTemplateValueRecord, options?: SimCfnResourceCallerOptions): SimCloudFrontResponseHeadersPolicy;
19
22
  /**
20
23
  * Remove a policy created from a Resource.
21
24
  */
22
- delete(resource: SimCfnResource): void;
25
+ delete(resource: SimCfnResource, options?: SimCfnResourceCallerOptions): void;
23
26
  }
24
27
  export {};
@@ -4,6 +4,8 @@ import { SimCfnCfResponseHeadersPolicyConfig } from "./sim-cfn-cf-rh-policy-conf
4
4
  * AWS::CloudFront::ResponseHeadersPolicy Resources.
5
5
  */
6
6
  export class SimCfnCfResponseHeadersPolicyCreator {
7
+ static createAction = "cloudfront:CreateResponseHeadersPolicy";
8
+ static deleteAction = "cloudfront:DeleteResponseHeadersPolicy";
7
9
  cloudFront;
8
10
  constructor(properties) {
9
11
  this.cloudFront = properties.cloudFront;
@@ -11,7 +13,10 @@ export class SimCfnCfResponseHeadersPolicyCreator {
11
13
  /**
12
14
  * Create and store the policy one Resource describes.
13
15
  */
14
- create(resource, properties) {
16
+ create(resource, properties, options) {
17
+ this.cloudFront
18
+ .cfnAuthorizer()
19
+ .authorizeAny(SimCfnCfResponseHeadersPolicyCreator.createAction, options);
15
20
  const policy = new SimCfnCfResponseHeadersPolicyConfig({
16
21
  resource,
17
22
  properties,
@@ -22,11 +27,14 @@ export class SimCfnCfResponseHeadersPolicyCreator {
22
27
  /**
23
28
  * Remove a policy created from a Resource.
24
29
  */
25
- delete(resource) {
30
+ delete(resource, options) {
26
31
  const policy = resource.simResource;
27
32
  if (policy === undefined) {
28
33
  return;
29
34
  }
35
+ this.cloudFront
36
+ .cfnAuthorizer()
37
+ .authorizeResource(SimCfnCfResponseHeadersPolicyCreator.deleteAction, `response-headers-policy/${policy.id}`, options);
30
38
  this.cloudFront.removeResponseHeadersPolicy(policy.id);
31
39
  }
32
40
  }
@@ -0,0 +1,40 @@
1
+ import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
2
+ import type { SimCfnResourceCallerOptions } from "../../cloudformation/resource/caller/sim-cfn-resource-caller-options.js";
3
+ import type { SimIamInterServiceAuthZ } from "../../iam/authorize/sim-iam-inter-service-auth-z.js";
4
+ interface SimCfnCfAuthorizerProperties {
5
+ readonly accountId: SimAwsAccountId;
6
+ readonly iam: SimIamInterServiceAuthZ;
7
+ }
8
+ /**
9
+ * Authorizes the CloudFront Resources a template is the only way to make.
10
+ *
11
+ * A cache policy, an origin request policy, a response headers policy and an
12
+ * origin access control have no SDK command here, so their CloudFormation
13
+ * creators reach the stored policy directly rather than through a command that
14
+ * would ask IAM on the way. This is where those creators ask instead, so a
15
+ * deploy Role holding no CloudFront permission is refused the way real
16
+ * CloudFormation refuses it.
17
+ */
18
+ export declare class SimCfnCfAuthorizer {
19
+ private readonly accountId;
20
+ private readonly iam;
21
+ constructor(properties: SimCfnCfAuthorizerProperties);
22
+ /**
23
+ * Ensure the caller may take an action that names nothing yet.
24
+ *
25
+ * A create action has no ID to authorize against until it succeeds, and
26
+ * CloudFront offers no resource-level permission for one, so a policy
27
+ * granting it writes `*` and that is what it is decided against.
28
+ */
29
+ authorizeAny(action: string, options?: SimCfnResourceCallerOptions): void;
30
+ /**
31
+ * Ensure the caller may take an action on the CloudFront resource a path
32
+ * names, such as `cache-policy/8f1a2b3c`.
33
+ *
34
+ * A delete names the thing it is deleting, so a policy can grant deleting
35
+ * one cache policy without granting deleting every cache policy in the
36
+ * Account.
37
+ */
38
+ authorizeResource(action: string, resourcePath: string, options?: SimCfnResourceCallerOptions): void;
39
+ }
40
+ export {};
@@ -0,0 +1,50 @@
1
+ import { simCfAuthorize } from "../sim-cf-authorize.js";
2
+ /**
3
+ * Authorizes the CloudFront Resources a template is the only way to make.
4
+ *
5
+ * A cache policy, an origin request policy, a response headers policy and an
6
+ * origin access control have no SDK command here, so their CloudFormation
7
+ * creators reach the stored policy directly rather than through a command that
8
+ * would ask IAM on the way. This is where those creators ask instead, so a
9
+ * deploy Role holding no CloudFront permission is refused the way real
10
+ * CloudFormation refuses it.
11
+ */
12
+ export class SimCfnCfAuthorizer {
13
+ accountId;
14
+ iam;
15
+ constructor(properties) {
16
+ this.accountId = properties.accountId;
17
+ this.iam = properties.iam;
18
+ }
19
+ /**
20
+ * Ensure the caller may take an action that names nothing yet.
21
+ *
22
+ * A create action has no ID to authorize against until it succeeds, and
23
+ * CloudFront offers no resource-level permission for one, so a policy
24
+ * granting it writes `*` and that is what it is decided against.
25
+ */
26
+ authorizeAny(action, options) {
27
+ simCfAuthorize({
28
+ iam: this.iam,
29
+ action,
30
+ resource: "*",
31
+ caller: options?.caller,
32
+ });
33
+ }
34
+ /**
35
+ * Ensure the caller may take an action on the CloudFront resource a path
36
+ * names, such as `cache-policy/8f1a2b3c`.
37
+ *
38
+ * A delete names the thing it is deleting, so a policy can grant deleting
39
+ * one cache policy without granting deleting every cache policy in the
40
+ * Account.
41
+ */
42
+ authorizeResource(action, resourcePath, options) {
43
+ simCfAuthorize({
44
+ iam: this.iam,
45
+ action,
46
+ resource: `arn:aws:cloudfront::${this.accountId}:${resourcePath}`,
47
+ caller: options?.caller,
48
+ });
49
+ }
50
+ }
@@ -8,10 +8,7 @@ export declare class SimCloudFrontCloudFormationResourceFactory implements SimCf
8
8
  private readonly distroCreator;
9
9
  private readonly functionCreator;
10
10
  private readonly distroDeleter;
11
- private readonly responseHeadersPolicyCreator;
12
- private readonly cachePolicyCreator;
13
- private readonly originRequestPolicyCreator;
14
- private readonly originAccessControlCreator;
11
+ private readonly policyCreators;
15
12
  private readonly keyValueStoreCreator;
16
13
  constructor(cloudFront: SimCloudFront);
17
14
  /**
@@ -2,10 +2,7 @@ import { simCfnResourceCallerOptions } from "../../cloudformation/resource/calle
2
2
  import { SimCfnCfDistroCreator } from "./distro/sim-cfn-cf-distro-creator.js";
3
3
  import { SimCfnCffCreator } from "./cff/sim-cfn-cff-creator.js";
4
4
  import { SimCfnCfDistroDeleter } from "./distro/sim-cfn-cf-distro-deleter.js";
5
- import { SimCfnCfResponseHeadersPolicyCreator } from "./response-headers-policy/sim-cfn-cf-rh-policy-creator.js";
6
- import { SimCfnCfCachePolicyCreator } from "./cache-policy/sim-cfn-cf-cache-policy-creator.js";
7
- import { SimCfnCfOriginRequestPolicyCreator } from "./origin-request-policy/sim-cfn-cf-orp-creator.js";
8
- import { SimCfnCfOriginAccessControlCreator } from "./origin-access-control/sim-cfn-cf-oac-creator.js";
5
+ import { SimCfnCfPolicyCreators } from "./policy/sim-cfn-cf-policy-creators.js";
9
6
  import { SimCfnCfKeyValueStoreCreator } from "./key-value-store/sim-cfn-cf-kvs-creator.js";
10
7
  /**
11
8
  * CloudFormation Resource factory for simulated CloudFront resources.
@@ -14,24 +11,13 @@ export class SimCloudFrontCloudFormationResourceFactory {
14
11
  distroCreator;
15
12
  functionCreator;
16
13
  distroDeleter;
17
- responseHeadersPolicyCreator;
18
- cachePolicyCreator;
19
- originRequestPolicyCreator;
20
- originAccessControlCreator;
14
+ policyCreators;
21
15
  keyValueStoreCreator;
22
16
  constructor(cloudFront) {
23
17
  this.distroCreator = new SimCfnCfDistroCreator({ cloudFront });
24
18
  this.functionCreator = new SimCfnCffCreator({ cloudFront });
25
19
  this.distroDeleter = new SimCfnCfDistroDeleter({ cloudFront });
26
- this.responseHeadersPolicyCreator =
27
- new SimCfnCfResponseHeadersPolicyCreator({ cloudFront });
28
- this.cachePolicyCreator = new SimCfnCfCachePolicyCreator({ cloudFront });
29
- this.originRequestPolicyCreator = new SimCfnCfOriginRequestPolicyCreator({
30
- cloudFront,
31
- });
32
- this.originAccessControlCreator = new SimCfnCfOriginAccessControlCreator({
33
- cloudFront,
34
- });
20
+ this.policyCreators = new SimCfnCfPolicyCreators(cloudFront);
35
21
  this.keyValueStoreCreator = new SimCfnCfKeyValueStoreCreator({
36
22
  cloudFront,
37
23
  });
@@ -41,6 +27,11 @@ export class SimCloudFrontCloudFormationResourceFactory {
41
27
  */
42
28
  async create(resourceTypeName, resource, context) {
43
29
  const properties = context.resolvedProperties ?? resource.properties;
30
+ const options = simCfnResourceCallerOptions(context.caller);
31
+ const policyCreator = this.policyCreators.creatorFor(resourceTypeName);
32
+ if (policyCreator !== undefined) {
33
+ return policyCreator.create(resource, properties, options);
34
+ }
44
35
  switch (resourceTypeName) {
45
36
  case "Distribution": {
46
37
  return await this.distroCreator.create(resource, properties, context);
@@ -48,20 +39,8 @@ export class SimCloudFrontCloudFormationResourceFactory {
48
39
  case "Function": {
49
40
  return await this.functionCreator.create(resource, properties, context);
50
41
  }
51
- case "ResponseHeadersPolicy": {
52
- return this.responseHeadersPolicyCreator.create(resource, properties);
53
- }
54
- case "CachePolicy": {
55
- return this.cachePolicyCreator.create(resource, properties);
56
- }
57
- case "OriginRequestPolicy": {
58
- return this.originRequestPolicyCreator.create(resource, properties);
59
- }
60
- case "OriginAccessControl": {
61
- return this.originAccessControlCreator.create(resource, properties);
62
- }
63
42
  case "KeyValueStore": {
64
- return await this.keyValueStoreCreator.create(resource, properties, simCfnResourceCallerOptions(context.caller));
43
+ return await this.keyValueStoreCreator.create(resource, properties, options);
65
44
  }
66
45
  default: {
67
46
  throw new Error(`Unsupported sim CloudFront CloudFormation Resource ${resourceTypeName}`);
@@ -74,6 +53,11 @@ export class SimCloudFrontCloudFormationResourceFactory {
74
53
  */
75
54
  async delete(resourceTypeName, resource, context) {
76
55
  const options = simCfnResourceCallerOptions(context.caller);
56
+ const policyCreator = this.policyCreators.creatorFor(resourceTypeName);
57
+ if (policyCreator !== undefined) {
58
+ policyCreator.delete(resource, options);
59
+ return;
60
+ }
77
61
  switch (resourceTypeName) {
78
62
  case "Distribution": {
79
63
  await this.distroDeleter.delete(resource, options);
@@ -83,22 +67,6 @@ export class SimCloudFrontCloudFormationResourceFactory {
83
67
  await this.functionCreator.delete(resource, options);
84
68
  return;
85
69
  }
86
- case "ResponseHeadersPolicy": {
87
- this.responseHeadersPolicyCreator.delete(resource);
88
- return;
89
- }
90
- case "CachePolicy": {
91
- this.cachePolicyCreator.delete(resource);
92
- return;
93
- }
94
- case "OriginRequestPolicy": {
95
- this.originRequestPolicyCreator.delete(resource);
96
- return;
97
- }
98
- case "OriginAccessControl": {
99
- this.originAccessControlCreator.delete(resource);
100
- return;
101
- }
102
70
  case "KeyValueStore": {
103
71
  await this.keyValueStoreCreator.delete(resource, options);
104
72
  return;
@@ -23,6 +23,7 @@ import { SimCfKeyValueStoreCommands } from "./key-value-store/sim-cf-key-value-s
23
23
  import { SimCloudFrontKeyValueStoreApi } from "./sim-cloudfront-key-value-store.js";
24
24
  import { SimCfFunctionCommands } from "./cff/sim-cf-function-commands.js";
25
25
  import { SimCfInvalidationCommands } from "./command/invalidation/sim-cf-invalidation-commands.js";
26
+ import { SimCfnCfAuthorizer } from "./cfn/sim-cfn-cf-authorizer.js";
26
27
  /**
27
28
  * How one simulated CloudFront is put together.
28
29
  */
@@ -92,6 +93,11 @@ export declare class SimCloudFrontCommands {
92
93
  * The invalidation commands, and the Distributions they clear.
93
94
  */
94
95
  readonly invalidations: SimCfInvalidationCommands;
96
+ /**
97
+ * How the CloudFormation Resource factory authorizes the Resources it
98
+ * creates without a command of their own.
99
+ */
100
+ readonly cfnAuthorizer: SimCfnCfAuthorizer;
95
101
  private readonly distributionState;
96
102
  private readonly configurationState;
97
103
  constructor(properties: SimCloudFrontCommandsProperties);
@@ -13,6 +13,7 @@ import { SimCloudFrontKeyValueStoreApi } from "./sim-cloudfront-key-value-store.
13
13
  import { SimCffKeyValueStoreUsers } from "./cff/kvs/sim-cff-key-value-store-users.js";
14
14
  import { SimCfFunctionCommands } from "./cff/sim-cf-function-commands.js";
15
15
  import { SimCfInvalidationCommands } from "./command/invalidation/sim-cf-invalidation-commands.js";
16
+ import { SimCfnCfAuthorizer } from "./cfn/sim-cfn-cf-authorizer.js";
16
17
  /**
17
18
  * The commands of one simulated CloudFront, and the state they share.
18
19
  *
@@ -45,6 +46,11 @@ export class SimCloudFrontCommands {
45
46
  * The invalidation commands, and the Distributions they clear.
46
47
  */
47
48
  invalidations;
49
+ /**
50
+ * How the CloudFormation Resource factory authorizes the Resources it
51
+ * creates without a command of their own.
52
+ */
53
+ cfnAuthorizer;
48
54
  distributionState;
49
55
  configurationState;
50
56
  constructor(properties) {
@@ -74,6 +80,7 @@ export class SimCloudFrontCommands {
74
80
  iam,
75
81
  background,
76
82
  });
83
+ this.cfnAuthorizer = new SimCfnCfAuthorizer({ accountId, iam });
77
84
  this.configurationState = {
78
85
  s3OriginResolver,
79
86
  customOriginDispatcher,
@@ -2,6 +2,7 @@ import type { SimArn } from "../aws/arn.js";
2
2
  import type { SimCfnServiceResourceFactory } from "../cloudformation/resource/factory/sim-cfn-resource-factory.type.js";
3
3
  import type { SimSdkCommandRouter } from "../../sdk/router/sim-sdk-command-router.type.js";
4
4
  import type { SimCloudFrontFunction, SimCloudFrontFunctionName } from "./cff/sim-cloudfront-function.js";
5
+ import type { SimCfnCfAuthorizer } from "./cfn/sim-cfn-cf-authorizer.js";
5
6
  import type { SimCreateDistributionCommand, SimCreateDistributionCommandOutput } from "./command/create-distribution/create-distribution.command.js";
6
7
  import type { SimCreateFunctionCommand, SimCreateFunctionCommandOutput } from "./command/create-function/create-function.command.js";
7
8
  import type { SimDeleteDistributionCommand, SimDeleteDistributionCommandOutput } from "./command/delete-distribution/delete-distribution.command.js";
@@ -92,6 +93,11 @@ export declare class SimCloudFront extends SimCloudFrontDistributions {
92
93
  * Get a sim CloudFront Function by name.
93
94
  */
94
95
  getCloudFrontFunctionByName(cloudFrontFunctionName: SimCloudFrontFunctionName | string): SimCloudFrontFunction | undefined;
96
+ /**
97
+ * How the CloudFormation Resource factory authorizes a deployment's caller
98
+ * for the Resources it creates without a command of their own.
99
+ */
100
+ cfnAuthorizer(): SimCfnCfAuthorizer;
95
101
  /**
96
102
  * Get this service's CloudFormation Resource factory.
97
103
  */
@@ -129,6 +129,13 @@ export class SimCloudFront extends SimCloudFrontDistributions {
129
129
  getCloudFrontFunctionByName(cloudFrontFunctionName) {
130
130
  return this.cloudFrontFunctions.get(cloudFrontFunctionName);
131
131
  }
132
+ /**
133
+ * How the CloudFormation Resource factory authorizes a deployment's caller
134
+ * for the Resources it creates without a command of their own.
135
+ */
136
+ cfnAuthorizer() {
137
+ return this.commands.cfnAuthorizer;
138
+ }
132
139
  /**
133
140
  * Get this service's CloudFormation Resource factory.
134
141
  */
@@ -54,4 +54,12 @@ export declare const simDynamoDbDocumentCommandPaths: {
54
54
  readonly input: SimDynamoDbDocumentPath;
55
55
  readonly output: SimDynamoDbDocumentPath;
56
56
  };
57
+ readonly transactWrite: {
58
+ readonly input: SimDynamoDbDocumentPath;
59
+ readonly output: SimDynamoDbDocumentPath;
60
+ };
61
+ readonly transactGet: {
62
+ readonly input: SimDynamoDbDocumentPath;
63
+ readonly output: SimDynamoDbDocumentPath;
64
+ };
57
65
  };
@@ -47,6 +47,58 @@ const batchWriteRequests = simDynamoDbDocumentEach(simDynamoDbDocumentEach(batch
47
47
  * The keys every table is read by in a batch get.
48
48
  */
49
49
  const batchGetKeys = simDynamoDbDocumentEach(simDynamoDbDocumentFields({ Keys: valueRecords }));
50
+ /**
51
+ * One action of a transactional write that names an item by its key, which a
52
+ * ConditionCheck, a Delete and an Update all do.
53
+ */
54
+ const transactWriteKeyed = simDynamoDbDocumentFields({
55
+ Key: simDynamoDbDocumentValues(),
56
+ ExpressionAttributeValues: simDynamoDbDocumentValues(),
57
+ });
58
+ /**
59
+ * The Put of a transactional write, which carries a whole item.
60
+ */
61
+ const transactWritePut = simDynamoDbDocumentFields({
62
+ Item: simDynamoDbDocumentValues(),
63
+ ExpressionAttributeValues: simDynamoDbDocumentValues(),
64
+ });
65
+ /**
66
+ * The actions a transactional write applies.
67
+ *
68
+ * An entry carries exactly one of the four, so each is named here and the
69
+ * three the entry left out are left out of the conversion with it. Every
70
+ * action carries its own condition, so its expression values are converted
71
+ * alongside the item they compare against.
72
+ */
73
+ const transactWriteActions = simDynamoDbDocumentEach(simDynamoDbDocumentFields({
74
+ ConditionCheck: transactWriteKeyed,
75
+ Put: transactWritePut,
76
+ Delete: transactWriteKeyed,
77
+ Update: transactWriteKeyed,
78
+ }));
79
+ /**
80
+ * One Get of a transactional read, which names an item by its key.
81
+ */
82
+ const transactGet = simDynamoDbDocumentFields({
83
+ Get: simDynamoDbDocumentFields({ Key: simDynamoDbDocumentValues() }),
84
+ });
85
+ /**
86
+ * What a transactional read answers with, one entry per Get.
87
+ */
88
+ const transactGetResponses = simDynamoDbDocumentEach(simDynamoDbDocumentFields({ Item: simDynamoDbDocumentValues() }));
89
+ /**
90
+ * What a transactional write answers with, which is nothing to convert.
91
+ *
92
+ * `ItemCollectionMetrics` is the one place the real document client converts
93
+ * this output, and it is only reported when a request asks for it with
94
+ * `ReturnItemCollectionMetrics`, which simulated DynamoDB refuses.
95
+ *
96
+ * A cancelled transaction is not converted either. `CancellationReasons` reach
97
+ * a caller on a thrown `TransactionCanceledException` rather than in an
98
+ * answer, and the real document client leaves the `Item` of a reason as the
99
+ * descriptors the low-level Command reports.
100
+ */
101
+ const transactWritten = simDynamoDbDocumentFields({});
50
102
  /**
51
103
  * Where each supported document Command carries native values.
52
104
  *
@@ -108,4 +160,14 @@ export const simDynamoDbDocumentCommandPaths = {
108
160
  UnprocessedKeys: batchGetKeys,
109
161
  }),
110
162
  },
163
+ transactWrite: {
164
+ input: simDynamoDbDocumentFields({ TransactItems: transactWriteActions }),
165
+ output: transactWritten,
166
+ },
167
+ transactGet: {
168
+ input: simDynamoDbDocumentFields({
169
+ TransactItems: simDynamoDbDocumentEach(transactGet),
170
+ }),
171
+ output: simDynamoDbDocumentFields({ Responses: transactGetResponses }),
172
+ },
111
173
  };
@@ -25,7 +25,7 @@ export declare function simDynamoDbDocumentSharedNameRoutes(dynamoDb: SimDynamoD
25
25
  * so are routed by `simDynamoDbDocumentSharedNameRoutes` instead.
26
26
  *
27
27
  * An operation with no document route at all, such as a document
28
- * `TransactWriteCommand`, is refused by name like any other unsupported
28
+ * `ExecuteStatementCommand`, is refused by name like any other unsupported
29
29
  * Command, rather than failing part way through a conversion.
30
30
  */
31
31
  export declare function simDynamoDbDocumentRoutes(dynamoDb: SimDynamoDb): readonly (readonly [string, SimSdkCommandRoute])[];
@@ -43,7 +43,7 @@ export function simDynamoDbDocumentSharedNameRoutes(dynamoDb) {
43
43
  * so are routed by `simDynamoDbDocumentSharedNameRoutes` instead.
44
44
  *
45
45
  * An operation with no document route at all, such as a document
46
- * `TransactWriteCommand`, is refused by name like any other unsupported
46
+ * `ExecuteStatementCommand`, is refused by name like any other unsupported
47
47
  * Command, rather than failing part way through a conversion.
48
48
  */
49
49
  export function simDynamoDbDocumentRoutes(dynamoDb) {
@@ -54,5 +54,7 @@ export function simDynamoDbDocumentRoutes(dynamoDb) {
54
54
  namedDocumentRoute("UpdateCommand", paths.update, async (input, options) => await dynamoDb.updateItem({ input }, options)),
55
55
  namedDocumentRoute("BatchWriteCommand", paths.batchWrite, async (input, options) => await dynamoDb.batchWriteItem({ input }, options)),
56
56
  namedDocumentRoute("BatchGetCommand", paths.batchGet, async (input, options) => await dynamoDb.batchGetItem({ input }, options)),
57
+ namedDocumentRoute("TransactWriteCommand", paths.transactWrite, async (input, options) => await dynamoDb.transactWriteItems({ input }, options)),
58
+ namedDocumentRoute("TransactGetCommand", paths.transactGet, async (input, options) => await dynamoDb.transactGetItems({ input }, options)),
57
59
  ];
58
60
  }
@@ -1,4 +1,5 @@
1
1
  import type { SimAwsCaller } from "../../aws/caller/sim-aws-caller.js";
2
+ import type { SimIamConditionValue } from "../policy/sim-iam-policy.js";
2
3
  import type { SimIamInterServiceAuthZ } from "./sim-iam-inter-service-auth-z.js";
3
4
  interface SimIamActionAuthorizerProperties {
4
5
  readonly iam: SimIamInterServiceAuthZ;
@@ -9,8 +10,9 @@ interface SimIamActionAuthorizerProperties {
9
10
  *
10
11
  * This shared authorizer suits services whose commands map one-to-one onto an
11
12
  * IAM action and resource ARN, such as the IAM and CloudFormation control
12
- * planes. Commands needing richer context, such as condition values, use
13
- * their own per-command authorizers instead.
13
+ * planes. A command carrying a condition value of its own passes it here.
14
+ * Commands needing more than that, such as a service that hands a Role over,
15
+ * use their own per-command authorizers instead.
14
16
  */
15
17
  export declare class SimIamActionAuthorizer {
16
18
  private readonly iam;
@@ -21,7 +23,10 @@ export declare class SimIamActionAuthorizer {
21
23
  * The caller is passed through unchanged so sim IAM can distinguish an
22
24
  * omitted caller, which defaults to Account root, from an explicit
23
25
  * anonymous caller, which has no identity policy permissions.
26
+ *
27
+ * Condition values the request itself carries are supplied last, since most
28
+ * commands carry none and read better without an empty record.
24
29
  */
25
- authorize(action: string, resource: string, caller?: SimAwsCaller): void;
30
+ authorize(action: string, resource: string, caller?: SimAwsCaller, conditionContext?: Readonly<Record<string, SimIamConditionValue>>): void;
26
31
  }
27
32
  export {};
@@ -5,8 +5,9 @@ import { SimIamAccessDenied } from "../error/sim-iam.error.js";
5
5
  *
6
6
  * This shared authorizer suits services whose commands map one-to-one onto an
7
7
  * IAM action and resource ARN, such as the IAM and CloudFormation control
8
- * planes. Commands needing richer context, such as condition values, use
9
- * their own per-command authorizers instead.
8
+ * planes. A command carrying a condition value of its own passes it here.
9
+ * Commands needing more than that, such as a service that hands a Role over,
10
+ * use their own per-command authorizers instead.
10
11
  */
11
12
  export class SimIamActionAuthorizer {
12
13
  iam;
@@ -19,9 +20,17 @@ export class SimIamActionAuthorizer {
19
20
  * The caller is passed through unchanged so sim IAM can distinguish an
20
21
  * omitted caller, which defaults to Account root, from an explicit
21
22
  * anonymous caller, which has no identity policy permissions.
23
+ *
24
+ * Condition values the request itself carries are supplied last, since most
25
+ * commands carry none and read better without an empty record.
22
26
  */
23
- authorize(action, resource, caller) {
24
- const decision = this.iam.authorize({ action, resource, caller });
27
+ authorize(action, resource, caller, conditionContext) {
28
+ const decision = this.iam.authorize({
29
+ action,
30
+ resource,
31
+ caller,
32
+ conditionContext,
33
+ });
25
34
  if (decision.isDenied) {
26
35
  throw new SimIamAccessDenied({
27
36
  principal: decision.caller.principal,
@@ -20,6 +20,7 @@ export class SimCfnIamRoleCreator {
20
20
  Path: roleProperties.path,
21
21
  Description: roleProperties.description,
22
22
  AssumeRolePolicyDocument: roleProperties.assumeRolePolicyDocument,
23
+ PermissionsBoundary: roleProperties.permissionsBoundary,
23
24
  },
24
25
  }, options);
25
26
  await Promise.all([