@anthusai/papyrus 1.19.0 → 1.19.1
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/bin/papyrus-infra.mjs +15 -11
- package/package.json +1 -1
- package/routes.manifest.json +1 -1
- package/src/edge-stack-deploy.mjs +14 -7
package/bin/papyrus-infra.mjs
CHANGED
|
@@ -134,20 +134,24 @@ if (command === "deploy") {
|
|
|
134
134
|
const outputDirectory = path.resolve(opt("out", process.env.CDK_OUTDIR ?? "cdk.out"));
|
|
135
135
|
const explicitAccount = opt("account");
|
|
136
136
|
const explicitRegion = opt("region");
|
|
137
|
-
const
|
|
137
|
+
const synthesis = spawnSync(
|
|
138
138
|
process.execPath,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
139
|
+
[
|
|
140
|
+
path.resolve(process.argv[1]),
|
|
141
|
+
"synth",
|
|
142
|
+
"--site",
|
|
143
|
+
path.resolve(opt("site", "infra/site.json")),
|
|
144
|
+
"--out",
|
|
145
|
+
outputDirectory,
|
|
146
|
+
...(explicitAccount ? ["--account", explicitAccount] : []),
|
|
147
|
+
...(explicitRegion ? ["--region", explicitRegion] : []),
|
|
148
|
+
],
|
|
149
|
+
{ stdio: "inherit" },
|
|
150
|
+
);
|
|
151
|
+
if (synthesis.status !== 0) process.exit(synthesis.status ?? 1);
|
|
148
152
|
const deployment = spawnSync(
|
|
149
153
|
"npx",
|
|
150
|
-
["--yes", "aws-cdk@2", "deploy", "--app",
|
|
154
|
+
["--yes", "aws-cdk@2", "deploy", "--app", outputDirectory, "--require-approval", "never", `AmplifyAppShell-${config.siteId}`],
|
|
151
155
|
{ stdio: "inherit" },
|
|
152
156
|
);
|
|
153
157
|
process.exit(deployment.status ?? 1);
|
package/package.json
CHANGED
package/routes.manifest.json
CHANGED
|
@@ -25,15 +25,22 @@ function logicalIdsInStack(stackName, region) {
|
|
|
25
25
|
return new Set(JSON.parse(completed.stdout).StackResourceSummaries.map((summary) => summary.LogicalResourceId));
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function
|
|
28
|
+
function parameterNamesInStack(stackName, region) {
|
|
29
|
+
const completed = runAws(["cloudformation", "describe-stacks", "--stack-name", stackName, "--region", region, "--output", "json"], { allowFailure: true });
|
|
30
|
+
if (completed.status !== 0) return new Set();
|
|
31
|
+
const stack = JSON.parse(completed.stdout).Stacks?.[0];
|
|
32
|
+
return new Set((stack?.Parameters ?? []).map((parameter) => parameter.ParameterKey));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function templateParameterFlags(parameterValues, templateFile, parameterNamesInStackNow) {
|
|
29
36
|
const templateText = fs.readFileSync(templateFile, "utf8");
|
|
30
37
|
const parametersSection = templateText.split("\nResources:")[0].split("\nParameters:\n")[1] ?? "";
|
|
31
38
|
const parameterNames = [...parametersSection.matchAll(/^ ([A-Za-z0-9]+):\s*$/gm)].map((match) => match[1]);
|
|
32
|
-
return parameterNames.
|
|
33
|
-
name in parameterValues
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
39
|
+
return parameterNames.flatMap((name) => {
|
|
40
|
+
if (name in parameterValues) return [`ParameterKey=${name},ParameterValue=${parameterValues[name]}`];
|
|
41
|
+
if (parameterNamesInStackNow.has(name)) return [`ParameterKey=${name},UsePreviousValue=true`];
|
|
42
|
+
return [];
|
|
43
|
+
});
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
export function applyChangeSet({ stackName, region, templateFile, parameterValues, adoptions }) {
|
|
@@ -47,7 +54,7 @@ export function applyChangeSet({ stackName, region, templateFile, parameterValue
|
|
|
47
54
|
"--template-body", `file://${path.resolve(templateFile)}`,
|
|
48
55
|
"--capabilities", "CAPABILITY_IAM",
|
|
49
56
|
"--region", region,
|
|
50
|
-
"--parameters", ...templateParameterFlags(parameterValues, templateFile),
|
|
57
|
+
"--parameters", ...templateParameterFlags(parameterValues, templateFile, parameterNamesInStack(stackName, region)),
|
|
51
58
|
];
|
|
52
59
|
if (adoptions) createArguments.push("--resources-to-import", JSON.stringify(adoptions));
|
|
53
60
|
runAws(createArguments);
|