-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from kishaningithub/update-documentation
Update readme documentation
- Loading branch information
Showing
2 changed files
with
158 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,140 @@ | ||
# tf-import-gen (Terraform import generator) | ||
|
||
[![Build Status](https://github.com/kishaningithub/tf-import-gen/actions/workflows/build.yml/badge.svg)](https://github.com/kishaningithub/tf-import-gen/actions/workflows/build.yml) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/kishaningithub/tf-import-gen)](https://goreportcard.com/report/github.com/kishaningithub/tf-import-gen) | ||
[![Latest release](https://img.shields.io/github/release/kishaningithub/tf-import-gen.svg)](https://github.com/kishaningithub/tf-import-gen/releases) | ||
|
||
Tool to generate terraform import statements to simplify state migrations from one terraform code base to another. | ||
|
||
<!-- TOC --> | ||
* [tf-import-gen (Terraform import generator)](#tf-import-gen-terraform-import-generator) | ||
* [Installation](#installation) | ||
* [Using Homebrew](#using-homebrew) | ||
* [Using docker](#using-docker) | ||
* [Others](#others) | ||
* [Examples](#examples) | ||
* [Generating import statements by module](#generating-import-statements-by-module) | ||
* [Generating import statements by resource](#generating-import-statements-by-resource) | ||
* [Generating import statements for all resources](#generating-import-statements-for-all-resources) | ||
* [Usage](#usage) | ||
* [Contributing](#contributing) | ||
<!-- TOC --> | ||
|
||
## Installation | ||
|
||
### Using Homebrew | ||
|
||
```bash | ||
brew install kishaningithub/tap/tf-import-gen | ||
``` | ||
|
||
### Using docker | ||
|
||
pulling the image | ||
```bash | ||
docker pull ghcr.io/kishaningithub/tf-import-gen:0.1.0 | ||
``` | ||
|
||
running the image in interactive mode (volume mounted aws folder for config) | ||
```bash | ||
docker run -it -v "${HOME}/.aws:/root/.aws" ghcr.io/kishaningithub/tf-import-gen:0.1.0 | ||
``` | ||
|
||
### Others | ||
|
||
Head over to the [releases page](https://github.com/kishaningithub/tf-import-gen/releases) and download a binary for your platform | ||
|
||
## Examples | ||
|
||
### Generating import statements by module | ||
|
||
```bash | ||
$ terraform show -json | tf-import-gen module.example | ||
|
||
import { | ||
to = module.example.aws_glue_catalog_database.example_db | ||
id = "123456789012:example_db" | ||
} | ||
|
||
import { | ||
to = module.example.aws_iam_instance_profile.example_instance_profile | ||
id = "example_instance_profile" | ||
} | ||
``` | ||
|
||
### Generating import statements by resource | ||
|
||
```bash | ||
$ terraform show -json | tf-import-gen aws_instance.example | ||
|
||
import { | ||
to = aws_instance.example | ||
id = "i-123456789012" | ||
} | ||
``` | ||
|
||
### Generating import statements for all resources | ||
|
||
```bash | ||
$ terraform show -json | tf-import-gen | ||
|
||
import { | ||
to = module.example.aws_glue_catalog_database.example_db | ||
id = "123456789012:example_db" | ||
} | ||
|
||
import { | ||
to = module.example.aws_iam_instance_profile.example_instance_profile | ||
id = "example_instance_profile" | ||
} | ||
|
||
import { | ||
to = aws_instance.example | ||
id = "i-123456789012" | ||
} | ||
``` | ||
|
||
## Usage | ||
|
||
```bash | ||
$ tf-import-gen --help | ||
|
||
Generate terraform import statements to simplify state migrations from one terraform code base to another. | ||
|
||
The address argument can be used to filter the instances by resource or module. If | ||
no pattern is given, import statements are generated for all the resources. | ||
|
||
The addresses must either be module addresses or absolute resource | ||
addresses, such as: | ||
aws_instance.example | ||
module.example | ||
module.example.module.child | ||
module.example.aws_instance.example | ||
|
||
Usage: | ||
tf-import-gen [flags] address | ||
|
||
Examples: | ||
|
||
## Generating import statements by module | ||
terraform show -json | tf-import-gen module.example | ||
|
||
## Generating import statements by resource | ||
terraform show -json | tf-import-gen aws_instance.example | ||
|
||
## Generating import statements for all resources | ||
terraform show -json | tf-import-gen | ||
|
||
|
||
Flags: | ||
-h, --help help for tf-import-gen | ||
-v, --version version for tf-import-gen | ||
``` | ||
|
||
|
||
## Contributing | ||
|
||
PRs are always welcome!. Refer [CONTRIBUTING.md](./CONTRIBUTING.md) for more information | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters