starhawking / python-terrascript

Create Terraform files using Python scripts.
BSD 2-Clause "Simplified" License
515 stars 76 forks source link

Add 'vault' provider. #31

Closed lvets closed 6 years ago

lvets commented 6 years ago

Would you be able to add the 'vault' provider? See https://www.terraform.io/docs/providers/vault/index.html.

mjuenema commented 6 years ago

@lvets I am going to look into it but I am very busy at the moment so it won't be soon. Feel free to fork the repo, add the vault provider and submit a pull request if you feel confident to do so.

mjuenema commented 6 years ago

The following works with release 0.5.0.

from terrascript import *
ts = Terrascript()
ts += provider('vault', address='https://address.to.vault.provider:1234', token='TOKEN')
ts.validate()

Obviously this is a dummy example. Can you adapt this to your needs and provide feedback whether it works for you? Thanks, Markus

lvets commented 6 years ago

I'll give it a try. I did a quick test and saw this:

$ python test1.py
{
  "provider": {
    "vault": {
      "__DEFAULT__": {
        "address": "https://address.to.vault.provider:1234",
        "token": "TOKEN"
      }
    }
  }
}
$

Any idea why that DEFAULT is there?

mjuenema commented 6 years ago

This __DEFAULT__ key in the vault dictionary is there to satisfy JSON syntax. It's a dummy key when a provider does not have an alias which is possible in HCL. If you look a the Multiple Provider section in the Terrafrom documentation you will see that only the second AWS provider has an alias.