@anthusai/papyrus 1.18.0-next.2 → 1.18.0-next.4
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 +19 -15
- 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
|
@@ -85,7 +85,7 @@ if (accountStack !== undefined) {
|
|
|
85
85
|
const { App } = createRequire(path.join(process.cwd(), "noop.js"))("aws-cdk-lib");
|
|
86
86
|
const app = new App({ outdir: path.resolve(opt("out", "cdk.out")) });
|
|
87
87
|
new GithubOidcProviderStack(app, "GithubOidcProviderStack", {
|
|
88
|
-
env: { account: opt("account", "335163751677"), region: opt("region", "us-east-1") },
|
|
88
|
+
env: { account: opt("account", process.env.CDK_DEFAULT_ACCOUNT ?? "335163751677"), region: opt("region", process.env.CDK_DEFAULT_REGION ?? "us-east-1") },
|
|
89
89
|
stackName: "github-oidc-provider",
|
|
90
90
|
});
|
|
91
91
|
app.synth();
|
|
@@ -132,22 +132,26 @@ if (command === "deploy") {
|
|
|
132
132
|
process.exit(0);
|
|
133
133
|
}
|
|
134
134
|
const outputDirectory = path.resolve(opt("out", process.env.CDK_OUTDIR ?? "cdk.out"));
|
|
135
|
-
const
|
|
135
|
+
const explicitAccount = opt("account");
|
|
136
|
+
const explicitRegion = opt("region");
|
|
137
|
+
const synthesis = spawnSync(
|
|
136
138
|
process.execPath,
|
|
137
|
-
|
|
138
|
-
|
|
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);
|
|
@@ -164,7 +168,7 @@ try {
|
|
|
164
168
|
const { App } = createRequire(path.join(process.cwd(), "noop.js"))("aws-cdk-lib");
|
|
165
169
|
const app = new App({ outdir: path.resolve(opt("out", "cdk.out")) });
|
|
166
170
|
new AmplifyAppShellStack(app, `AmplifyAppShell-${config.siteId}`, config, {
|
|
167
|
-
env: { account: opt("account", "335163751677"), region: opt("region", "us-east-1") },
|
|
171
|
+
env: { account: opt("account", process.env.CDK_DEFAULT_ACCOUNT ?? "335163751677"), region: opt("region", process.env.CDK_DEFAULT_REGION ?? "us-east-1") },
|
|
168
172
|
stackName: resolveStackName(config),
|
|
169
173
|
});
|
|
170
174
|
app.synth();
|
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);
|