@go-to-k/cdkd 0.21.0 → 0.23.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 +105 -7
- package/dist/cli.js +234 -5
- package/dist/cli.js.map +2 -2
- package/dist/go-to-k-cdkd-0.23.0.tgz +0 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/go-to-k-cdkd-0.21.0.tgz +0 -0
package/README.md
CHANGED
|
@@ -429,13 +429,10 @@ cdkd destroy --all --force
|
|
|
429
429
|
cdkd force-unlock MyStack
|
|
430
430
|
|
|
431
431
|
# Adopt already-deployed AWS resources into cdkd state.
|
|
432
|
-
#
|
|
433
|
-
#
|
|
434
|
-
cdkd import MyStack --
|
|
435
|
-
cdkd import MyStack --
|
|
436
|
-
cdkd import MyStack --resource MyBucket=my-bucket-name --yes # explicit override (repeatable)
|
|
437
|
-
cdkd import MyStack --resource-mapping mapping.json --yes # CDK CLI mapping-file compat
|
|
438
|
-
cdkd import MyStack --force # overwrite existing state
|
|
432
|
+
# See "Importing existing resources" below for the full guide (auto / selective /
|
|
433
|
+
# hybrid modes, --resource overrides, --resource-mapping CDK CLI compatibility).
|
|
434
|
+
cdkd import MyStack --dry-run
|
|
435
|
+
cdkd import MyStack --yes
|
|
439
436
|
|
|
440
437
|
# Inspect state-bucket info on demand (bucket name, region, source, schema version, stack count).
|
|
441
438
|
# Routine commands (deploy / destroy / etc.) no longer print the bucket banner by default —
|
|
@@ -543,6 +540,107 @@ Built on modern AWS tooling:
|
|
|
543
540
|
- **Cloud Control API** - Fallback resource management for types without SDK Providers
|
|
544
541
|
- **S3 Conditional Writes** - State locking via `If-None-Match`/`If-Match`
|
|
545
542
|
|
|
543
|
+
## Importing existing resources
|
|
544
|
+
|
|
545
|
+
`cdkd import` adopts AWS resources that are already deployed (e.g. via
|
|
546
|
+
`cdk deploy`, manual creation, or another tool) into cdkd state, so the
|
|
547
|
+
next `cdkd deploy` updates them in-place instead of trying to CREATE
|
|
548
|
+
duplicates.
|
|
549
|
+
|
|
550
|
+
It reads the CDK app to find logical IDs, resource types, and
|
|
551
|
+
dependencies, then matches each logical ID to a real AWS resource in
|
|
552
|
+
one of three modes:
|
|
553
|
+
|
|
554
|
+
All examples below assume cdkd reads the CDK app command from `cdk.json`
|
|
555
|
+
(the typical case). Pass `--app "<command>"` only if you're running cdkd
|
|
556
|
+
outside the CDK project directory or want to override `cdk.json`.
|
|
557
|
+
|
|
558
|
+
### Mode 1: auto (default — no flags)
|
|
559
|
+
|
|
560
|
+
```bash
|
|
561
|
+
cdkd import MyStack
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
Imports **every** resource in the synthesized template by tag. cdkd
|
|
565
|
+
looks up each resource using its `aws:cdk:path` tag (which CDK
|
|
566
|
+
automatically writes), so resources deployed by `cdk deploy` are found
|
|
567
|
+
without any manual work. Useful for **adopting a whole stack** that was
|
|
568
|
+
previously deployed by `cdk deploy`. This is cdkd's value-add over
|
|
569
|
+
`cdk import` — CDK CLI does not have a tag-based bulk-import mode.
|
|
570
|
+
|
|
571
|
+
### Mode 2: selective (CDK CLI parity — when explicit overrides are given)
|
|
572
|
+
|
|
573
|
+
```bash
|
|
574
|
+
# Import ONLY MyBucket; the other resources in the template are left alone.
|
|
575
|
+
cdkd import MyStack --resource MyBucket=my-bucket-name
|
|
576
|
+
|
|
577
|
+
# Several resources at once (--resource is repeatable).
|
|
578
|
+
cdkd import MyStack \
|
|
579
|
+
--resource MyBucket=my-bucket-name \
|
|
580
|
+
--resource MyFn=my-function-name
|
|
581
|
+
|
|
582
|
+
# CDK CLI compat: read overrides from a JSON file.
|
|
583
|
+
cdkd import MyStack --resource-mapping mapping.json
|
|
584
|
+
# mapping.json: { "MyBucket": "my-bucket-name", "MyFn": "my-function-name" }
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
When at least one `--resource` flag (or a `--resource-mapping` file) is
|
|
588
|
+
supplied, **only the listed resources are imported**. Every other
|
|
589
|
+
resource in the template is reported as `out of scope` and left out of
|
|
590
|
+
state — the next `cdkd deploy` will treat them as new and CREATE them.
|
|
591
|
+
This matches the semantics of `cdk import --resource-mapping`. cdkd
|
|
592
|
+
validates that every override key is a real logical ID in the
|
|
593
|
+
template; a typo aborts the run rather than silently importing nothing.
|
|
594
|
+
|
|
595
|
+
Use selective mode when you want to **adopt a few specific resources**
|
|
596
|
+
out of a larger stack — for example, you have one S3 bucket that was
|
|
597
|
+
created manually that you want cdkd to manage, while the rest of the
|
|
598
|
+
stack will be deployed fresh.
|
|
599
|
+
|
|
600
|
+
### Mode 3: hybrid (`--auto` with overrides)
|
|
601
|
+
|
|
602
|
+
```bash
|
|
603
|
+
cdkd import MyStack \
|
|
604
|
+
--resource MyBucket=my-bucket-name \
|
|
605
|
+
--auto
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
Listed resources use the explicit physical ID you supplied; **every
|
|
609
|
+
other resource still goes through tag-based auto-import**. Useful when
|
|
610
|
+
you have one resource whose tag-based lookup is unreliable (e.g. you
|
|
611
|
+
deleted and re-created it without the tag) but you want cdkd to find
|
|
612
|
+
the rest by tag automatically.
|
|
613
|
+
|
|
614
|
+
### Common flags
|
|
615
|
+
|
|
616
|
+
| Flag | Purpose |
|
|
617
|
+
| ----------- | ----------------------------------------------------------------------------- |
|
|
618
|
+
| `--dry-run` | Preview what would be imported. State is NOT written. |
|
|
619
|
+
| `--yes` | Skip the confirmation prompt before writing state. |
|
|
620
|
+
| `--force` | Overwrite an existing state record. Without this, existing state aborts. |
|
|
621
|
+
|
|
622
|
+
### After import
|
|
623
|
+
|
|
624
|
+
Run `cdkd diff` to see how the imported state lines up with the
|
|
625
|
+
template. If the resource's actual properties differ from the template,
|
|
626
|
+
the next `cdkd deploy` will UPDATE them to match. If you imported only
|
|
627
|
+
some resources (selective mode), the remaining template resources
|
|
628
|
+
appear as `to create` in the diff.
|
|
629
|
+
|
|
630
|
+
### Provider support
|
|
631
|
+
|
|
632
|
+
Tag-based auto-lookup is implemented for the most-used resource types
|
|
633
|
+
(S3 Bucket, Lambda Function, IAM Role, SNS Topic, SQS Queue, DynamoDB
|
|
634
|
+
Table, Logs LogGroup, EventBridge EventBus, KMS Key/Alias, Secrets
|
|
635
|
+
Manager Secret, SSM Parameter, EC2 VPC/Subnet/SecurityGroup, RDS,
|
|
636
|
+
ECS Cluster/Service/TaskDefinition, CloudFront Distribution, Cognito
|
|
637
|
+
User Pool — the full list is in [CLAUDE.md](CLAUDE.md)). For resource
|
|
638
|
+
types without auto-lookup support (ApiGateway sub-resources, niche
|
|
639
|
+
services, anything in Cloud Control API), use the explicit
|
|
640
|
+
`--resource <id>=<physicalId>` override mode — selective mode handles
|
|
641
|
+
exactly this case. Resource types whose provider does not implement
|
|
642
|
+
import are reported as `unsupported` and skipped.
|
|
643
|
+
|
|
546
644
|
## State Management
|
|
547
645
|
|
|
548
646
|
State is stored in S3. Keys are scoped by `(stackName, region)` so the same
|
package/dist/cli.js
CHANGED
|
@@ -7749,6 +7749,27 @@ var CustomResourceProvider = class _CustomResourceProvider {
|
|
|
7749
7749
|
sleep(ms) {
|
|
7750
7750
|
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
7751
7751
|
}
|
|
7752
|
+
/**
|
|
7753
|
+
* Adopt an existing custom resource into cdkd state.
|
|
7754
|
+
*
|
|
7755
|
+
* **Explicit override only.** A custom resource's identity is the
|
|
7756
|
+
* `PhysicalResourceId` returned by its user-supplied Lambda handler at
|
|
7757
|
+
* Create time — there is no AWS-side resource cdkd can introspect, no
|
|
7758
|
+
* tag API, and no `aws:cdk:path` to look up by. cdkd cannot rediscover
|
|
7759
|
+
* a custom resource without invoking the handler, which would mutate
|
|
7760
|
+
* state.
|
|
7761
|
+
*
|
|
7762
|
+
* Users adopting an existing custom resource should pass
|
|
7763
|
+
* `--resource <logicalId>=<physicalResourceId>` — the same value the
|
|
7764
|
+
* handler returned originally.
|
|
7765
|
+
*/
|
|
7766
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- explicit-override-only intentionally has no AWS calls
|
|
7767
|
+
async import(input) {
|
|
7768
|
+
if (input.knownPhysicalId) {
|
|
7769
|
+
return { physicalId: input.knownPhysicalId, attributes: {} };
|
|
7770
|
+
}
|
|
7771
|
+
return null;
|
|
7772
|
+
}
|
|
7752
7773
|
};
|
|
7753
7774
|
|
|
7754
7775
|
// src/provisioning/provider-registry.ts
|
|
@@ -11372,6 +11393,25 @@ var S3BucketPolicyProvider = class {
|
|
|
11372
11393
|
);
|
|
11373
11394
|
}
|
|
11374
11395
|
}
|
|
11396
|
+
/**
|
|
11397
|
+
* Adopt an existing S3 bucket policy into cdkd state.
|
|
11398
|
+
*
|
|
11399
|
+
* **Explicit override only.** An `S3::BucketPolicy` is a policy document
|
|
11400
|
+
* attached to a bucket via `PutBucketPolicy` — it has no standalone
|
|
11401
|
+
* identity and is not independently taggable. There is no `aws:cdk:path`
|
|
11402
|
+
* tag to look up by; only the bucket itself is taggable.
|
|
11403
|
+
*
|
|
11404
|
+
* Users adopting an existing bucket policy should pass
|
|
11405
|
+
* `--resource <logicalId>=<bucketName>` (matching the physical id
|
|
11406
|
+
* format returned by `create()`).
|
|
11407
|
+
*/
|
|
11408
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- explicit-override-only intentionally has no AWS calls
|
|
11409
|
+
async import(input) {
|
|
11410
|
+
if (input.knownPhysicalId) {
|
|
11411
|
+
return { physicalId: input.knownPhysicalId, attributes: {} };
|
|
11412
|
+
}
|
|
11413
|
+
return null;
|
|
11414
|
+
}
|
|
11375
11415
|
};
|
|
11376
11416
|
|
|
11377
11417
|
// src/provisioning/providers/sqs-queue-provider.ts
|
|
@@ -11808,6 +11848,25 @@ var SQSQueuePolicyProvider = class {
|
|
|
11808
11848
|
);
|
|
11809
11849
|
}
|
|
11810
11850
|
}
|
|
11851
|
+
/**
|
|
11852
|
+
* Adopt an existing SQS queue policy into cdkd state.
|
|
11853
|
+
*
|
|
11854
|
+
* **Explicit override only.** A `QueuePolicy` is an attachment applied to
|
|
11855
|
+
* a queue via `SetQueueAttributes(Policy=...)` — it has no standalone
|
|
11856
|
+
* identity and is not independently taggable. There is no `aws:cdk:path`
|
|
11857
|
+
* tag to look up by; only the queue itself is taggable.
|
|
11858
|
+
*
|
|
11859
|
+
* Users adopting an existing queue policy should pass
|
|
11860
|
+
* `--resource <logicalId>=<queueUrl>` (matching the physical id format
|
|
11861
|
+
* returned by `create()`, which uses the first queue URL).
|
|
11862
|
+
*/
|
|
11863
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- explicit-override-only intentionally has no AWS calls
|
|
11864
|
+
async import(input) {
|
|
11865
|
+
if (input.knownPhysicalId) {
|
|
11866
|
+
return { physicalId: input.knownPhysicalId, attributes: {} };
|
|
11867
|
+
}
|
|
11868
|
+
return null;
|
|
11869
|
+
}
|
|
11811
11870
|
};
|
|
11812
11871
|
|
|
11813
11872
|
// src/provisioning/providers/sns-topic-provider.ts
|
|
@@ -12300,6 +12359,25 @@ var SNSSubscriptionProvider = class {
|
|
|
12300
12359
|
);
|
|
12301
12360
|
}
|
|
12302
12361
|
}
|
|
12362
|
+
/**
|
|
12363
|
+
* Adopt an existing SNS subscription into cdkd state.
|
|
12364
|
+
*
|
|
12365
|
+
* **Explicit override only.** SNS subscriptions are attached to a parent
|
|
12366
|
+
* topic and identified by their `SubscriptionArn`, but the SubscribeAPI
|
|
12367
|
+
* does not accept tags and the AWS tag APIs do not cover subscriptions
|
|
12368
|
+
* (only Topics are taggable). There is therefore no `aws:cdk:path` tag
|
|
12369
|
+
* we could use for auto-lookup.
|
|
12370
|
+
*
|
|
12371
|
+
* Users adopting an existing subscription should pass
|
|
12372
|
+
* `--resource <logicalId>=<subscriptionArn>`.
|
|
12373
|
+
*/
|
|
12374
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- explicit-override-only intentionally has no AWS calls
|
|
12375
|
+
async import(input) {
|
|
12376
|
+
if (input.knownPhysicalId) {
|
|
12377
|
+
return { physicalId: input.knownPhysicalId, attributes: {} };
|
|
12378
|
+
}
|
|
12379
|
+
return null;
|
|
12380
|
+
}
|
|
12303
12381
|
};
|
|
12304
12382
|
|
|
12305
12383
|
// src/provisioning/providers/sns-topic-policy-provider.ts
|
|
@@ -12439,6 +12517,26 @@ var SNSTopicPolicyProvider = class {
|
|
|
12439
12517
|
}
|
|
12440
12518
|
this.logger.debug(`Successfully deleted SNS topic policy ${logicalId}`);
|
|
12441
12519
|
}
|
|
12520
|
+
/**
|
|
12521
|
+
* Adopt an existing SNS topic policy into cdkd state.
|
|
12522
|
+
*
|
|
12523
|
+
* **Explicit override only.** A `TopicPolicy` is an attachment to one or
|
|
12524
|
+
* more SNS topics applied via `SetTopicAttributes(AttributeName=Policy)` —
|
|
12525
|
+
* it has no standalone identity and is not independently taggable. There
|
|
12526
|
+
* is no `aws:cdk:path` tag to look up by, and the policy has no name/ARN
|
|
12527
|
+
* of its own.
|
|
12528
|
+
*
|
|
12529
|
+
* Users adopting an existing topic policy should pass
|
|
12530
|
+
* `--resource <logicalId>=<comma-joined-topic-ARNs>` (matching the
|
|
12531
|
+
* physical id format returned by `create()`).
|
|
12532
|
+
*/
|
|
12533
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- explicit-override-only intentionally has no AWS calls
|
|
12534
|
+
async import(input) {
|
|
12535
|
+
if (input.knownPhysicalId) {
|
|
12536
|
+
return { physicalId: input.knownPhysicalId, attributes: {} };
|
|
12537
|
+
}
|
|
12538
|
+
return null;
|
|
12539
|
+
}
|
|
12442
12540
|
/**
|
|
12443
12541
|
* Set the policy on a single SNS topic
|
|
12444
12542
|
*/
|
|
@@ -13294,6 +13392,26 @@ var LambdaPermissionProvider = class {
|
|
|
13294
13392
|
);
|
|
13295
13393
|
}
|
|
13296
13394
|
}
|
|
13395
|
+
/**
|
|
13396
|
+
* Adopt an existing Lambda permission into cdkd state.
|
|
13397
|
+
*
|
|
13398
|
+
* **Explicit override only.** A `Lambda::Permission` is a single statement
|
|
13399
|
+
* within a function's resource-based policy added via `AddPermission`. It
|
|
13400
|
+
* has no independent ARN, no taggable identity, and the only way to find
|
|
13401
|
+
* it is to call `GetPolicy` on the parent function and parse the JSON
|
|
13402
|
+
* statements — which the user knows by `StatementId` already.
|
|
13403
|
+
*
|
|
13404
|
+
* Users adopting an existing permission should pass
|
|
13405
|
+
* `--resource <logicalId>=<statementId>` (matching the physical id
|
|
13406
|
+
* format returned by `create()`).
|
|
13407
|
+
*/
|
|
13408
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- explicit-override-only intentionally has no AWS calls
|
|
13409
|
+
async import(input) {
|
|
13410
|
+
if (input.knownPhysicalId) {
|
|
13411
|
+
return { physicalId: input.knownPhysicalId, attributes: { Id: input.knownPhysicalId } };
|
|
13412
|
+
}
|
|
13413
|
+
return null;
|
|
13414
|
+
}
|
|
13297
13415
|
};
|
|
13298
13416
|
|
|
13299
13417
|
// src/provisioning/providers/lambda-url-provider.ts
|
|
@@ -13427,6 +13545,26 @@ var LambdaUrlProvider = class {
|
|
|
13427
13545
|
);
|
|
13428
13546
|
}
|
|
13429
13547
|
}
|
|
13548
|
+
/**
|
|
13549
|
+
* Adopt an existing Lambda Function URL into cdkd state.
|
|
13550
|
+
*
|
|
13551
|
+
* **Explicit override only.** A `Lambda::Url` is a configuration attached
|
|
13552
|
+
* to a Lambda function — it has no standalone identity (the natural
|
|
13553
|
+
* physical id is the parent function's ARN/name) and `FunctionUrlConfig`
|
|
13554
|
+
* is not independently taggable. There is no `aws:cdk:path` tag to look
|
|
13555
|
+
* up by; only the parent function carries the CDK path tag.
|
|
13556
|
+
*
|
|
13557
|
+
* Users adopting an existing function URL should pass
|
|
13558
|
+
* `--resource <logicalId>=<functionArnOrName>` (matching the physical id
|
|
13559
|
+
* format returned by `create()`).
|
|
13560
|
+
*/
|
|
13561
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- explicit-override-only intentionally has no AWS calls
|
|
13562
|
+
async import(input) {
|
|
13563
|
+
if (input.knownPhysicalId) {
|
|
13564
|
+
return { physicalId: input.knownPhysicalId, attributes: {} };
|
|
13565
|
+
}
|
|
13566
|
+
return null;
|
|
13567
|
+
}
|
|
13430
13568
|
/**
|
|
13431
13569
|
* Build CORS configuration from CDK properties
|
|
13432
13570
|
*/
|
|
@@ -13669,6 +13807,27 @@ var LambdaEventSourceMappingProvider = class {
|
|
|
13669
13807
|
);
|
|
13670
13808
|
}
|
|
13671
13809
|
}
|
|
13810
|
+
/**
|
|
13811
|
+
* Adopt an existing Lambda event source mapping into cdkd state.
|
|
13812
|
+
*
|
|
13813
|
+
* **Explicit override only.** Event source mappings are identified by a
|
|
13814
|
+
* UUID returned at create time. While Lambda event source mappings ARE
|
|
13815
|
+
* taggable since 2020, CDK does NOT propagate the `aws:cdk:path` tag to
|
|
13816
|
+
* them by default (the `Tags` property must be explicitly opted into),
|
|
13817
|
+
* and the natural lookup is by `(FunctionName, EventSourceArn)` — which
|
|
13818
|
+
* the user already knows.
|
|
13819
|
+
*
|
|
13820
|
+
* Users adopting an existing event source mapping should pass
|
|
13821
|
+
* `--resource <logicalId>=<UUID>` (matching the physical id format
|
|
13822
|
+
* returned by `create()`).
|
|
13823
|
+
*/
|
|
13824
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- explicit-override-only intentionally has no AWS calls
|
|
13825
|
+
async import(input) {
|
|
13826
|
+
if (input.knownPhysicalId) {
|
|
13827
|
+
return { physicalId: input.knownPhysicalId, attributes: { Id: input.knownPhysicalId } };
|
|
13828
|
+
}
|
|
13829
|
+
return null;
|
|
13830
|
+
}
|
|
13672
13831
|
};
|
|
13673
13832
|
|
|
13674
13833
|
// src/provisioning/providers/lambda-layer-provider.ts
|
|
@@ -19792,6 +19951,25 @@ var CloudFrontOAIProvider = class {
|
|
|
19792
19951
|
`Unsupported attribute: ${attributeName} for AWS::CloudFront::CloudFrontOriginAccessIdentity`
|
|
19793
19952
|
);
|
|
19794
19953
|
}
|
|
19954
|
+
/**
|
|
19955
|
+
* Adopt an existing CloudFront Origin Access Identity into cdkd state.
|
|
19956
|
+
*
|
|
19957
|
+
* **Explicit override only.** OAIs do not support tags — their identity
|
|
19958
|
+
* is the `CallerReference` set at create time, plus the auto-generated
|
|
19959
|
+
* `Id`. There is no `aws:cdk:path` tag API to look up by; CloudFront's
|
|
19960
|
+
* `ListCloudFrontOriginAccessIdentities` returns Id/Comment/CallerReference
|
|
19961
|
+
* but no tags.
|
|
19962
|
+
*
|
|
19963
|
+
* Users adopting an existing OAI should pass
|
|
19964
|
+
* `--resource <logicalId>=<oaiId>` (e.g. `E1ABCDEF123456`).
|
|
19965
|
+
*/
|
|
19966
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- explicit-override-only intentionally has no AWS calls
|
|
19967
|
+
async import(input) {
|
|
19968
|
+
if (input.knownPhysicalId) {
|
|
19969
|
+
return { physicalId: input.knownPhysicalId, attributes: { Id: input.knownPhysicalId } };
|
|
19970
|
+
}
|
|
19971
|
+
return null;
|
|
19972
|
+
}
|
|
19795
19973
|
};
|
|
19796
19974
|
|
|
19797
19975
|
// src/provisioning/providers/cloudfront-distribution-provider.ts
|
|
@@ -20515,6 +20693,27 @@ var AgentCoreRuntimeProvider = class {
|
|
|
20515
20693
|
}
|
|
20516
20694
|
throw new Error(`Unsupported attribute: ${attributeName} for AWS::BedrockAgentCore::Runtime`);
|
|
20517
20695
|
}
|
|
20696
|
+
/**
|
|
20697
|
+
* Adopt an existing BedrockAgentCore Runtime into cdkd state.
|
|
20698
|
+
*
|
|
20699
|
+
* **Explicit override only (for now).** The BedrockAgentCore SDK does
|
|
20700
|
+
* expose `ListTagsForResource`, so a future PR could add full tag-based
|
|
20701
|
+
* auto-lookup. For this batch we keep it override-only to ship
|
|
20702
|
+
* consistently with the other batch-5 attachment-style providers; users
|
|
20703
|
+
* adopting an existing runtime should pass
|
|
20704
|
+
* `--resource <logicalId>=<agentRuntimeId>` (e.g. `runtime-12345`,
|
|
20705
|
+
* matching the physical id format returned by `create()`).
|
|
20706
|
+
*/
|
|
20707
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- explicit-override-only intentionally has no AWS calls
|
|
20708
|
+
async import(input) {
|
|
20709
|
+
if (input.knownPhysicalId) {
|
|
20710
|
+
return {
|
|
20711
|
+
physicalId: input.knownPhysicalId,
|
|
20712
|
+
attributes: { AgentRuntimeId: input.knownPhysicalId }
|
|
20713
|
+
};
|
|
20714
|
+
}
|
|
20715
|
+
return null;
|
|
20716
|
+
}
|
|
20518
20717
|
};
|
|
20519
20718
|
|
|
20520
20719
|
// src/provisioning/providers/stepfunctions-provider.ts
|
|
@@ -33859,15 +34058,38 @@ async function importCommand(stackArg, options) {
|
|
|
33859
34058
|
if (overrides.size > 0) {
|
|
33860
34059
|
logger.debug(`User-supplied physical IDs: ${[...overrides.keys()].join(", ")}`);
|
|
33861
34060
|
}
|
|
34061
|
+
const selectiveMode = overrides.size > 0 && !options.auto;
|
|
34062
|
+
if (selectiveMode) {
|
|
34063
|
+
logger.info(
|
|
34064
|
+
`Selective mode: only importing the ${overrides.size} resource(s) you listed (${[...overrides.keys()].join(", ")}). Pass --auto to also tag-import the rest.`
|
|
34065
|
+
);
|
|
34066
|
+
}
|
|
33862
34067
|
const template = stackInfo.template;
|
|
33863
34068
|
const templateParser = new TemplateParser();
|
|
33864
34069
|
const resources = collectImportableResources(template);
|
|
33865
34070
|
logger.info(`Found ${resources.length} resource(s) in template`);
|
|
34071
|
+
const templateLogicalIds = new Set(resources.map((r) => r.logicalId));
|
|
34072
|
+
for (const overrideId of overrides.keys()) {
|
|
34073
|
+
if (!templateLogicalIds.has(overrideId)) {
|
|
34074
|
+
throw new Error(
|
|
34075
|
+
`--resource / --resource-mapping references logical ID '${overrideId}' which is not in the synthesized template for stack '${stackInfo.stackName}'. Available IDs: ${[...templateLogicalIds].join(", ")}`
|
|
34076
|
+
);
|
|
34077
|
+
}
|
|
34078
|
+
}
|
|
33866
34079
|
const owner = `${process.env["USER"] || "unknown"}@${process.env["HOSTNAME"] || "host"}:${process.pid}`;
|
|
33867
34080
|
await lockManager.acquireLock(stackInfo.stackName, targetRegion, owner, "import");
|
|
33868
34081
|
try {
|
|
33869
34082
|
const rows = [];
|
|
33870
34083
|
for (const { logicalId, resource } of resources) {
|
|
34084
|
+
if (selectiveMode && !overrides.has(logicalId)) {
|
|
34085
|
+
rows.push({
|
|
34086
|
+
logicalId,
|
|
34087
|
+
resourceType: resource.Type,
|
|
34088
|
+
outcome: "skipped-out-of-scope",
|
|
34089
|
+
reason: "not in --resource / --resource-mapping (use --auto to include)"
|
|
34090
|
+
});
|
|
34091
|
+
continue;
|
|
34092
|
+
}
|
|
33871
34093
|
const outcome = await importOne({
|
|
33872
34094
|
logicalId,
|
|
33873
34095
|
resource,
|
|
@@ -34057,6 +34279,7 @@ function printSummary(rows) {
|
|
|
34057
34279
|
imported: 0,
|
|
34058
34280
|
"skipped-no-impl": 0,
|
|
34059
34281
|
"skipped-not-found": 0,
|
|
34282
|
+
"skipped-out-of-scope": 0,
|
|
34060
34283
|
failed: 0
|
|
34061
34284
|
};
|
|
34062
34285
|
logger.info("");
|
|
@@ -34069,7 +34292,7 @@ function printSummary(rows) {
|
|
|
34069
34292
|
}
|
|
34070
34293
|
logger.info("");
|
|
34071
34294
|
logger.info(
|
|
34072
|
-
`Summary: ${counts.imported} imported, ${counts["skipped-not-found"]} not found, ${counts["skipped-no-impl"]} unsupported, ${counts.failed} failed`
|
|
34295
|
+
`Summary: ${counts.imported} imported, ${counts["skipped-not-found"]} not found, ${counts["skipped-no-impl"]} unsupported, ${counts["skipped-out-of-scope"]} out of scope, ${counts.failed} failed`
|
|
34073
34296
|
);
|
|
34074
34297
|
}
|
|
34075
34298
|
function formatOutcome(outcome) {
|
|
@@ -34080,6 +34303,8 @@ function formatOutcome(outcome) {
|
|
|
34080
34303
|
return "\xB7";
|
|
34081
34304
|
case "skipped-no-impl":
|
|
34082
34305
|
return "?";
|
|
34306
|
+
case "skipped-out-of-scope":
|
|
34307
|
+
return "-";
|
|
34083
34308
|
case "failed":
|
|
34084
34309
|
return "\u2717";
|
|
34085
34310
|
}
|
|
@@ -34095,18 +34320,22 @@ async function confirmPrompt2(prompt) {
|
|
|
34095
34320
|
}
|
|
34096
34321
|
function createImportCommand() {
|
|
34097
34322
|
const cmd = new Command12("import").description(
|
|
34098
|
-
"Adopt already-deployed AWS resources into cdkd state. Reads the CDK app to find logical IDs, resource types, and dependencies
|
|
34323
|
+
"Adopt already-deployed AWS resources into cdkd state. Reads the CDK app to find logical IDs, resource types, and dependencies. With no flags, imports every resource via the aws:cdk:path tag. With --resource / --resource-mapping, only the listed resources are imported (CDK CLI parity); pass --auto to also tag-import the rest."
|
|
34099
34324
|
).argument(
|
|
34100
34325
|
"[stack]",
|
|
34101
34326
|
"Stack to import. Optional when the synthesized app contains exactly one stack."
|
|
34102
34327
|
).option(
|
|
34103
34328
|
"--resource <id=physical>",
|
|
34104
|
-
"Explicit physical-id override for one logical ID. Repeatable.
|
|
34329
|
+
"Explicit physical-id override for one logical ID. Repeatable. When at least one --resource is given, only listed resources are imported (CDK CLI parity). Pass --auto to also tag-import everything else.",
|
|
34105
34330
|
collectMultiple,
|
|
34106
34331
|
[]
|
|
34107
34332
|
).option(
|
|
34108
34333
|
"--resource-mapping <file>",
|
|
34109
|
-
"Path to a JSON file of {logicalId: physicalId} overrides (CDK CLI `cdk import --resource-mapping` compatible)."
|
|
34334
|
+
"Path to a JSON file of {logicalId: physicalId} overrides (CDK CLI `cdk import --resource-mapping` compatible). Implies selective mode unless --auto is set."
|
|
34335
|
+
).option(
|
|
34336
|
+
"--auto",
|
|
34337
|
+
"Hybrid mode: when explicit overrides are supplied, ALSO tag-import every other resource in the template. Without this flag, --resource / --resource-mapping behave as a whitelist (CDK CLI parity).",
|
|
34338
|
+
false
|
|
34110
34339
|
).option("--dry-run", "Show planned imports without writing state", false).option(
|
|
34111
34340
|
"--force",
|
|
34112
34341
|
"Overwrite an existing state record. Without this, an existing state file aborts the import.",
|
|
@@ -34148,7 +34377,7 @@ function reorderArgs(argv) {
|
|
|
34148
34377
|
}
|
|
34149
34378
|
async function main() {
|
|
34150
34379
|
const program = new Command13();
|
|
34151
|
-
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.
|
|
34380
|
+
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.23.0");
|
|
34152
34381
|
program.addCommand(createBootstrapCommand());
|
|
34153
34382
|
program.addCommand(createSynthCommand());
|
|
34154
34383
|
program.addCommand(createListCommand());
|