用于在terrascript组件之间共享变量的terraobject包
terraobject的Python项目详细描述
TerraObject
用于在terrascript组件之间共享变量的terraobject包
您可以使用terraobject为多个类设置参数,并共享其他terraform资源使用的资源。
示例:
# Create the referencefromterraobjectimportTerraobject# Import the terrascript resources you needfromterrascriptimportproviderfromterrascript.digitalocean.dimportdigitalocean_volume# Create the objecto=Terraobject()# Add the providers, resources, data, as usualo.terrascript.add(provider("digitalocean",token="tokentoken"))# Get some info (e.g. data) and share to be used on other commandspersistent_volume=digitalocean_volume("persistent_volume",name="volume-nyc3-01",region="abc")o.terrascript.add(persistent_volume)o.shared['persistent_volume']=persistent_volume# And you can use and another place:o.shared['persistent_volume'].name# Dump the XMLprint(o.terrascript.dump())
有关terrascript的更多信息:
https://github.com/mjuenema/python-terrascript