Use "Configuration Discovery" to import the existing Cloud resources (in your account) and its configuration settings - to auto-generate the terraform configuration file (.tf) and state file (.tfstate). It makes it easy for you to adopt the Infrastructure-as-Code practices; it can reverse engineer the current IBM Cloud environment (that was provisioned using UI or CLI).
Configuration Discovery tool is powered by Terraformer. This Tool will augment the terraformer, with a number of capabilities that are native to IBM Cloud.
- Terraform 0.12.31 or 0.13+
- Terraformer 0.8.17+
- IBM Cloud Provider
- Go 1.15+ (to build the discovery tool)
- Mongodb v4.4.5+ (to run as a server)
Run this command to install the Terraformer and Configuration Discovery tool:
curl -qL https://raw.githubusercontent.com/IBM-Cloud/configuration-discovery/main/install.sh | sh
You can download pre-built binaries for linux and macOS on the releases page.
- Download the IBM Cloud provider plugin for Terraform from release page.
- Unzip the release archive to extract the plugin binary (
terraform-provider-ibm_vX.Y.Z
). - Move the binary into the Terraform plugins directory for the platform.
- Linux/Unix:
~/.terraform.d/plugins/linux_amd64/
- Mac OS X:
~/.terraform.d/plugins/darwin_amd64/
- Linux/Unix:
$> discovery
NAME:
IBM Cloud Discovery CLI - Lets you create state file and TF Config from Resources in your cloud account. For the green field and brown field imports of config and statefile, and all terraformer related
USAGE:
discovery [global options] command [command options] [arguments...]
VERSION:
0.1.1
COMMANDS:
help, h Shows a list of commands or help for one command
discovery:
version discovery version
config, configure discovery config [--config_name CONFIG_NAME]
import discovery import --services SERVICES_TO_IMPORT [--tags TAGS] [--config_name CONFIG_NAME] [--compact]
GLOBAL OPTIONS:
--help, -h show help
--version, -v print the version
Below commands help you to import your resources into terraform configuration. For more detailed description, run discovery help
. For help on a command, run discovery help <command>
Command | Description |
---|---|
discovery version | IBM Cloud Discovery CLI version. Gives you other dependency information. Shows all supported importable resources |
discovery config | Create a local configuration directory for exporting the terrraform configuration and state files |
discovery import | Import TF config and state for resources in your ibm cloud account. Import all the resources for this service |
You are now ready to use the Configuration Discovery tool tutorial.
- Green-field scenario - importing the existing infrastructure on a clean state
- Upgrading the Terraform state file to the latest Terraform versions
- Brown-field scenario - importing the existing infrastructure and merge the generated Terraform files into the presence of already existing Terraform files.
- Rewrite Terraform resource into Terraform modules.
- Supports integration of the Configuration Discovery tool into the VS Code extension for IBM Cloud Schematics
-
main.go
This file contains the web server and handlers.
-
cmd/discovery
Code for the tool.
-
Build and install the tool to your GOPATH
make install-cli
-
Export the required env vars
IC_API_KEY: Your ibm cloud api key. Imports resources in that account, for which user has access. DISCOVERY_CONFIG_DIR: Directory, where to generate and import the terraform code. discovery uses only this directory for any read/write op.
-
Example commands
discovery version discovery config --config_name testfolder discovery import --services ibm_is_vpc --config_name testfolder --compact --merge
-
Start the server
cd /go/src/github.com git clone [email protected]:IBM-Cloud/configuration-discovery.git cd configuration-discovery/ go run main.go docs.go https://localhost:8080
-
Or
make run-mac <or make run-local for linux>
-
Run as docker container
make docker-build make docker-run
First two need mongodb service running on localhost:27017. Third needs mongodb running as docker container. To run mongodb as docker container with 27017 exposed outside. This will work for all three methods above. Run this before any of the above steps
make docker-run-mongo
cd /go/src/github.com
git clone [email protected]:IBM-Cloud/configuration-discovery.git
cd configuration-discovery/
docker build -t configuration-discovery .
docker images
export API_IMAGE=configuration-discovery:latest
docker-compose up --build -d
Please have a look at the CONTRIBUTING.md file for some guidance before submitting a pull request.
- Is something broken? Have a issue/bug to report? use the Bug report link. But before raising a issue, please check the issues list to see if the issue is already raised by someone
- Do you have a new feature or enhancement you would like to see? use the Feature request link.
- Head to config-discovery-users slack channel to engage with the team.
The project is licensed under the Apache 2.0 License. A copy is also available in the LICENSE file in this repository.