Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Terrafrom JSON tfjson
- ## TL;DR
- ```
- tf = Tfjson()
- print('do your magic here')
- tf.save('/tmp/my.tf.json')
- ```
- ## non objects
- #### terraform
- ```
- tf.terraform["required_version"] = ">= 0.12.0"
- ```
- #### locals
- ```
- tf.locals["command"] = "echo ${var.name}"
- ```
- #### variable
- ```
- tf.variable["regions"] = {
- "description": "available regions",
- "type": "list(string)",
- "default": ["eu","us"]
- }
- ```
- #### output
- ```
- tf.output["serverid"] = {
- "description": "lorem ipsum",
- "value": "${aws_instance.webide.id}"
- }
- ```
- #### Provider
- ```
- tf.provider['aws'] = {'region' : "us-west-1"}
- ```
- #### module
- ```
- tf.module["mymod"] = {
- "source": "../../mymod",
- "version": "= 1.0.0",
- "providers": {
- "aws": "$aws.usw1"
- }
- }
- ```
- ## new object types
- #### Resource
- For every resource, we create instances.
- ```
- instances = {
- 'myweb' : {
- 'ami' : 'mywebami'
- },
- 'myapi' : {
- 'instance_type' : "t2.micro",
- "depends_on" : ["aws_instance.myweb"]
- }
- }
- tf.Resource('aws_instance', instances)
- # OR
- r = tf.Resource('aws_instance')
- r['myweb'] = {"ami":"mywebami"}
- ```
- #### Data
- This same approach is used for `data`
- ```
- tf.Data('data_example', {})
- # OR
- x = tf.Data('data_example')
- x['data_example'] = {"x":"y"}
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement