0.1.1 • Published 7 months ago

cdktf-import v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

CDKTF Import

A CLI for importing terraform resources using CDKTF. Terraform can import existing infrastructure resources. This functionality lets you bring existing resources under Terraform management. We want to bring the same experience to CDKTF. This CLI is based on the solution that comes from this comment on this Github issue.

Installation

npm i cdktf-import -g

Usage

cdktf-import <Resource_Name>.<Unique_ID> <Import_ID>

How it works

  1. Assume resources exist, write the approximate cdktf code.
  2. Change directory using this path cd cdktf.out/stacks/<stack>.
  3. Check Unique_ID in cdk.tf.json, as shown below:

        "resource": {
            "<Resource_Name>": {
                "<Unique_ID>": {
                    "//": {
                        "metadata": {
                            "path": "<Path>",
                            "uniqueId": "<Unique_ID>"
                        }
                    },
                },
            },
        },
  4. Initialize project by running command terraform init.

  5. Import resources using the values from the step 3 terraform import <Resource_Name>.<Unique_ID> <ID>.
  6. Change directory to cwd.
  7. Run cdktf diff <stack>.

BIG THANKS to Xing Yahao for providing the solution.

License

CDKTF Import is distributed under the MIT License. Feel free to use, modify, and distribute this library in your projects.

0.1.1

7 months ago

0.1.0

7 months ago

0.0.0

7 months ago