Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. # Terrafrom JSON tfjson
  2.  
  3. ## TL;DR
  4.  
  5. ```
  6. tf = Tfjson()
  7. print('do your magic here')
  8. tf.save('/tmp/my.tf.json')
  9. ```
  10.  
  11. ## non objects
  12.  
  13. #### terraform
  14.  
  15. ```
  16. tf.terraform["required_version"] = ">= 0.12.0"
  17. ```
  18.  
  19. #### locals
  20.  
  21. ```
  22. tf.locals["command"] = "echo ${var.name}"
  23. ```
  24.  
  25. #### variable
  26.  
  27. ```
  28. tf.variable["regions"] = {
  29. "description": "available regions",
  30. "type": "list(string)",
  31. "default": ["eu","us"]
  32. }
  33. ```
  34.  
  35. #### output
  36.  
  37. ```
  38. tf.output["serverid"] = {
  39. "description": "lorem ipsum",
  40. "value": "${aws_instance.webide.id}"
  41. }
  42. ```
  43.  
  44. #### Provider
  45.  
  46. ```
  47. tf.provider['aws'] = {'region' : "us-west-1"}
  48. ```
  49.  
  50. #### module
  51.  
  52. ```
  53. tf.module["mymod"] = {
  54. "source": "../../mymod",
  55. "version": "= 1.0.0",
  56. "providers": {
  57. "aws": "$aws.usw1"
  58. }
  59. }
  60. ```
  61.  
  62.  
  63. ## new object types
  64.  
  65. #### Resource
  66.  
  67. For every resource, we create instances.
  68.  
  69. ```
  70. instances = {
  71. 'myweb' : {
  72. 'ami' : 'mywebami'
  73. },
  74. 'myapi' : {
  75. 'instance_type' : "t2.micro",
  76. "depends_on" : ["aws_instance.myweb"]
  77. }
  78. }
  79. tf.Resource('aws_instance', instances)
  80. # OR
  81. r = tf.Resource('aws_instance')
  82. r['myweb'] = {"ami":"mywebami"}
  83. ```
  84.  
  85. #### Data
  86.  
  87. This same approach is used for `data`
  88.  
  89. ```
  90. tf.Data('data_example', {})
  91. # OR
  92. x = tf.Data('data_example')
  93. x['data_example'] = {"x":"y"}
  94. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement