https://github.com/glenjamin/azure-terraform-generate
Generate terraform config from deployed azure resources.
https://github.com/glenjamin/azure-terraform-generate
Last synced: 9 days ago
JSON representation
Generate terraform config from deployed azure resources.
- Host: GitHub
- URL: https://github.com/glenjamin/azure-terraform-generate
- Owner: glenjamin
- Created: 2017-11-26T17:50:51.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-28T13:01:21.000Z (almost 7 years ago)
- Last Synced: 2024-09-28T09:13:45.216Z (7 months ago)
- Language: Python
- Size: 19.5 KB
- Stars: 4
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - glenjamin/azure-terraform-generate - Generate terraform config from deployed azure resources. (Python)
README
# Azure Terraform Generate
Generate terraform config from deployed azure resources.
Made a bunch of stuff in azure but wish you'd used terraform? Now's your chance to fix the mistakes of past-you.
## Work in progress
This is currently just a proof of concept type thing.
## Requirements
* Python 3.5+
* The Azure 2.0 CLI (The python based `az` one).In order to dodge API calling and avoid having to deal with azure authentication, this project abdicates all responsibility for that functionality by shelling out to the azure CLI.
## Install
```sh
pip3 install aztfgen
```## Usage
The arguments are intended to match whatever you'll also need to pass to `terraform import` to take care of getting the current state into terraform.
```
aztfgen
```### Importing lots of resources
If you want to do a bulk import, your best bet is to use a loop and some shell.
For example:
```
az network nsg list > nsgs.json
cat nsgs.json | jq 'map("aztfgen azurerm_network_security_group." + .name + " " + .id + " > " + .name + ".tf") | join("\n")' -r | bash -x
cat nsgs.json | jq 'map("terraform import azurerm_network_security_group." + .name + " " + .id) | join("\n")' -r | bash
```## License
MIT