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.
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.
terraform-provider-ibm_vX.Y.Z
).~/.terraform.d/plugins/linux_amd64/
~/.terraform.d/plugins/darwin_amd64/
$> 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.
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 git@github.com:IBM-Cloud/configuration-discovery.git
cd configuration-discovery/
go run main.go docs.go
http://localhost:8080
Or
make run-mac
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 git@github.com: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.
The project is licensed under the Apache 2.0 License. A copy is also available in the LICENSE file in this repository.