sst 2.0.15 → 2.0.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.
@@ -37,15 +37,7 @@ export class Auth extends Construct {
37
37
  this.id = id;
38
38
  const stack = Stack.of(scope);
39
39
  this.authenticator = props.authenticator;
40
- new CustomResource(this, "StackMetadata", {
41
- serviceToken: stack.customResourceHandler.functionArn,
42
- resourceType: "Custom::AuthKeys",
43
- properties: {
44
- publicPath: getParameterPath(this, PUBLIC_KEY_PROP),
45
- privatePath: getParameterPath(this, PRIVATE_KEY_PROP),
46
- },
47
- });
48
- stack.customResourceHandler.role?.attachInlinePolicy(new Policy(this, "CloudFrontInvalidatorPolicy", {
40
+ const policy = new Policy(this, "CloudFrontInvalidatorPolicy", {
49
41
  statements: [
50
42
  new PolicyStatement({
51
43
  actions: [
@@ -58,7 +50,17 @@ export class Auth extends Construct {
58
50
  ],
59
51
  }),
60
52
  ],
61
- }));
53
+ });
54
+ stack.customResourceHandler.role?.attachInlinePolicy(policy);
55
+ const resource = new CustomResource(this, "StackMetadata", {
56
+ serviceToken: stack.customResourceHandler.functionArn,
57
+ resourceType: "Custom::AuthKeys",
58
+ properties: {
59
+ publicPath: getParameterPath(this, PUBLIC_KEY_PROP),
60
+ privatePath: getParameterPath(this, PRIVATE_KEY_PROP),
61
+ },
62
+ });
63
+ resource.node.addDependency(policy);
62
64
  }
63
65
  /** @internal */
64
66
  getConstructMetadata() {
@@ -150,6 +150,16 @@ ${exports}
150
150
  // They need to be replaced with real values before the Lambda
151
151
  // functions get deployed.
152
152
  const stack = Stack.of(this);
153
+ const policy = new Policy(this, "AssetReplacerPolicy", {
154
+ statements: [
155
+ new PolicyStatement({
156
+ effect: Effect.ALLOW,
157
+ actions: ["s3:GetObject", "s3:PutObject"],
158
+ resources: [`arn:${stack.partition}:s3:::${asset.s3BucketName}/*`],
159
+ }),
160
+ ],
161
+ });
162
+ stack.customResourceHandler.role?.attachInlinePolicy(policy);
153
163
  const resource = new CustomResource(this.scope, "AssetReplacer", {
154
164
  serviceToken: stack.customResourceHandler.functionArn,
155
165
  resourceType: "Custom::AssetReplacer",
@@ -159,15 +169,7 @@ ${exports}
159
169
  replacements: this.getLambdaContentReplaceValues(),
160
170
  },
161
171
  });
162
- stack.customResourceHandler.role?.attachInlinePolicy(new Policy(this, "AssetReplacerPolicy", {
163
- statements: [
164
- new PolicyStatement({
165
- effect: Effect.ALLOW,
166
- actions: ["s3:GetObject", "s3:PutObject"],
167
- resources: [`arn:${stack.partition}:s3:::${asset.s3BucketName}/*`],
168
- }),
169
- ],
170
- }));
172
+ resource.node.addDependency(policy);
171
173
  return resource;
172
174
  }
