@intelligems/sst 2.49.3 → 2.49.6-ig.10

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/stacks/deploy.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import path from "path";
2
+ import { fileURLToPath, pathToFileURL } from "url";
2
3
  import { useBus } from "../bus.js";
3
4
  import { useProject } from "../project.js";
4
5
  import { useAWSClient, useAWSProvider } from "../credentials.js";
@@ -7,6 +8,7 @@ import { filterOutputs, isFailed, monitor, } from "./monitor.js";
7
8
  import { VisibleError } from "../error.js";
8
9
  export async function publishAssets(stacks) {
9
10
  Logger.debug("Publishing assets");
11
+ const { cdk } = useProject().config;
10
12
  const results = {};
11
13
  for (const stackArtifact of stacks) {
12
14
  const cfnStack = await getCloudFormationStack(stackArtifact);
@@ -15,7 +17,7 @@ export async function publishAssets(stacks) {
15
17
  await buildAndPublishAssets(deployment, stackArtifact);
16
18
  results[stackArtifact.stackName] = {
17
19
  isUpdate: cfnStack && cfnStack.StackStatus !== "REVIEW_IN_PROGRESS",
18
- params: await buildCloudFormationStackParams(deployment, stackArtifact),
20
+ params: await buildCloudFormationStackParams(deployment, stackArtifact, cdk),
19
21
  };
20
22
  }
21
23
  return results;
@@ -87,7 +89,7 @@ export async function deploy(stack) {
87
89
  cfnStack?.StackStatus === "ROLLBACK_FAILED") {
88
90
  await deleteCloudFormationStack(stack.stackName);
89
91
  }
90
- const stackParams = await buildCloudFormationStackParams(deployment, stack);
92
+ const stackParams = await buildCloudFormationStackParams(deployment, stack, cdk);
91
93
  try {
92
94
  cfnStack && cfnStack.StackStatus !== "REVIEW_IN_PROGRESS"
93
95
  ? await updateCloudFormationStack(stackParams)
@@ -192,9 +194,9 @@ async function addInUseExports(stackArtifact, cfnStack) {
192
194
  }
193
195
  async function createCdkDeployments() {
194
196
  const cdkToolkitUrl = await import.meta.resolve("@aws-cdk/toolkit-lib");
195
- const cdkToolkitPath = new URL(cdkToolkitUrl).pathname;
196
- const { Deployments } = await import(path.resolve(cdkToolkitPath, "..", "api", "deployments", "deployments.js"));
197
- const { IoHelper } = await import(path.resolve(cdkToolkitPath, "..", "api", "io", "private", "io-helper.js"));
197
+ const cdkToolkitPath = fileURLToPath(cdkToolkitUrl);
198
+ const { Deployments } = await import(pathToFileURL(path.resolve(cdkToolkitPath, "..", "api", "deployments", "deployments.js")).href);
199
+ const { IoHelper } = await import(pathToFileURL(path.resolve(cdkToolkitPath, "..", "api", "io", "private", "io-helper.js")).href);
198
200
  const provider = await useAWSProvider();
199
201
  await useAWSProvider();
200
202
  const ioHelper = IoHelper.fromActionAwareIoHost({
@@ -227,17 +229,19 @@ async function buildAndPublishAssets(deployment, stackArtifact) {
227
229
  }
228
230
  }
229
231
  }
230
- async function buildCloudFormationStackParams(deployment, stack) {
231
- const resolvedEnv = await deployment.resolveEnvironment(stack);
232
+ async function buildCloudFormationStackParams(deployment, stack, cdkOptions) {
233
+ const env = await deployment.envs.accessStackForMutableStackOperations(stack);
234
+ const executionRoleArn = cdkOptions?.cloudFormationExecutionRole ?? await env.replacePlaceholders(stack.cloudFormationExecutionRoleArn);
232
235
  const s3Url = stack
233
- .stackTemplateAssetObjectUrl.replace("${AWS::AccountId}", resolvedEnv.account)
236
+ .stackTemplateAssetObjectUrl.replace("${AWS::AccountId}", env.resolvedEnvironment.account)
234
237
  .match(/s3:\/\/([^/]+)\/(.*)$/);
235
238
  const templateUrl = s3Url
236
- ? `https://s3.${resolvedEnv.region}.amazonaws.com/${s3Url[1]}/${s3Url[2]}`
239
+ ? `https://s3.${env.resolvedEnvironment.region}.amazonaws.com/${s3Url[1]}/${s3Url[2]}`
237
240
  : stack.stackTemplateAssetObjectUrl;
238
241
  return {
239
242
  StackName: stack.stackName,
240
243
  TemplateURL: templateUrl,
244
+ RoleARN: executionRoleArn,
241
245
  //TemplateBody: bodyParameter.TemplateBody,
242
246
  //Parameters: stackParams.apiParameters,
243
247
  Parameters: [],
@@ -257,7 +261,7 @@ async function getCloudFormationStack(stack) {
257
261
  const client = useAWSClient(CloudFormationClient);
258
262
  try {
259
263
  const { Stacks: stacks } = await client.send(new DescribeStacksCommand({
260
- StackName: stack.id,
264
+ StackName: stack.stackName,
261
265
  }));
262
266
  if (!stacks || stacks.length === 0)
263
267
  return;
package/stacks/synth.js CHANGED
@@ -2,6 +2,7 @@ import { Logger } from "../logger.js";
2
2
  import { useProject } from "../project.js";
3
3
  import { useAWSProvider, useSTSIdentity } from "../credentials.js";
4
4
  import path from "path";
5
+ import { fileURLToPath, pathToFileURL } from "url";
5
6
  import { VisibleError } from "../error.js";
6
7
  import { Semaphore } from "../util/semaphore.js";
7
8
  import { Configuration } from "../util/user-configuration.js";
@@ -11,10 +12,10 @@ export async function synth(opts) {
11
12
  const { App } = await import("../constructs/App.js");
12
13
  const cxapi = await import("@aws-cdk/cx-api");
13
14
  const cdkToolkitUrl = await import.meta.resolve("@aws-cdk/toolkit-lib");
14
- const cdkToolkitPath = new URL(cdkToolkitUrl).pathname;
15
- const { IoHelper } = await import(path.resolve(cdkToolkitPath, "..", "api", "io", "private", "io-helper.js"));
16
- const { PluginHost } = await import(path.resolve(cdkToolkitPath, "..", "api", "plugin", "plugin.js"));
17
- const { provideContextValues } = await import(path.resolve(cdkToolkitPath, "..", "context-providers", "index.js"));
15
+ const cdkToolkitPath = fileURLToPath(cdkToolkitUrl);
16
+ const { IoHelper } = await import(pathToFileURL(path.resolve(cdkToolkitPath, "..", "api", "io", "private", "io-helper.js")).href);
17
+ const { PluginHost } = await import(pathToFileURL(path.resolve(cdkToolkitPath, "..", "api", "plugin", "plugin.js")).href);
18
+ const { provideContextValues } = await import(pathToFileURL(path.resolve(cdkToolkitPath, "..", "context-providers", "index.js")).href);
18
19
  const project = useProject();
19
20
  const cwd = process.cwd();
20
21
  process.chdir(project.paths.root);