Module terraform#

Typedefs#

typedef terraform::config::nesting_mode_t#
  • Base type string

  • Type constraint (self in ['set','list','dict','single'])

Entities#

entity terraform::Provider#

Parents: std::Entity

A Terraform provider

attribute string namespace#

Organization in the terraform registry, packaging this provider

attribute string type#

The provider type (e.g. “aws”, “vsphere”, “local”)

attribute string version='latest'#

The version of the provider to use, setting it to null will get the latest one

attribute string alias=''#

An alias to differentiate this provider from other providers with the same binary but different config

attribute dict config#

The config to apply to this provider

attribute bool manual_config=true#

Whether the user wishes to provide the config as a dict, if false the config should be provided as a config block entity tree via the root_config relation.

attribute bool auto_agent=true#

Whether to start an agent automatically or not. If set to false the relation agent_config should be set manually. :rel agent_config: This needs to be set only if auto_agent=false

relation std::AgentConfig agent_config [1]#

Relation to the agent config

relation terraform::config::Block root_config [0:1]#

Relation to the root configuration, or null if manual_config is true

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity terraform::Resource#

Parents: std::PurgeableResource

A Terraform resource

attribute string type#

The type of resource this is

attribute string name#

An arbitrary name to identify this resource

attribute string? terraform_id=null#

If this is set, and the resource state is not stored in parameter yet, the handler will first try to import it, using the provided value as terraform id. :rel provider: The terraform provider for this resource

attribute dict config#

The configuration for this resource

attribute bool manual_config=true#

Whether the user wishes to provide the config as a dict, if false the config should be provided as a config block entity tree via the root_config relation.

attribute bool purge_on_delete=false#
relation terraform::Provider provider [1]#

Relation to the resource provider

relation terraform::config::Block root_config [0:1]#

Relation to the root configuration, or null if manual_config is true

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

entity terraform::config::Block#

Parents: std::Entity

This entity represents a block of attributes in a terraform module. It can be used for anyone using the module to build a config. It is being used by the generator to generate the config of a resource or provider.

Source for the schema:

https://github.com/inmanta/inmanta-tfplugin/blob/7269bc7d28d751b5dc110161dae29a6209c3fb63/docs/tf_grpc_plugin/proto/inmanta_tfplugin/tfplugin5.proto

tfplugin5.proto: L81: message Block { L82: int64 version = 1; L83: repeated Attribute attributes = 2; L84: repeated NestedBlock block_types = 3; L85: string description = 4; L86: StringKind description_kind = 5; L87: bool deprecated = 6; L88: }

attribute string? name=null#

The name of this config section in the parent config block. Should be left null for the root config block.

attribute dict attributes#

A dictionary of attributes. The key is the attribute name as specified in the terraform provider schema. The value is the value assigned to this attribute in the corresponding inmanta entity.

attribute bool deprecated=false#

If true, will raise a warning everytime the configuration block is used.

attribute terraform::config::nesting_mode_t nesting_mode='single'#
attribute string key#

The key, required for list and dict nesting mode, automatically set otherwise.

attribute dict _config#

Generated, the serialized version of this config.

attribute dict _state#

Generated, the current state for the resource attached to this config block. The state here matches the same element as this config block. (The config should be a subset of the state if there is not change between last compile config and current compile config, in which case the config will still be unknown). i.e. The following configuration structure can be constructed with entities. .. code-block:: terraform::config::Block( name=null, attributes={“name”: “Albert”}, children=[ terraform::config::Block( name=”children”, attributes={“name”: “Bob”, “age”: 12}, nesting_mode=”set”, ), terraform::config::Block( name=”children”, attributes={“name”: “Alice”, “age”: 14}, nesting_mode=”set”, ), terraform::config::Block( name=”pets”, attributes={“type”: “dog”}, nesting_mode=”dict”, key=”Brutus”, ), terraform::config::Block( name=”favorite_dishes”, attributes={“name”: “Pizza”}, nesting_mode=”list”, key=”1”, ), terraform::config::Block( name=”favorite_dishes”, attributes={“name”: “Pasta”}, nesting_mode=”list”, key=”2”, ) ], parent=null, state=get_resource_attribute(terraform_resource, []), ) It will be serialized as follows (the order of the children list might differ): .. code-block:: { “name”: “Albert”, “children”: [ { “name”: “Alice”, “age”: 14, }, { “name”: “Bob”, “age”: 12, }, ], “pets”: { “Brutus”: { “type”: “dog”, }, }, “favorite_dishes”: [ {“name”: “Pizza”}, {“name”: “Pasta”}, ], }

relation terraform::config::Block children [0:*]#

other end: terraform::config::Block.parent [0:1]

relation terraform::config::Block parent [0:1]#

other end: terraform::config::Block.children [0:*]

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

Implementations#

implementation terraform::agentConfig#
implementation terraform::providerBlockConfig#

If self.manual_config is false, the user should provide the root_config relation, the Block entity will be serialized and attached to this entity config attribute.

implementation terraform::providerManualConfig#

If self.manual_config is true, the user should provide the config as a dict directly to the entity. The root_config relation should then be set to null.

implementation terraform::resourceBlockConfig#

If self.manual_config is false, the user should provide the root_config relation, the Block entity will be serialized and attached to this entity config attribute.

implementation terraform::resourceManualConfig#

If self.manual_config is true, the user should provide the config as a dict directly to the entity. The root_config relation should then be set to null.

implementation terraform::config::build_state#

Extract the state matching this block from the parent state. This should only be called on non-root blocks. The root block should get the config from the resource parameter storing it.

implementation terraform::config::deprecation_warning#

Send a warning that the usage of this block is deprecated

implementation terraform::config::generate_key#

Automatically generate the key for blocks that don’t require it to be set. This key will be a hash of the block’s config and can then be used to order the block and generate a consistent config even with unordered sets of children blocks. (e.a. nesting_mode=set)

implementation terraform::config::serialize#

Serialize this block into a config dict.

Plugins#

terraform.deprecated_config_block(config_block: terraform::config::Block)#

Log a warning for the usage of a deprecated config block

terraform.dict_hash(input: dict) string#
terraform.extract_state(parent_state: dict, config: terraform::config::Block) dict#

Extract the state corresponding to the provided config block from the parent state. This method should only be used with a state originating from the safe_resource_state plugin.

Parameters:
  • state – The parent state dict, it should include our config at key config.name

  • config – The config block we want to find the matching config for.

terraform.get_resource_attribute(resource: terraform::Resource, attribute_path: any) any#

Get a resource attribute from the saved parameters (facts).

Disclaimer: Whatever comes out of this method might not be very safe to use,

as it might be out of sync with the current state of the model. i.e. If you access here the id of a file, which is modified in the same

model, the id you will receive will be the one of the previous file not the one deployed in this model.

It is safer to use safe_resource_state plugin.

Parameters:
  • resource – The resource we which to get an attribute from.

  • attribute_path – The path, in the resource state dict, to the desired value.

terraform.get_resource_attribute_ref(resource: terraform::Resource, attribute_path: any) dict#

Get a resource attribute reference. The difference with get_resource_attribute is that the value is not resolved at compile time but during the handler execution. This means that:

  1. The value can not be manipulated in the model.

  2. We save some time during the compile as we don’t need to make api calls.

  3. We avoid multiple recompile due to unknown values.

  4. If the targeted value changes, but none of the other attributes of this

    resource, we will need a full deploy to have our value up to date.

Parameters:
  • resource – The resource we which to get an attribute from.

  • attribute_path – The path, in the resource state dict, to the desired value.

terraform.safe_resource_state(resource: terraform::Resource) dict#

Get the state dict of a resource and check whether the current config of the resource has changed since the state was published. If this is the case, raise an Unknown value, as the state is out of sync and is dangerous to use.

terraform.serialize_config(config_block: terraform::config::Block) dict#

Serialize a config block into a dictionnary.

terraform.sorted_list(input_list: list) list#

Resources#

class terraform.terraform_resource.TerraformResource#

Handlers#

class terraform.terraform_resource.TerraformResourceHandler#