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).
- Terraform 0.9.3+
- Terraformer 0.8.15+
- Go 1.15+ (to build the discovery cli)
- IBM Cloud Provider
- Mongodb v4.4.5+
-
main.go
This file contains the web server and handlers.
-
cmd/discovery
Code for the executable.
-
Build and install the executable 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 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]:IBMTerraform/configuration-discovery/.git cd configuration-discovery/ go run main.go docs.go http://localhost:8080
-
Or
make run-mac <or make run-local for linux>
-
Or 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]:IBMTerraform/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. Thank you for your help and interest!
Head over to the releases page and download the latest release and place it under the path. For example,
wget https://github.com/anilkumarnagaraj/terraform-provider-ibm-api/releases/download/v0.1.1/discovery_0.1.1_darwin_arm64.zip
untar discovery_0.1.1_darwin_arm64.zip
mv discovery <$GOPATH/bin or any other directory in path>
If you have go installed, run this command
go install github.com/anilkumarnagaraj/terraform-provider-ibm-api/cmd/discovery
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 importing the terrraform configuration. |
discovery import | Import TF config for resources in your ibm cloud account. Import all the resources for this service. Imports config and statefile. If a statefile is already present, merging will be done. |
Start using discovery executable
- 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.
The project is licensed under the Apache 2.0 License. A copy is also available in the LICENSE file in this repository.