sst 2.1.14 → 2.1.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.
package/bootstrap.d.ts CHANGED
@@ -2,4 +2,4 @@ export declare const useBootstrap: () => Promise<{
2
2
  version: string;
3
3
  bucket: string;
4
4
  }>;
5
- export declare function bootstrapSST(tags: Record<string, string>): Promise<void>;
5
+ export declare function bootstrapSST(tags?: Record<string, string>, publicAccessBlockConfiguration?: boolean): Promise<void>;
package/bootstrap.js CHANGED
@@ -38,7 +38,7 @@ export const useBootstrap = Context.memo(async () => {
38
38
  await bootstrapCDK();
39
39
  }
40
40
  if (needToBootstrapSST) {
41
- await bootstrapSST({});
41
+ await bootstrapSST();
42
42
  // fetch bootstrap status
43
43
  sstStatus = await loadSSTStatus();
44
44
  if (!sstStatus)
@@ -81,7 +81,11 @@ async function loadCDKStatus() {
81
81
  }
82
82
  }
83
83
  }
84
- export async function bootstrapSST(tags) {
84
+ export async function bootstrapSST(tags, publicAccessBlockConfiguration) {
85
+ // Normalize input
86
+ tags = tags || {};
87
+ publicAccessBlockConfiguration =
88
+ publicAccessBlockConfiguration === false ? false : true;
85
89
  // Create bootstrap stack
86
90
  const project = useProject();
87
91
  const app = new App();
@@ -99,7 +103,9 @@ export async function bootstrapSST(tags) {
99
103
  encryption: BucketEncryption.S3_MANAGED,
100
104
  removalPolicy: RemovalPolicy.DESTROY,
101
105
  autoDeleteObjects: true,
102
- blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
106
+ blockPublicAccess: publicAccessBlockConfiguration
107
+ ? BlockPublicAccess.BLOCK_ALL
108
+ : undefined,
103
109
  });
104
110
  // Create Function and subscribe to CloudFormation events
105
111
  const fn = new Function(stack, "MetadataHandler", {
@@ -12,4 +12,6 @@ export declare const bootstrap: (program: Program) => import("yargs").Argv<{
12
12
  role: string | undefined;
13
13
  } & {
14
14
  tags: string[] | undefined;
15
+ } & {
16
+ "public-access-block-configuration": boolean;
15
17
  }>;
@@ -1,7 +1,13 @@
1
- export const bootstrap = (program) => program.command("bootstrap", "Create the SST bootstrap stack", (yargs) => yargs.option("tags", {
1
+ export const bootstrap = (program) => program.command("bootstrap", "Create the SST bootstrap stack", (yargs) => yargs
2
+ .option("tags", {
2
3
  type: "array",
3
4
  string: true,
4
5
  describe: "Tags to add for the bootstrap stack",
6
+ })
7
+ .option("public-access-block-configuration", {
8
+ type: "boolean",
9
+ default: true,
10
+ describe: "Block public access configuration on SST bootstrap bucket",
5
11
  }), async (args) => {
6
12
  const { createSpinner } = await import("../spinner.js");
7
13
  const { Colors } = await import("../colors.js");
@@ -15,7 +21,7 @@ export const bootstrap = (program) => program.command("bootstrap", "Create the S
15
21
  Colors.line(`${Colors.primary(`➜`)} Using tags`, tags);
16
22
  }
17
23
  const spinner = createSpinner(" Deploying bootstrap stack").start();
18
- await bootstrapSST(tags);
24
+ await bootstrapSST(tags, args.publicAccessBlockConfiguration);
19
25
  spinner.succeed(Colors.bold(` Bootstrapped account ${identity.Account} in region ${project.config.region}`));
20
26
  process.exit(0);
21
27
  });
@@ -164,12 +164,18 @@ export class Stack extends cdk.Stack {
164
164
  if (value === undefined) {
165
165
  throw new Error(`The stack output "${key}" is undefined`);
166
166
  }
167
- else if (typeof value === "string") {
168
- new cdk.CfnOutput(this, key, { value });
169
- }
170
- else {
171
- new cdk.CfnOutput(this, key, value);
172
- }
167
+ // Note: add "SSTStackOutput" prefix to the CfnOutput id to ensure the id
168
+ // does not thrash w/ construct ids in the stack. So users can do this:
169
+ // ```
170
+ // const table = new Table(stack, "myTable");
171
+ // stack.addOutputs({ myTable: table.name });
172
+ // ```
173
+ // And then we override the logical id so the actual output name is
174
+ // still "myTable".
175
+ const output = typeof value === "string"
176
+ ? new cdk.CfnOutput(this, `SSTStackOutput${key}`, { value })
177
+ : new cdk.CfnOutput(this, `SSTStackOutput${key}`, value);
178
+ output.overrideLogicalId(key);
173
179
  });
174
180
  }
175
181
  createCustomResourceHandler() {
@@ -77,9 +77,10 @@ export class WebSocketApi extends Construct {
77
77
  return Object.keys(this.functions);
78
78
  }
79
79
  get _connectionsArn() {
80
+ this.cdk.webSocketApi.grantManageConnections;
80
81
  return Stack.of(this).formatArn({
81
82
  service: "execute-api",
82
- resourceName: `${this.cdk.webSocketStage.stageName}/POST/*`,
83
+ resourceName: "*/*/@connections/*",
83
84
  resource: this.cdk.webSocketApi.apiId,
84
85
  });
85
86
  }
@@ -201,7 +202,9 @@ export class WebSocketApi extends Construct {
201
202
  value: this.customDomainUrl || this.url,
202
203
  },
203
204
  },
204
- permissions: {},
205
+ permissions: {
206
+ "execute-api:ManageConnections": [this._connectionsArn],
207
+ },
205
208
  };
206
209
  }
207
210
  createWebSocketApi() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.1.14",
3
+ "version": "2.1.16",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
@@ -66,7 +66,7 @@ export const useGoHandler = Context.memo(async () => {
66
66
  });
67
67
  }
68
68
  catch (ex) {
69
- throw new VisibleError("Failed to build");
69
+ throw new VisibleError(`Failed to build ${ex}`);
70
70
  }
71
71
  }
