Categorygithub.com/hashicorp/terraform-json
modulepackage
0.24.0
Repository: https://github.com/hashicorp/terraform-json.git
Documentation: pkg.go.dev

# README

terraform-json

GoDoc

This repository houses data types designed to help parse the data produced by two Terraform commands:

While containing mostly data types, there are also a few helpers to assist with working with the data.

This repository also serves as de facto documentation for the formats produced by these commands. For more details, see the GoDoc.

Should I use this library?

This library was built for a few specific applications, and is not intended for general purpose use.

The Terraform core team recommends against using terraform-json if your application has any of the following requirements:

  • Forward-compatibility: each version of this library represents a specific snapshot of the Terraform JSON output format, and it often slightly lags behind Terraform itself. The library supports the 1.x compatibility promises but you will need to upgrade the version promptly to use new additions. If you require full compatibility with future Terraform versions, we recommend implementing your own custom decoders for the parts of the JSON format you need.
  • Writing JSON output: the structures in this library are not guaranteed to emit JSON data which is semantically equivalent to Terraform itself. If your application must robustly write JSON data to be consumed by systems which expect Terraform's format to be supported, you should implement your own custom encoders.
  • Filtering or round-tripping: the Terraform JSON formats are designed to be forwards compatible, and permit new attributes to be added which may safely be ignored by earlier versions of consumers. This library drops unknown attributes, which means it is unsuitable for any application which intends to filter data or read-modify-write data which will be consumed downstream. Any application doing this will silently drop new data from new versions. For this application, you should implement a custom decoder and encoder which preserves any unknown attributes through a round-trip.

When is terraform-json suitable? We recommend using it for applications which decode the core stable data types and use it directly, and don't attempt to emit JSON to be consumed by applications which expect the Terraform format.

Why a separate repository?

To reduce dependencies on any of Terraform core's internals, we've made a design decision to make any helpers or libraries that work with the external JSON data external and not a part of the Terraform GitHub repository itself.

While Terraform core will change often and be relatively unstable, this library will see a smaller amount of change. Most of the major changes have already happened leading up to 0.12, so you can expect this library to only see minor incremental changes going forward.

For this reason, terraform show -json and terraform providers schema -json is the recommended format for working with Terraform data externally, and as such, if you require any help working with the data in these formats, or even a reference of how the JSON is formatted, use this repository.

# Packages

No description provided by the author
No description provided by the author

# Constants

ActionCreate denotes a create operation.
ActionDelete denotes a delete operation.
ActionForget denotes a forget operation.
ActionNoop denotes a no-op operation.
ActionRead denotes a read operation.
ActionUpdate denotes an update operation.
CheckKindCheckBlock indicates the check result is from a check block.
CheckKindOutputValue indicates the check result is from an output post-condition.
CheckKindResource indicates the check result is from a pre- or post-condition on a resource or data source.
CheckStatusError indicates the check errored.
CheckStatusFail indicates the check failed.
CheckStatusPass indicates the check passed.
CheckStatusUnknown indicates the result of the check was not known.
DataResourceMode is the resource mode for data sources.
These severities map to the tfdiags.Severity values, plus an explicit unknown in case that enum grows without us noticing here.
These severities map to the tfdiags.Severity values, plus an explicit unknown in case that enum grows without us noticing here.
These severities map to the tfdiags.Severity values, plus an explicit unknown in case that enum grows without us noticing here.
ManagedResourceMode is the resource mode for managed resources.
SchemaDescriptionKindMarkdown indicates a Markdown string and may need to be processed prior to presentation.
SchemaDescriptionKindPlain indicates a string in plain text format.
SchemaNestingModeGroup is similar to SchemaNestingModeSingle in that it calls for only a single instance of a given block type with no labels, but it additonally guarantees that its result will never be null, even if the block is absent, and instead the nested attributes and blocks will be treated as absent in that case.
SchemaNestingModeList denotes list block nesting mode, which allows an ordered list of blocks where duplicates are allowed.
SchemaNestingModeMap denotes map block nesting mode.
SchemaNestingModeSet denotes set block nesting mode, which allows an unordered list of blocks where duplicates are generally not allowed.
SchemaNestingModeSingle denotes single block nesting mode, which allows a single block of this specific type only in configuration.