173
175
  createSingletonBucketCR() {
@@ -78,6 +78,16 @@ export class SsrFunction extends Construct {
78
78
  // They need to be replaced with real values before the Lambda
79
79
  // functions get deployed.
80
80
  const stack = Stack.of(this);
81
+ const policy = new Policy(this, "AssetReplacerPolicy", {
82
+ statements: [
83
+ new PolicyStatement({
84
+ effect: Effect.ALLOW,
85
+ actions: ["s3:GetObject", "s3:PutObject"],
86
+ resources: [`arn:${stack.partition}:s3:::${asset.s3BucketName}/*`],
87
+ }),
88
+ ],
89
+ });
90
+ stack.customResourceHandler.role?.attachInlinePolicy(policy);
81
91
  const resource = new CustomResource(this, "AssetReplacer", {
82
92
  serviceToken: stack.customResourceHandler.functionArn,
83
93
  resourceType: "Custom::AssetReplacer",
@@ -87,15 +97,7 @@ export class SsrFunction extends Construct {
87
97
  replacements: this.getLambdaContentReplaceValues(),
88
98
  },
89
99
  });
90
- stack.customResourceHandler.role?.attachInlinePolicy(new Policy(this, "AssetReplacerPolicy", {
91
- statements: [
92
- new PolicyStatement({
93
- effect: Effect.ALLOW,
94
- actions: ["s3:GetObject", "s3:PutObject"],
95
- resources: [`arn:${stack.partition}:s3:::${asset.s3BucketName}/*`],
96
- }),
97
- ],
98
- }));
100
+ resource.node.addDependency(policy);
99
101
  return resource;
100
102
  }
101
103
  getLambdaContentReplaceValues() {
@@ -552,17 +552,7 @@ export class SsrSite extends Construct {
552
552
  }
553
553
  createCloudFrontInvalidation() {
554
554
  const stack = Stack.of(this);
555
- const resource = new CustomResource(this, "CloudFrontInvalidator", {
556
- serviceToken: stack.customResourceHandler.functionArn,
557
- resourceType: "Custom::CloudFrontInvalidator",
558
- properties: {
559
- buildId: this.generateBuildId(),
560
- distributionId: this.distribution.distributionId,
561
- paths: ["/*"],
562
- waitForInvalidation: this.props.waitForInvalidation,
563
- },
564
- });
565
- stack.customResourceHandler.role?.attachInlinePolicy(new Policy(this, "CloudFrontInvalidatorPolicy", {
555
+ const policy = new Policy(this, "CloudFrontInvalidatorPolicy", {
566
556
  statements: [
567
557
  new PolicyStatement({
568
558
  effect: Effect.ALLOW,
@@ -575,7 +565,19 @@ export class SsrSite extends Construct {
575
565
  ],
576
566
  }),
577
567
  ],
578
- }));
568
+ });
569
+ stack.customResourceHandler.role?.attachInlinePolicy(policy);
570
+ const resource = new CustomResource(this, "CloudFrontInvalidator", {
571
+ serviceToken: stack.customResourceHandler.functionArn,
572
+ resourceType: "Custom::CloudFrontInvalidator",
573
+ properties: {
574
+ buildId: this.generateBuildId(),
575
+ distributionId: this.distribution.distributionId,
576
+ paths: ["/*"],
577
+ waitForInvalidation: this.props.waitForInvalidation,
578
+ },
579
+ });
580
+ resource.node.addDependency(policy);
579
581
  return resource;
580
582
  }
581
583
  /////////////////////
@@ -427,17 +427,7 @@ interface ImportMeta {
427
427
  .createHash("md5")
428
428
  .update(assets.map(({ assetHash }) => assetHash).join(""))
429
429
  .digest("hex");
430
- const resource = new CustomResource(this, "CloudFrontInvalidator", {
431
- serviceToken: stack.customResourceHandler.functionArn,
432
- resourceType: "Custom::CloudFrontInvalidator",
433
- properties: {
434
- assetsHash,
435
- distributionId: this.distribution.distributionId,
436
- paths: ["/*"],
437
- waitForInvalidation: this.props.waitForInvalidation,
438
- },
439
- });
440
- stack.customResourceHandler.role?.attachInlinePolicy(new Policy(this, "CloudFrontInvalidatorPolicy", {
430
+ const policy = new Policy(this, "CloudFrontInvalidatorPolicy", {
441
431
  statements: [
442
432
  new PolicyStatement({
443
433
  effect: Effect.ALLOW,
@@ -450,7 +440,19 @@ interface ImportMeta {
450
440
  ],
451
441
  }),
452
442
  ],
453
- }));
443
+ });
444
+ stack.customResourceHandler.role?.attachInlinePolicy(policy);
445
+ const resource = new CustomResource(this, "CloudFrontInvalidator", {
446
+ serviceToken: stack.customResourceHandler.functionArn,
447
+ resourceType: "Custom::CloudFrontInvalidator",
448
+ properties: {
449
+ assetsHash,
450
+ distributionId: this.distribution.distributionId,
451
+ paths: ["/*"],
452
+ waitForInvalidation: this.props.waitForInvalidation,
453
+ },
454
+ });
455
+ resource.node.addDependency(policy);
454
456
  return resource;
455
457
  }
456
458
  /////////////////////
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.15",
3
+ "version": "2.0.16",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },