@go-to-k/cdkd 0.10.0 → 0.11.0
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/README.md +3 -3
- package/dist/cli.js +48 -10
- package/dist/cli.js.map +3 -3
- package/dist/go-to-k-cdkd-0.11.0.tgz +0 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/go-to-k-cdkd-0.10.0.tgz +0 -0
package/README.md
CHANGED
|
@@ -95,7 +95,7 @@ Reproduce with `./tests/benchmark/run-benchmark.sh all`. See [tests/benchmark/RE
|
|
|
95
95
|
```
|
|
96
96
|
1. CLI Layer
|
|
97
97
|
├── Resolve --app (CLI > CDKD_APP env > cdk.json "app")
|
|
98
|
-
├── Resolve --state-bucket (CLI > env > cdk.json > auto: cdkd-state-{accountId}-{region})
|
|
98
|
+
├── Resolve --state-bucket (CLI > env > cdk.json > auto: cdkd-state-{accountId}, with legacy fallback to cdkd-state-{accountId}-{region})
|
|
99
99
|
└── Initialize AWS clients
|
|
100
100
|
|
|
101
101
|
2. Synthesis (self-implemented, no CDK CLI dependency)
|
|
@@ -355,7 +355,7 @@ cdkd diff
|
|
|
355
355
|
cdkd destroy
|
|
356
356
|
```
|
|
357
357
|
|
|
358
|
-
That's it. cdkd reads `--app` from `cdk.json` and auto-resolves the state bucket from your AWS account ID (`cdkd-state-{accountId}-{region}`).
|
|
358
|
+
That's it. cdkd reads `--app` from `cdk.json` and auto-resolves the state bucket from your AWS account ID (`cdkd-state-{accountId}`). If you bootstrapped under a previous cdkd version, the legacy region-suffixed name (`cdkd-state-{accountId}-{region}`) is still picked up automatically with a deprecation warning.
|
|
359
359
|
|
|
360
360
|
## Usage
|
|
361
361
|
|
|
@@ -547,7 +547,7 @@ s3://{state-bucket}/
|
|
|
547
547
|
|
|
548
548
|
| Setting | CLI | cdk.json | Env var | Default |
|
|
549
549
|
|---------|-----|----------|---------|---------|
|
|
550
|
-
| Bucket | `--state-bucket` | `context.cdkd.stateBucket` | `CDKD_STATE_BUCKET` | `cdkd-state-{accountId}-{region}` |
|
|
550
|
+
| Bucket | `--state-bucket` | `context.cdkd.stateBucket` | `CDKD_STATE_BUCKET` | `cdkd-state-{accountId}` (legacy `cdkd-state-{accountId}-{region}` is still read with a deprecation warning) |
|
|
551
551
|
| Prefix | `--state-prefix` | - | - | `cdkd` |
|
|
552
552
|
|
|
553
553
|
### Multi-app isolation
|
package/dist/cli.js
CHANGED
|
@@ -971,7 +971,10 @@ function resolveStateBucket(cliBucket) {
|
|
|
971
971
|
const bucket = cdkdContext?.["stateBucket"];
|
|
972
972
|
return typeof bucket === "string" ? bucket : void 0;
|
|
973
973
|
}
|
|
974
|
-
function getDefaultStateBucketName(accountId
|
|
974
|
+
function getDefaultStateBucketName(accountId) {
|
|
975
|
+
return `cdkd-state-${accountId}`;
|
|
976
|
+
}
|
|
977
|
+
function getLegacyStateBucketName(accountId, region) {
|
|
975
978
|
return `cdkd-state-${accountId}-${region}`;
|
|
976
979
|
}
|
|
977
980
|
async function resolveStateBucketWithDefault(cliBucket, region) {
|
|
@@ -981,13 +984,48 @@ async function resolveStateBucketWithDefault(cliBucket, region) {
|
|
|
981
984
|
const logger = getLogger();
|
|
982
985
|
logger.debug("No state bucket specified, resolving default from account...");
|
|
983
986
|
const { GetCallerIdentityCommand: GetCallerIdentityCommand8 } = await import("@aws-sdk/client-sts");
|
|
987
|
+
const { S3Client: S3Client10 } = await import("@aws-sdk/client-s3");
|
|
984
988
|
const { getAwsClients: getAwsClients2 } = await Promise.resolve().then(() => (init_aws_clients(), aws_clients_exports));
|
|
985
989
|
const awsClients = getAwsClients2();
|
|
986
990
|
const identity = await awsClients.sts.send(new GetCallerIdentityCommand8({}));
|
|
987
991
|
const accountId = identity.Account;
|
|
988
|
-
const
|
|
989
|
-
|
|
990
|
-
|
|
992
|
+
const newName = getDefaultStateBucketName(accountId);
|
|
993
|
+
const legacyName = getLegacyStateBucketName(accountId, region);
|
|
994
|
+
const probe = new S3Client10({ region: "us-east-1" });
|
|
995
|
+
try {
|
|
996
|
+
if (await bucketExists(probe, newName)) {
|
|
997
|
+
logger.info(`State bucket: ${newName}`);
|
|
998
|
+
return newName;
|
|
999
|
+
}
|
|
1000
|
+
if (await bucketExists(probe, legacyName)) {
|
|
1001
|
+
logger.warn(
|
|
1002
|
+
`Using legacy state bucket name '${legacyName}'. The default has changed to '${newName}'. Future cdkd versions will drop legacy support; consider migrating with cdkd state migrate-bucket (coming in a future release).`
|
|
1003
|
+
);
|
|
1004
|
+
return legacyName;
|
|
1005
|
+
}
|
|
1006
|
+
throw new Error(
|
|
1007
|
+
`No cdkd state bucket found for account ${accountId}. Looked for '${newName}' (current default) and '${legacyName}' (legacy default). Run 'cdkd bootstrap' to create '${newName}'.`
|
|
1008
|
+
);
|
|
1009
|
+
} finally {
|
|
1010
|
+
probe.destroy();
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
async function bucketExists(client, bucketName) {
|
|
1014
|
+
const { HeadBucketCommand: HeadBucketCommand3 } = await import("@aws-sdk/client-s3");
|
|
1015
|
+
try {
|
|
1016
|
+
await client.send(new HeadBucketCommand3({ Bucket: bucketName }));
|
|
1017
|
+
return true;
|
|
1018
|
+
} catch (error) {
|
|
1019
|
+
const err = error;
|
|
1020
|
+
const status = err.$metadata?.httpStatusCode;
|
|
1021
|
+
if (err.name === "NotFound" || err.name === "NoSuchBucket" || status === 404) {
|
|
1022
|
+
return false;
|
|
1023
|
+
}
|
|
1024
|
+
if (status === 301 || status === 403) {
|
|
1025
|
+
return true;
|
|
1026
|
+
}
|
|
1027
|
+
throw error;
|
|
1028
|
+
}
|
|
991
1029
|
}
|
|
992
1030
|
|
|
993
1031
|
// src/cli/commands/bootstrap.ts
|
|
@@ -1015,14 +1053,14 @@ async function bootstrapCommand(options) {
|
|
|
1015
1053
|
logger.info("No --state-bucket specified, resolving default bucket name...");
|
|
1016
1054
|
const identity = await awsClients.sts.send(new GetCallerIdentityCommand({}));
|
|
1017
1055
|
accountId = identity.Account;
|
|
1018
|
-
bucketName = getDefaultStateBucketName(accountId
|
|
1056
|
+
bucketName = getDefaultStateBucketName(accountId);
|
|
1019
1057
|
logger.info(`Using default state bucket: ${bucketName}`);
|
|
1020
1058
|
}
|
|
1021
1059
|
try {
|
|
1022
|
-
let
|
|
1060
|
+
let bucketExists2 = false;
|
|
1023
1061
|
try {
|
|
1024
1062
|
await s3Client.send(new HeadBucketCommand({ Bucket: bucketName }));
|
|
1025
|
-
|
|
1063
|
+
bucketExists2 = true;
|
|
1026
1064
|
logger.info(`Bucket ${bucketName} already exists`);
|
|
1027
1065
|
} catch (error) {
|
|
1028
1066
|
const err = error;
|
|
@@ -1032,7 +1070,7 @@ async function bootstrapCommand(options) {
|
|
|
1032
1070
|
throw normalizeAwsError(error, { bucket: bucketName, operation: "HeadBucket" });
|
|
1033
1071
|
}
|
|
1034
1072
|
}
|
|
1035
|
-
if (
|
|
1073
|
+
if (bucketExists2) {
|
|
1036
1074
|
if (!options.force) {
|
|
1037
1075
|
logger.warn(
|
|
1038
1076
|
`Bucket ${bucketName} already exists. Use --force to reconfigure (this will not delete existing state)`
|
|
@@ -1119,7 +1157,7 @@ State bucket: ${bucketName}`);
|
|
|
1119
1157
|
function createBootstrapCommand() {
|
|
1120
1158
|
const cmd = new Command("bootstrap").description("Bootstrap cdkd by creating required S3 bucket for state management").option(
|
|
1121
1159
|
"--state-bucket <bucket>",
|
|
1122
|
-
"Name of S3 bucket to create for state storage (default: cdkd-state-{accountId}
|
|
1160
|
+
"Name of S3 bucket to create for state storage (default: cdkd-state-{accountId})"
|
|
1123
1161
|
).option("--force", "Force reconfiguration of existing bucket", false).action(withErrorHandling(bootstrapCommand));
|
|
1124
1162
|
commonOptions.forEach((opt) => cmd.addOption(opt));
|
|
1125
1163
|
return cmd;
|
|
@@ -29898,7 +29936,7 @@ function reorderArgs(argv) {
|
|
|
29898
29936
|
}
|
|
29899
29937
|
async function main() {
|
|
29900
29938
|
const program = new Command10();
|
|
29901
|
-
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.
|
|
29939
|
+
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.11.0");
|
|
29902
29940
|
program.addCommand(createBootstrapCommand());
|
|
29903
29941
|
program.addCommand(createSynthCommand());
|
|
29904
29942
|
program.addCommand(createListCommand());
|