# Variables

MetadataFunctionsFormatVersionConstraints defines the versions of the JSON metadata functions format that are supported by this package.
PlanFormatVersionConstraints defines the versions of the JSON plan format that are supported by this package.
ProviderSchemasFormatVersionConstraints defines the versions of the JSON provider schema format that are supported by this package.
StateFormatVersionConstraints defines the versions of the JSON state format that are supported by this package.
UnknownConstantValue is a singleton type that denotes that a constant value is explicitly unknown.
ValidateFormatVersionConstraints defines the versions of the JSON validate format that are supported by this package.

# Structs

Change is the representation of a proposed change for an object.
CheckDynamicAddress contains the InstanceKey field for any resources that have multiple instances.
CheckResultDynamic describes the check result for a dynamic object that results from the expansion of the containing object.
CheckResultProblem describes one of potentially several problems that led to a check being classied as CheckStatusFail.
CheckResultStatic is the container for a "checkable object".
CheckStaticAddress details the address of the object that performed a given check.
Config represents the complete configuration source.
ConfigModule describes a module in Terraform configuration.
ConfigOutput defines an output as defined in configuration.
ConfigProvisioner describes a provisioner declared in a resource configuration.
ConfigResource is the configuration representation of a resource.
ConfigVariable defines a variable as defined in configuration.
DeferredResourceChange is a description of a resource change that has been deferred for some reason.
Diagnostic represents information to be presented to a user about an error or anomaly in parsing or evaluating configuration.
DiagnosticExpressionValue represents an HCL traversal string (e.g.
DiagnosticSnippet represents source code information about the diagnostic.
Expression describes the format for an individual key in a Terraform configuration.
ExpressionData describes the format for an individual key in a Terraform configuration.
FunctionParameter represents a parameter to a function.
FunctionSignature represents a function signature.
Importing is a nested object for the resource import metadata.
MetadataFunctions is the top-level object returned when exporting function signatures.
ModuleCall describes a declared "module" within a configuration.
Plan represents the entire contents of an output Terraform plan.
PlanVariable is a top-level variable in the Terraform plan.
Pos represents a position in a config file.
ProviderConfig describes a provider configuration instance.
ProviderSchema is the JSON representation of the schema of an entire provider, including the provider configuration and any resources and data sources included with the provider.
ProviderSchemas represents the schemas of all providers and resources in use by the configuration.
Range represents a range of bytes between two positions.
ResourceAttribute describes a full path to a resource attribute.
ResourceChange is a description of an individual change action that Terraform plans to use to move from the prior state to a new state matching the configuration.
Schema is the JSON representation of a particular schema (provider configuration, resources, data sources).
SchemaAttribute describes an attribute within a schema block.
SchemaBlock represents a nested block within a particular schema.
SchemaBlockType describes a nested block within a schema.
SchemaNestedAttributeType describes a nested attribute which could also be just expressed simply as cty.Object(...), cty.List(cty.Object(...)) etc.
State is the top-level representation of a Terraform state.
StateModule is the representation of a module in the common state representation.
StateOutput represents an output value in a common state representation.
StateResource is the representation of a resource in the common state representation.
StateValues is the common representation of resolved values for both the prior state (which is always complete) and the planned new state.
ValidateOutput represents JSON output from terraform validate (available from 0.12 onwards).
VersionOutput represents output from the version -json command added in v0.13.

# Type aliases

Action is a valid action type for a resource change.
Actions denotes a valid change type.
CheckKind is a string representation of the type of conditional check referenced in a check result.
CheckStatus is a string representation of the status of a given conditional check.
No description provided by the author
ResourceMode is a string representation of the resource type found in certain fields in the plan.
SchemaDescriptionKind describes the format type for a particular description's field.
SchemaNestingMode is the nesting mode for a particular nested schema block.