72
72
  if (input.mode === "deploy") {
package/sst.mjs CHANGED
@@ -2809,7 +2809,9 @@ async function loadCDKStatus() {
2809
2809
  }
2810
2810
  }
2811
2811
  }
2812
- async function bootstrapSST(tags) {
2812
+ async function bootstrapSST(tags, publicAccessBlockConfiguration) {
2813
+ tags = tags || {};
2814
+ publicAccessBlockConfiguration = publicAccessBlockConfiguration === false ? false : true;
2813
2815
  const project = useProject();
2814
2816
  const app = new App();
2815
2817
  const stack = new Stack(app, STACK_NAME, {
@@ -2824,7 +2826,7 @@ async function bootstrapSST(tags) {
2824
2826
  encryption: BucketEncryption.S3_MANAGED,
2825
2827
  removalPolicy: RemovalPolicy.DESTROY,
2826
2828
  autoDeleteObjects: true,
2827
- blockPublicAccess: BlockPublicAccess.BLOCK_ALL
2829
+ blockPublicAccess: publicAccessBlockConfiguration ? BlockPublicAccess.BLOCK_ALL : void 0
2828
2830
  });
2829
2831
  const fn = new Function(stack, "MetadataHandler", {
2830
2832
  code: Code.fromAsset(
@@ -3000,7 +3002,7 @@ var init_bootstrap = __esm({
3000
3002
  await bootstrapCDK();
3001
3003
  }
3002
3004
  if (needToBootstrapSST) {
3003
- await bootstrapSST({});
3005
+ await bootstrapSST();
3004
3006
  sstStatus = await loadSSTStatus();
3005
3007
  if (!sstStatus)
3006
3008
  throw new VisibleError("Failed to load bootstrap stack status");
@@ -5169,7 +5171,7 @@ var init_go = __esm({
5169
5171
  }
5170
5172
  );
5171
5173
  } catch (ex) {
5172
- throw new VisibleError("Failed to build");
5174
+ throw new VisibleError(`Failed to build ${ex}`);
5173
5175
  }
5174
5176
  }
5175
5177
  if (input.mode === "deploy") {
@@ -7736,6 +7738,10 @@ var bootstrap = (program2) => program2.command(
7736
7738
  type: "array",
7737
7739
  string: true,
7738
7740
  describe: "Tags to add for the bootstrap stack"
7741
+ }).option("public-access-block-configuration", {
7742
+ type: "boolean",
7743
+ default: true,
7744
+ describe: "Block public access configuration on SST bootstrap bucket"
7739
7745
  }),
7740
7746
  async (args) => {
7741
7747
  const { createSpinner: createSpinner2 } = await Promise.resolve().then(() => (init_spinner(), spinner_exports));
@@ -7752,7 +7758,7 @@ var bootstrap = (program2) => program2.command(
7752
7758
  Colors2.line(`${Colors2.primary(`\u279C`)} Using tags`, tags);
7753
7759
  }
7754
7760
  const spinner = createSpinner2(" Deploying bootstrap stack").start();
7755
- await bootstrapSST2(tags);
7761
+ await bootstrapSST2(tags, args.publicAccessBlockConfiguration);
7756
7762
  spinner.succeed(
7757
7763
  Colors2.bold(
7758
7764
  ` Bootstrapped account ${identity.Account} in region ${project.config.region}`