@beesolve/aws-accounts 1.0.4 → 1.0.6
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/dist/commands/remote.js +36 -4
- package/dist-lambda/lambda.zip +0 -0
- package/package.json +1 -1
package/dist/commands/remote.js
CHANGED
|
@@ -116,7 +116,11 @@ async function runRemoteBootstrap(input) {
|
|
|
116
116
|
resolvedRegion,
|
|
117
117
|
logger: input.logger
|
|
118
118
|
});
|
|
119
|
-
|
|
119
|
+
let context = null;
|
|
120
|
+
try {
|
|
121
|
+
context = await readAwsContextFromFile(contextFilePath);
|
|
122
|
+
} catch {
|
|
123
|
+
}
|
|
120
124
|
const deployment = {
|
|
121
125
|
profile: input.profile ?? "",
|
|
122
126
|
region: resolvedRegion,
|
|
@@ -124,8 +128,11 @@ async function runRemoteBootstrap(input) {
|
|
|
124
128
|
stateBucketName: bucketName,
|
|
125
129
|
stateCacheTtlSeconds: 300
|
|
126
130
|
};
|
|
127
|
-
const updatedContext = {
|
|
128
|
-
|
|
131
|
+
const updatedContext = context != null ? { ...context, deployment } : {
|
|
132
|
+
version: "1",
|
|
133
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
134
|
+
organization: { managementAccountId: accountId, rootId: "pending", graveyardOuId: "pending" },
|
|
135
|
+
identityCenter: { instanceArn: "pending", identityStoreId: "pending" },
|
|
129
136
|
deployment
|
|
130
137
|
};
|
|
131
138
|
const ordered = {
|
|
@@ -138,7 +145,7 @@ async function runRemoteBootstrap(input) {
|
|
|
138
145
|
await writeFile(contextFilePath, `${JSON.stringify(ordered, null, 2)}
|
|
139
146
|
`, "utf8");
|
|
140
147
|
const instanceArn = updatedContext.identityCenter?.instanceArn;
|
|
141
|
-
if (instanceArn != null && instanceArn !== "") {
|
|
148
|
+
if (instanceArn != null && instanceArn !== "" && instanceArn !== "pending") {
|
|
142
149
|
await ensureOrganizationManagementPermissionSet({
|
|
143
150
|
ssoAdminClient: input.ssoAdminClient,
|
|
144
151
|
instanceArn,
|
|
@@ -420,6 +427,31 @@ async function runRemoteInit(input) {
|
|
|
420
427
|
writeStateCache(cachePath, response.state)
|
|
421
428
|
]);
|
|
422
429
|
input.logger.log("State written to state.json and cache updated.");
|
|
430
|
+
const context = await readAwsContextFromFile(contextFilePath);
|
|
431
|
+
const graveyardOu = response.state.organization.organizationalUnits.find(
|
|
432
|
+
(ou) => ou.name === "Graveyard"
|
|
433
|
+
);
|
|
434
|
+
const updatedContext = {
|
|
435
|
+
...context,
|
|
436
|
+
organization: {
|
|
437
|
+
managementAccountId: context.organization.managementAccountId,
|
|
438
|
+
rootId: response.state.organization.rootId,
|
|
439
|
+
graveyardOuId: graveyardOu?.id ?? context.organization.graveyardOuId
|
|
440
|
+
},
|
|
441
|
+
identityCenter: {
|
|
442
|
+
instanceArn: response.state.identityCenter.instanceArn,
|
|
443
|
+
identityStoreId: response.state.identityCenter.identityStoreId
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
const ordered = {
|
|
447
|
+
version: updatedContext.version,
|
|
448
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
449
|
+
organization: updatedContext.organization,
|
|
450
|
+
identityCenter: updatedContext.identityCenter,
|
|
451
|
+
deployment: updatedContext.deployment
|
|
452
|
+
};
|
|
453
|
+
await writeFile(contextFilePath, `${JSON.stringify(ordered, null, 2)}
|
|
454
|
+
`, "utf8");
|
|
423
455
|
const configWriteResult = await writeAwsConfigFromState({
|
|
424
456
|
statePath,
|
|
425
457
|
contextPath: contextFilePath,
|
package/dist-lambda/lambda.zip
CHANGED
|
Binary file
|