Movatterモバイル変換


[0]ホーム

URL:


tfjson

packagemodule
v0.25.0Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2025 License:MPL-2.0Imports:6Imported by:373

Details

Repository

github.com/hashicorp/terraform-json

Links

README

terraform-json

GoDoc

This repository houses data types designed to help parse the data produced bytwoTerraform commands:

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

This repository also serves as de facto documentation for the formats producedby these commands. For more details, see theGoDoc.

Should I use this library?

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

The Terraform core teamrecommends against usingterraform-json if yourapplication has any of the following requirements:

  • Forward-compatibility: each version of this library represents a specificsnapshot of theTerraform JSON output format,and it often slightly lags behind Terraform itself. The library supportsthe 1.x compatibility promisesbut you will need to upgrade the version promptly to use new additions. If yourequire full compatibility with future Terraform versions, we recommendimplementing 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 emitJSON data which is semantically equivalent to Terraform itself. If your applicationmust robustly write JSON data to be consumed by systems which expect Terraform'sformat to be supported, you should implement your own custom encoders.
  • Filtering or round-tripping: the Terraform JSON formats are designed to beforwards compatible, and permit new attributes to be added which may safely beignored by earlier versions of consumers. This librarydrops unknown attributes,which means it is unsuitable for any application which intends to filter dataor read-modify-write data which will be consumed downstream. Any application doingthis will silently drop new data from new versions. For this application, you shouldimplement a custom decoder and encoder which preserves any unknown attributesthrough a round-trip.

When isterraform-json suitable? We recommend using it for applications whichdecode the core stable data types and use it directly, and don't attempt to emitJSON 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 designdecision to make any helpers or libraries that work with the external JSON dataexternal and not a part of the Terraform GitHub repository itself.

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

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

Documentation

Overview

Package tfjson is a de-coupled helper library containing types forthe plan format output by "terraform show -json" command. Thiscommand is designed for the export of Terraform plan data ina format that can be easily processed by tools unrelated toTerraform.

This format is stable and should be used over the binary plan datawhenever possible.

Index

Constants

This section is empty.

Variables

View Source
var MetadataFunctionsFormatVersionConstraints = "~> 1.0"

MetadataFunctionsFormatVersionConstraints defines the versions of the JSONmetadata functions format that are supported by this package.

View Source
var PlanFormatVersionConstraints = ">= 0.1, < 2.0"

PlanFormatVersionConstraints defines the versions of the JSON plan formatthat are supported by this package.

View Source
var ProviderSchemasFormatVersionConstraints = ">= 0.1, < 2.0"

ProviderSchemasFormatVersionConstraints defines the versions of the JSONprovider schema format that are supported by this package.

View Source
var StateFormatVersionConstraints = ">= 0.1, < 2.0"

StateFormatVersionConstraints defines the versions of the JSON state formatthat are supported by this package.

View Source
var UnknownConstantValue = &unknownConstantValue{}

UnknownConstantValue is a singleton type that denotes that aconstant value is explicitly unknown. This is set during anunmarshal when references are found in an expression to help moreexplicitly differentiate between an explicit null and unknownvalue.

View Source
var ValidateFormatVersionConstraints = ">= 0.1, < 2.0"

ValidateFormatVersionConstraints defines the versions of the JSONvalidate format that are supported by this package.

Functions

This section is empty.

Types

typeAction

type Actionstring

Action is a valid action type for a resource change.

Note that a singular Action is not telling of a full resourcechange operation. Certain resource actions, such as replacement,are a composite of more than one type. See the Actions type andits helpers for more information.

const (// ActionNoop denotes a no-op operation.ActionNoopAction = "no-op"// ActionCreate denotes a create operation.ActionCreateAction = "create"// ActionRead denotes a read operation.ActionReadAction = "read"// ActionUpdate denotes an update operation.ActionUpdateAction = "update"// ActionDelete denotes a delete operation.ActionDeleteAction = "delete"// ActionForget denotes a forget operation.ActionForgetAction = "forget")

typeActions

type Actions []Action

Actions denotes a valid change type.

func (Actions)Create

func (aActions) Create()bool

Create is true if this set of Actions denotes creation of a newresource.

func (Actions)CreateBeforeDestroy

func (aActions) CreateBeforeDestroy()bool

CreateBeforeDestroy is true if this set of Actions denotes acreate-before-destroy operation, usually the result of replacementto a resource that has the create_before_destroy lifecycle optionset.

func (Actions)Delete

func (aActions) Delete()bool

Delete is true if this set of Actions denotes resource removal.

func (Actions)DestroyBeforeCreate

func (aActions) DestroyBeforeCreate()bool

DestroyBeforeCreate is true if this set of Actions denotes adestroy-before-create operation. This is the standard resourcereplacement method.

func (Actions)Forgetadded inv0.23.0

func (aActions) Forget()bool

Forget is true if this set of Actions denotes a forget operation.

func (Actions)NoOp

func (aActions) NoOp()bool

NoOp is true if this set of Actions denotes a no-op.

func (Actions)Read

func (aActions) Read()bool

Read is true if this set of Actions denotes a read operation only.

func (Actions)Replace

func (aActions) Replace()bool

Replace is true if this set of Actions denotes a valid replacementoperation.

func (Actions)Update

func (aActions) Update()bool

Update is true if this set of Actions denotes an update operation.

typeChange

type Change struct {// The action to be carried out by this change.ActionsActions `json:"actions,omitempty"`// Before and After are representations of the object value both// before and after the action. For create and delete actions,// either Before or After is unset (respectively). For no-op// actions, both values will be identical. After will be incomplete// if there are values within it that won't be known until after// apply.Before interface{} `json:"before,"`After  interface{} `json:"after,omitempty"`// A deep object of booleans that denotes any values that are// unknown in a resource. These values were previously referred to// as "computed" values.//// If the value cannot be found in this map, then its value should// be available within After, so long as the operation supports it.AfterUnknown interface{} `json:"after_unknown,omitempty"`// BeforeSensitive and AfterSensitive are object values with similar// structure to Before and After, but with all sensitive leaf values// replaced with true, and all non-sensitive leaf values omitted. These// objects should be combined with Before and After to prevent accidental// display of sensitive values in user interfaces.BeforeSensitive interface{} `json:"before_sensitive,omitempty"`AfterSensitive  interface{} `json:"after_sensitive,omitempty"`// Importing contains the import metadata about this operation. If importing// is present (ie. not null) then the change is an import operation in// addition to anything mentioned in the actions field. The actual contents// of the Importing struct is subject to change, so downstream consumers// should treat any values in here as strictly optional.Importing *Importing `json:"importing,omitempty"`// GeneratedConfig contains any HCL config generated for this resource// during planning as a string.//// If this is populated, then Importing should also be populated but this// might change in the future. However, not all Importing changes will// contain generated config.GeneratedConfigstring `json:"generated_config,omitempty"`// ReplacePaths contains a set of paths that point to attributes/elements// that are causing the overall resource to be replaced rather than simply// updated.//// This field is always a slice of indexes, where an index in this context// is either an integer pointing to a child of a set/list, or a string// pointing to the child of a map, object, or block.ReplacePaths []interface{} `json:"replace_paths,omitempty"`// BeforeIdentity and AfterIdentity are representations of the resource// identity value both before and after the action.BeforeIdentity interface{} `json:"before_identity,omitempty"`AfterIdentity  interface{} `json:"after_identity,omitempty"`}

Change is the representation of a proposed change for an object.

typeCheckDynamicAddressadded inv0.17.0

type CheckDynamicAddress struct {// ToDisplay is a formatted and ready to display representation of the// full address, including the additional information from the relevant// CheckStaticAddress.ToDisplaystring `json:"to_display"`// Module is the module part of the address. This address will include the// instance key for any module expansions resulting from foreach or count// arguments. This field will be empty for any resources within the root// module.Modulestring `json:"module,omitempty"`// InstanceKey is the instance key for any instances of a given resource.//// InstanceKey will be empty if there was no foreach or count argument// defined on the containing object.InstanceKey interface{} `json:"instance_key,omitempty"`}

CheckDynamicAddress contains the InstanceKey field for any resources thathave multiple instances. A complete address can be built by combining theCheckStaticAddress with the CheckDynamicAddress.

typeCheckKindadded inv0.17.0

type CheckKindstring

CheckKind is a string representation of the type of conditional checkreferenced in a check result.

const (// CheckKindResource indicates the check result is from a pre- or// post-condition on a resource or data source.CheckKindResourceCheckKind = "resource"// CheckKindOutputValue indicates the check result is from an output// post-condition.CheckKindOutputValueCheckKind = "output_value"// CheckKindCheckBlock indicates the check result is from a check block.CheckKindCheckBlockCheckKind = "check")

typeCheckResultDynamicadded inv0.17.0

type CheckResultDynamic struct {// Address is the relative address of this instance given the Address in the// parent object.AddressCheckDynamicAddress `json:"address"`// Status is the overall status for the checks within this dynamic object.StatusCheckStatus `json:"status"`// Problems describes any additional optional details about this check if// the check failed.//// This will not include the errors resulting from this check block, as they// will be exposed as diagnostics in the original terraform execution. It// may contain any failure messages even if the overall status is// CheckStatusError, however, as the instance could contain multiple checks// that returned a mix of error and failure statuses.Problems []CheckResultProblem `json:"problems,omitempty"`}

CheckResultDynamic describes the check result for a dynamic object thatresults from the expansion of the containing object.

typeCheckResultProblemadded inv0.17.0

type CheckResultProblem struct {// Message is the condition error message provided by the original check// author.Messagestring `json:"message"`}

CheckResultProblem describes one of potentially several problems that led toa check being classied as CheckStatusFail.

typeCheckResultStaticadded inv0.17.0

type CheckResultStatic struct {// Address is the absolute address of the "checkable object"AddressCheckStaticAddress `json:"address"`// Status is the overall status for all the checks within this object.StatusCheckStatus `json:"status"`// Instances contains the results for dynamic object that belongs to this// static object. For example, any instances created from an object using// the foreach or count meta arguments.//// Check blocks and outputs will only contain a single instance, while// resources can contain 1 to many.Instances []CheckResultDynamic `json:"instances,omitempty"`}

CheckResultStatic is the container for a "checkable object".

A "checkable object" is a resource or data source, an output, or a checkblock.

typeCheckStaticAddressadded inv0.17.0

type CheckStaticAddress struct {// ToDisplay is a formatted and ready to display representation of the// address.ToDisplaystring `json:"to_display"`// Kind represents the CheckKind of this check.KindCheckKind `json:"kind"`// Module is the module part of the address. This will be empty for any// resources in the root module.Modulestring `json:"module,omitempty"`// Mode is the ResourceMode of the resource that contains this check. This// field is only set is Kind equals CheckKindResource.ModeResourceMode `json:"mode,omitempty"`// Type is the resource type for the resource that contains this check. This// field is only set if Kind equals CheckKindResource.Typestring `json:"type,omitempty"`// Name is the name of the resource, check block, or output that contains// this check.Namestring `json:"name,omitempty"`}

CheckStaticAddress details the address of the object that performed a givencheck. The static address points to the overall resource, as opposed to thedynamic address which contains the instance key for any resource that hasmultiple instances.

typeCheckStatusadded inv0.17.0

type CheckStatusstring

CheckStatus is a string representation of the status of a given conditionalcheck.

const (// CheckStatusPass indicates the check passed.CheckStatusPassCheckStatus = "pass"// CheckStatusFail indicates the check failed.CheckStatusFailCheckStatus = "fail"// CheckStatusError indicates the check errored. This is distinct from// CheckStatusFail in that it represents a logical or configuration error// within the check block that prevented the check from executing, as// opposed to the check was attempted and evaluated to false.CheckStatusErrorCheckStatus = "error"// CheckStatusUnknown indicates the result of the check was not known. This// could be because a value within the check could not be known at plan// time, or because the overall plan failed for an unrelated reason before// this check could be executed.CheckStatusUnknownCheckStatus = "unknown")

typeConfig

type Config struct {// A map of all provider instances across all modules in the// configuration.//// The index for this field is opaque and should not be parsed. Use// the individual fields in ProviderConfig to discern actual data// about the provider such as name, alias, or defined module.ProviderConfigs map[string]*ProviderConfig `json:"provider_config,omitempty"`// The root module in the configuration. Any child modules descend// off of here.RootModule *ConfigModule `json:"root_module,omitempty"`}

Config represents the complete configuration source.

func (*Config)UnmarshalJSONadded inv0.4.0

func (c *Config) UnmarshalJSON(b []byte)error

func (*Config)Validate

func (c *Config) Validate()error

Validate checks to ensure that the config is present.

typeConfigModule

type ConfigModule struct {// The outputs defined in the module.Outputs map[string]*ConfigOutput `json:"outputs,omitempty"`// The resources defined in the module.Resources []*ConfigResource `json:"resources,omitempty"`// Any "module" stanzas within the specific module.ModuleCalls map[string]*ModuleCall `json:"module_calls,omitempty"`// The variables defined in the module.Variables map[string]*ConfigVariable `json:"variables,omitempty"`}

ConfigModule describes a module in Terraform configuration.

typeConfigOutput

type ConfigOutput struct {// Indicates whether or not the output was marked as sensitive.Sensitivebool `json:"sensitive,omitempty"`// The defined value of the output.Expression *Expression `json:"expression,omitempty"`// The defined description of this output.Descriptionstring `json:"description,omitempty"`// The defined dependencies tied to this output.DependsOn []string `json:"depends_on,omitempty"`}

ConfigOutput defines an output as defined in configuration.

typeConfigProvisioner

type ConfigProvisioner struct {// The type of the provisioner, ie: "local-exec".Typestring `json:"type,omitempty"`// Any non-special configuration values in the provisioner, indexed by// key.Expressions map[string]*Expression `json:"expressions,omitempty"`}

ConfigProvisioner describes a provisioner declared in a resourceconfiguration.

typeConfigResource

type ConfigResource struct {// The address of the resource relative to the module that it is// in.Addressstring `json:"address,omitempty"`// The resource mode.ModeResourceMode `json:"mode,omitempty"`// The type of resource, ie: "null_resource" in// "null_resource.foo".Typestring `json:"type,omitempty"`// The name of the resource, ie: "foo" in "null_resource.foo".Namestring `json:"name,omitempty"`// An opaque key representing the provider configuration this// module uses. Note that there are more than one circumstance that// this key will not match what is found in the ProviderConfigs// field in the root Config structure, and as such should not be// relied on for that purpose.ProviderConfigKeystring `json:"provider_config_key,omitempty"`// The list of provisioner defined for this configuration. This// will be nil if no providers are defined.Provisioners []*ConfigProvisioner `json:"provisioners,omitempty"`// Any non-special configuration values in the resource, indexed by// key.Expressions map[string]*Expression `json:"expressions,omitempty"`// The resource's configuration schema version. With access to the// specific Terraform provider for this resource, this can be used// to determine the correct schema for the configuration data// supplied in Expressions.SchemaVersionuint64 `json:"schema_version"`// The expression data for the "count" value in the resource.CountExpression *Expression `json:"count_expression,omitempty"`// The expression data for the "for_each" value in the resource.ForEachExpression *Expression `json:"for_each_expression,omitempty"`// The contents of the "depends_on" config directive, which// declares explicit dependencies for this resource.DependsOn []string `json:"depends_on,omitempty"`}

ConfigResource is the configuration representation of a resource.

typeConfigVariable

type ConfigVariable struct {// The defined default value of the variable.Default interface{} `json:"default,omitempty"`// The defined text description of the variable.Descriptionstring `json:"description,omitempty"`// Whether the variable is marked as sensitiveSensitivebool `json:"sensitive,omitempty"`}

ConfigVariable defines a variable as defined in configuration.

typeDeferredResourceChangeadded inv0.22.0

type DeferredResourceChange struct {// Reason is the reason why this resource change was deferred.Reasonstring `json:"reason,omitempty"`// Change contains any information we have about the deferred change.ResourceChange *ResourceChange `json:"resource_change,omitempty"`}

DeferredResourceChange is a description of a resource change that has beendeferred for some reason.

typeDiagnosticadded inv0.7.0

type Diagnostic struct {SeverityDiagnosticSeverity `json:"severity,omitempty"`Summarystring `json:"summary,omitempty"`Detailstring `json:"detail,omitempty"`Range   *Range `json:"range,omitempty"`Snippet *DiagnosticSnippet `json:"snippet,omitempty"`}

Diagnostic represents information to be presented to a user about anerror or anomaly in parsing or evaluating configuration

typeDiagnosticExpressionValueadded inv0.9.0

type DiagnosticExpressionValue struct {Traversalstring `json:"traversal"`Statementstring `json:"statement"`}

DiagnosticExpressionValue represents an HCL traversal string (e.g."var.foo") and a statement about its value while the expression wasevaluated (e.g. "is a string", "will be known only after apply"). These areintended to help the consumer diagnose why an expression caused a diagnosticto be emitted.

typeDiagnosticSeverityadded inv0.9.0

type DiagnosticSeveritystring
const (DiagnosticSeverityUnknownDiagnosticSeverity = "unknown"DiagnosticSeverityErrorDiagnosticSeverity = "error"DiagnosticSeverityWarningDiagnosticSeverity = "warning")

These severities map to the tfdiags.Severity values, plus an explicitunknown in case that enum grows without us noticing here.

typeDiagnosticSnippetadded inv0.9.0

type DiagnosticSnippet struct {// Context is derived from HCL's hcled.ContextString output. This gives a// high-level summary of the root context of the diagnostic: for example,// the resource block in which an expression causes an error.Context *string `json:"context"`// Code is a possibly-multi-line string of Terraform configuration, which// includes both the diagnostic source and any relevant context as defined// by the diagnostic.Codestring `json:"code"`// StartLine is the line number in the source file for the first line of// the snippet code block. This is not necessarily the same as the value of// Range.Start.Line, as it is possible to have zero or more lines of// context source code before the diagnostic range starts.StartLineint `json:"start_line"`// HighlightStartOffset is the character offset into Code at which the// diagnostic source range starts, which ought to be highlighted as such by// the consumer of this data.HighlightStartOffsetint `json:"highlight_start_offset"`// HighlightEndOffset is the character offset into Code at which the// diagnostic source range ends.HighlightEndOffsetint `json:"highlight_end_offset"`// Values is a sorted slice of expression values which may be useful in// understanding the source of an error in a complex expression.Values []DiagnosticExpressionValue `json:"values"`}

DiagnosticSnippet represents source code information about the diagnostic.It is possible for a diagnostic to have a source (and therefore a range) butno source code can be found. In this case, the range field will be present andthe snippet field will not.

typeExpression

type Expression struct {*ExpressionData}

Expression describes the format for an individual key in aTerraform configuration.

This struct wraps ExpressionData to support custom JSON parsing.

func (*Expression)MarshalJSON

func (e *Expression) MarshalJSON() ([]byte,error)

MarshalJSON implements json.Marshaler for Expression.

func (*Expression)UnmarshalJSON

func (e *Expression) UnmarshalJSON(b []byte)error

UnmarshalJSON implements json.Unmarshaler for Expression.

typeExpressionData

type ExpressionData struct {// If the *entire* expression is a constant-defined value, this// will contain the Go representation of the expression's data.//// Note that a nil here denotes and explicit null. When a value is// unknown on part of the value coming from an expression that// cannot be resolved at parse time, this field will contain// UnknownConstantValue.ConstantValue interface{} `json:"constant_value,omitempty"`// If any part of the expression contained values that were not// able to be resolved at parse-time, this will contain a list of// the referenced identifiers that caused the value to be unknown.References []string `json:"references,omitempty"`// A list of complex objects that were nested in this expression.// If this value is a nested block in configuration, sometimes// referred to as a "sub-resource", this field will contain those// values, and ConstantValue and References will be blank.NestedBlocks []map[string]*Expression `json:"-"`}

ExpressionData describes the format for an individual key in aTerraform configuration.

typeFunctionParameteradded inv0.15.0

type FunctionParameter struct {// Name is an optional name for the argument.Namestring `json:"name,omitempty"`// Description is an optional human-readable description// of the argumentDescriptionstring `json:"description,omitempty"`// IsNullable is true if null is acceptable value for the argumentIsNullablebool `json:"is_nullable,omitempty"`// A type that any argument for this parameter must conform to.Typecty.Type `json:"type"`}

FunctionParameter represents a parameter to a function.

typeFunctionSignatureadded inv0.15.0

type FunctionSignature struct {// Description is an optional human-readable description// of the functionDescriptionstring `json:"description,omitempty"`// Summary is an optional shortened description of the functionSummarystring `json:"summary,omitempty"`// DeprecationMessage is an optional message that indicates that the// function should be considered deprecated and what actions should be// performed by the practitioner to handle the deprecation.DeprecationMessagestring `json:"deprecation_message,omitempty"`// ReturnType is the ctyjson representation of the function's// return types based on supplying all parameters using// dynamic types. Functions can have dynamic return types.ReturnTypecty.Type `json:"return_type"`// Parameters describes the function's fixed positional parameters.Parameters []*FunctionParameter `json:"parameters,omitempty"`// VariadicParameter describes the function's variadic// parameter if it is supported.VariadicParameter *FunctionParameter `json:"variadic_parameter,omitempty"`}

FunctionSignature represents a function signature.

typeIdentityAttributeadded inv0.25.0

type IdentityAttribute struct {// The identity attribute typeIdentityTypecty.Type `json:"type,omitempty"`// The description of the identity attributeDescriptionstring `json:"description,omitempty"`// RequiredForImport when enabled signifies that this attribute must be// specified in the configuration during importRequiredForImportbool `json:"required_for_import,omitempty"`// OptionalForImport when enabled signifies that this attribute is not// required to be specified during import, because it can be supplied by the// providerOptionalForImportbool `json:"optional_for_import,omitempty"`}

IdentityAttribute describes an identity attribute

typeIdentitySchemaadded inv0.25.0

type IdentitySchema struct {// The version of the particular resource identity schema.Versionuint64 `json:"version"`// Map of identity attributesAttributes map[string]*IdentityAttribute `json:"attributes,omitempty"`}

IdentitySchema is the JSON representation of a particularresource identity schema

typeImportingadded inv0.17.0

type Importing struct {// The original ID of this resource used to target it as part of planned// import operation.IDstring `json:"id,omitempty"`// Unknown indicates the ID or identity was unknown at the time of// planning. This would have led to the overall change being deferred, as// such this should only be true when processing changes from the deferred// changes list.Unknownbool `json:"unknown,omitempty"`// The identity can be used instead of the ID to target the resource as part// of the planned import operation.Identity interface{} `json:"identity,omitempty"`}

Importing is a nested object for the resource import metadata.

typeMetadataFunctionsadded inv0.15.0

type MetadataFunctions struct {// The version of the format. This should always match the// MetadataFunctionsFormatVersionConstraints in this package, else// unmarshaling will fail.FormatVersionstring `json:"format_version"`// The signatures of the functions available in a Terraform version.Signatures map[string]*FunctionSignature `json:"function_signatures,omitempty"`}

MetadataFunctions is the top-level object returned when exporting functionsignatures

func (*MetadataFunctions)UnmarshalJSONadded inv0.15.0

func (f *MetadataFunctions) UnmarshalJSON(b []byte)error

func (*MetadataFunctions)Validateadded inv0.15.0

func (f *MetadataFunctions) Validate()error

Validate checks to ensure that MetadataFunctions is present, and theversion matches the version supported by this library.

typeModuleCall

type ModuleCall struct {// The contents of the "source" field.Sourcestring `json:"source,omitempty"`// Any non-special configuration values in the module, indexed by// key.Expressions map[string]*Expression `json:"expressions,omitempty"`// The expression data for the "count" value in the module.CountExpression *Expression `json:"count_expression,omitempty"`// The expression data for the "for_each" value in the module.ForEachExpression *Expression `json:"for_each_expression,omitempty"`// The configuration data for the module itself.Module *ConfigModule `json:"module,omitempty"`// The version constraint for modules that come from the registry.VersionConstraintstring `json:"version_constraint,omitempty"`// The explicit resource dependencies for the "depends_on" value.// As it must be a slice of references, Expression is not used.DependsOn []string `json:"depends_on,omitempty"`}

ModuleCall describes a declared "module" within a configuration.It also contains the data for the module itself.

typePlan

type Plan struct {// The version of the plan format. This should always match the// PlanFormatVersion constant in this package, or else an unmarshal// will be unstable.FormatVersionstring `json:"format_version,omitempty"`// The version of Terraform used to make the plan.TerraformVersionstring `json:"terraform_version,omitempty"`// The variables set in the root module when creating the plan.Variables map[string]*PlanVariable `json:"variables,omitempty"`// The common state representation of resources within this plan.// This is a product of the existing state merged with the diff for// this plan.PlannedValues *StateValues `json:"planned_values,omitempty"`// The change operations for resources and data sources within this plan// resulting from resource drift.ResourceDrift []*ResourceChange `json:"resource_drift,omitempty"`// The change operations for resources and data sources within this// plan.ResourceChanges []*ResourceChange `json:"resource_changes,omitempty"`// DeferredChanges contains the change operations for resources that are deferred// for this plan.DeferredChanges []*DeferredResourceChange `json:"deferred_changes,omitempty"`// Complete indicates that all resources have successfully planned changes.// This will be false if there are DeferredChanges or if the -target flag is used.//// Complete was introduced in Terraform 1.8 and will be nil for all previous// Terraform versions.Complete *bool `json:"complete,omitempty"`// The change operations for outputs within this plan.OutputChanges map[string]*Change `json:"output_changes,omitempty"`// The Terraform state prior to the plan operation. This is the// same format as PlannedValues, without the current diff merged.PriorState *State `json:"prior_state,omitempty"`// The Terraform configuration used to make the plan.Config *Config `json:"configuration,omitempty"`// RelevantAttributes represents any resource instances and their// attributes which may have contributed to the planned changesRelevantAttributes []ResourceAttribute `json:"relevant_attributes,omitempty"`// Checks contains the results of any conditional checks executed, or// planned to be executed, during this plan.Checks []CheckResultStatic `json:"checks,omitempty"`// Timestamp contains the static timestamp that Terraform considers to be// the time this plan executed, in UTC.Timestampstring `json:"timestamp,omitempty"`// contains filtered or unexported fields}

Plan represents the entire contents of an output Terraform plan.

func (*Plan)UnmarshalJSONadded inv0.4.0

func (p *Plan) UnmarshalJSON(b []byte)error

func (*Plan)UseJSONNumberadded inv0.19.0

func (p *Plan) UseJSONNumber(bbool)

UseJSONNumber controls whether the Plan will be decoded using thejson.Number behavior or the float64 behavior. When b is true, the Plan willrepresent numbers in PlanOutputs as json.Numbers. When b is false, thePlan will represent numbers in PlanOutputs as float64s.

func (*Plan)Validate

func (p *Plan) Validate()error

Validate checks to ensure that the plan is present, and theversion matches the version supported by this library.

typePlanVariable

type PlanVariable struct {// The value for this variable at plan time.Value interface{} `json:"value,omitempty"`}

PlanVariable is a top-level variable in the Terraform plan.

typePosadded inv0.7.0

type Pos struct {Lineint `json:"line"`Columnint `json:"column"`Byteint `json:"byte"`}

Pos represents a position in a config file

typeProviderConfig

type ProviderConfig struct {// The name of the provider, ie: "aws".Namestring `json:"name,omitempty"`// The fully-specified name of the provider, ie: "registry.terraform.io/hashicorp/aws".FullNamestring `json:"full_name,omitempty"`// The alias of the provider, ie: "us-east-1".Aliasstring `json:"alias,omitempty"`// The address of the module the provider is declared in.ModuleAddressstring `json:"module_address,omitempty"`// Any non-special configuration values in the provider, indexed by// key.Expressions map[string]*Expression `json:"expressions,omitempty"`// The defined version constraint for this provider.VersionConstraintstring `json:"version_constraint,omitempty"`}

ProviderConfig describes a provider configuration instance.

typeProviderSchema

type ProviderSchema struct {// The schema for the provider's configuration.ConfigSchema *Schema `json:"provider,omitempty"`// The schemas for any resources in this provider.ResourceSchemas map[string]*Schema `json:"resource_schemas,omitempty"`// The schemas for any data sources in this provider.DataSourceSchemas map[string]*Schema `json:"data_source_schemas,omitempty"`// The schemas for any ephemeral resources in this provider.EphemeralResourceSchemas map[string]*Schema `json:"ephemeral_resource_schemas,omitempty"`// The definitions for any functions in this provider.Functions map[string]*FunctionSignature `json:"functions,omitempty"`// The schemas for resources identities in this provider.ResourceIdentitySchemas map[string]*IdentitySchema `json:"resource_identity_schemas,omitempty"`}

ProviderSchema is the JSON representation of the schema of anentire provider, including the provider configuration and anyresources and data sources included with the provider.

typeProviderSchemas

type ProviderSchemas struct {// The version of the plan format. This should always match one of// ProviderSchemasFormatVersions in this package, or else// an unmarshal will be unstable.FormatVersionstring `json:"format_version,omitempty"`// The schemas for the providers in this configuration, indexed by// provider type. Aliases are not included, and multiple instances// of a provider in configuration will be represented by a single// provider here.Schemas map[string]*ProviderSchema `json:"provider_schemas,omitempty"`}

ProviderSchemas represents the schemas of all providers andresources in use by the configuration.

func (*ProviderSchemas)UnmarshalJSONadded inv0.4.0

func (p *ProviderSchemas) UnmarshalJSON(b []byte)error

func (*ProviderSchemas)Validate

func (p *ProviderSchemas) Validate()error

Validate checks to ensure that ProviderSchemas is present, and theversion matches the version supported by this library.

typeRangeadded inv0.7.0

type Range struct {Filenamestring `json:"filename"`StartPos    `json:"start"`EndPos    `json:"end"`}

Range represents a range of bytes between two positions

typeResourceAttributeadded inv0.14.0

type ResourceAttribute struct {// Resource describes resource instance address (e.g. null_resource.foo)Resourcestring `json:"resource"`// Attribute describes the attribute path using a lossy representation// of cty.Path. (e.g. ["id"] or ["objects", 0, "val"]).Attribute []json.RawMessage `json:"attribute"`}

ResourceAttribute describes a full path to a resource attribute

typeResourceChange

type ResourceChange struct {// The absolute resource address.Addressstring `json:"address,omitempty"`// The absolute address that this resource instance had// at the conclusion of a previous plan.PreviousAddressstring `json:"previous_address,omitempty"`// The module portion of the above address. Omitted if the instance// is in the root module.ModuleAddressstring `json:"module_address,omitempty"`// The resource mode.ModeResourceMode `json:"mode,omitempty"`// The resource type, example: "aws_instance" for aws_instance.foo.Typestring `json:"type,omitempty"`// The resource name, example: "foo" for aws_instance.foo.Namestring `json:"name,omitempty"`// The instance key for any resources that have been created using// "count" or "for_each". If neither of these apply the key will be// empty.//// This value can be either an integer (int) or a string.Index interface{} `json:"index,omitempty"`// The name of the provider this resource belongs to. This allows// the provider to be interpreted unambiguously in the unusual// situation where a provider offers a resource type whose name// does not start with its own name, such as the "googlebeta"// provider offering "google_compute_instance".ProviderNamestring `json:"provider_name,omitempty"`// An identifier used during replacement operations, and can be// used to identify the exact resource being replaced in state.DeposedKeystring `json:"deposed,omitempty"`// The data describing the change that will be made to this object.Change *Change `json:"change,omitempty"`}

ResourceChange is a description of an individual change actionthat Terraform plans to use to move from the prior state to a newstate matching the configuration.

typeResourceMode

type ResourceModestring

ResourceMode is a string representation of the resource type foundin certain fields in the plan.

const (// DataResourceMode is the resource mode for data sources.DataResourceModeResourceMode = "data"// ManagedResourceMode is the resource mode for managed resources.ManagedResourceModeResourceMode = "managed")

typeSchema

type Schema struct {// The version of the particular resource schema.Versionuint64 `json:"version"`// The root-level block of configuration values.Block *SchemaBlock `json:"block,omitempty"`}

Schema is the JSON representation of a particular schema(provider configuration, resources, data sources).

typeSchemaAttribute

type SchemaAttribute struct {// The attribute type// Either AttributeType or AttributeNestedType is set, never both.AttributeTypecty.Type `json:"type,omitempty"`// Details about a nested attribute type// Either AttributeType or AttributeNestedType is set, never both.AttributeNestedType *SchemaNestedAttributeType `json:"nested_type,omitempty"`// The description field for this attribute. If no kind is// provided, it can be assumed to be plain text.Descriptionstring                `json:"description,omitempty"`DescriptionKindSchemaDescriptionKind `json:"description_kind,omitempty"`// If true, this attribute is deprecated.Deprecatedbool `json:"deprecated,omitempty"`// If true, this attribute is required - it has to be entered in// configuration.Requiredbool `json:"required,omitempty"`// If true, this attribute is optional - it does not need to be// entered in configuration.Optionalbool `json:"optional,omitempty"`// If true, this attribute is computed - it can be set by the// provider. It may also be set by configuration if Optional is// true.Computedbool `json:"computed,omitempty"`// If true, this attribute is sensitive and will not be displayed// in logs. Future versions of Terraform may encrypt or otherwise// treat these values with greater care than non-sensitive fields.Sensitivebool `json:"sensitive,omitempty"`// If true, this attribute is write only and its value will not be// persisted in artifacts such as plan files or state.WriteOnlybool `json:"write_only,omitempty"`}

SchemaAttribute describes an attribute within a schema block.

func (*SchemaAttribute)MarshalJSONadded inv0.13.0

func (as *SchemaAttribute) MarshalJSON() ([]byte,error)

typeSchemaBlock

type SchemaBlock struct {// The attributes defined at the particular level of this block.Attributes map[string]*SchemaAttribute `json:"attributes,omitempty"`// Any nested blocks within this particular block.NestedBlocks map[string]*SchemaBlockType `json:"block_types,omitempty"`// The description for this block and format of the description. If// no kind is provided, it can be assumed to be plain text.Descriptionstring                `json:"description,omitempty"`DescriptionKindSchemaDescriptionKind `json:"description_kind,omitempty"`// If true, this block is deprecated.Deprecatedbool `json:"deprecated,omitempty"`}

SchemaBlock represents a nested block within a particular schema.

typeSchemaBlockType

type SchemaBlockType struct {// The nesting mode for this block.NestingModeSchemaNestingMode `json:"nesting_mode,omitempty"`// The block data for this block type, including attributes and// subsequent nested blocks.Block *SchemaBlock `json:"block,omitempty"`// The lower limit on items that can be declared of this block// type.MinItemsuint64 `json:"min_items,omitempty"`// The upper limit on items that can be declared of this block// type.MaxItemsuint64 `json:"max_items,omitempty"`}

SchemaBlockType describes a nested block within a schema.

typeSchemaDescriptionKindadded inv0.5.0

type SchemaDescriptionKindstring

SchemaDescriptionKind describes the format type for a particular description's field.

const (// SchemaDescriptionKindPlain indicates a string in plain text format.SchemaDescriptionKindPlainSchemaDescriptionKind = "plain"// SchemaDescriptionKindMarkdown indicates a Markdown string and may need to be// processed prior to presentation.SchemaDescriptionKindMarkdownSchemaDescriptionKind = "markdown")

typeSchemaNestedAttributeTypeadded inv0.9.0

type SchemaNestedAttributeType struct {// A map of nested attributesAttributes map[string]*SchemaAttribute `json:"attributes,omitempty"`// The nesting mode for this attribute.NestingModeSchemaNestingMode `json:"nesting_mode,omitempty"`// The lower limit on number of items that can be declared// of this attribute type (not applicable to single nesting mode).MinItemsuint64 `json:"min_items,omitempty"`// The upper limit on number of items that can be declared// of this attribute type (not applicable to single nesting mode).MaxItemsuint64 `json:"max_items,omitempty"`}

SchemaNestedAttributeType describes a nested attributewhich could also be just expressed simply as cty.Object(...),cty.List(cty.Object(...)) etc. but this allows tracking additionalmetadata which can help interpreting or validating the data.

typeSchemaNestingMode

type SchemaNestingModestring

SchemaNestingMode is the nesting mode for a particular nestedschema block.

const (// SchemaNestingModeSingle denotes single block nesting mode, which// allows a single block of this specific type only in// configuration. This is generally the same as list or set types// with a single-element constraint.SchemaNestingModeSingleSchemaNestingMode = "single"// 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.//// This is useful for the situation where a remote API has a feature that// is always enabled but has a group of settings related to that feature// that themselves have default values. By using SchemaNestingModeGroup// instead of SchemaNestingModeSingle in that case, generated plans will// show the block as present even when not present in configuration,// thus allowing any default values within to be displayed to the user.SchemaNestingModeGroupSchemaNestingMode = "group"// SchemaNestingModeList denotes list block nesting mode, which// allows an ordered list of blocks where duplicates are allowed.SchemaNestingModeListSchemaNestingMode = "list"// SchemaNestingModeSet denotes set block nesting mode, which// allows an unordered list of blocks where duplicates are// generally not allowed. What is considered a duplicate is up to// the rules of the set itself, which may or may not cover all// fields in the block.SchemaNestingModeSetSchemaNestingMode = "set"// SchemaNestingModeMap denotes map block nesting mode. This// creates a map of all declared blocks of the block type within// the parent, keying them on the label supplied in the block// declaration. This allows for blocks to be declared in the same// style as resources.SchemaNestingModeMapSchemaNestingMode = "map")

typeState

type State struct {// The version of the state format. This should always match the// StateFormatVersion constant in this package, or else am// unmarshal will be unstable.FormatVersionstring `json:"format_version,omitempty"`// The Terraform version used to make the state.TerraformVersionstring `json:"terraform_version,omitempty"`// The values that make up the state.Values *StateValues `json:"values,omitempty"`// Checks contains the results of any conditional checks when Values was// last updated.Checks []CheckResultStatic `json:"checks,omitempty"`// contains filtered or unexported fields}

State is the top-level representation of a Terraform state.

func (*State)UnmarshalJSONadded inv0.4.0

func (s *State) UnmarshalJSON(b []byte)error

func (*State)UseJSONNumberadded inv0.8.0

func (s *State) UseJSONNumber(bbool)

UseJSONNumber controls whether the State will be decoded using thejson.Number behavior or the float64 behavior. When b is true, the State willrepresent numbers in StateOutputs as json.Numbers. When b is false, theState will represent numbers in StateOutputs as float64s.

func (*State)Validate

func (s *State) Validate()error

Validate checks to ensure that the state is present, and theversion matches the version supported by this library.

typeStateModule

type StateModule struct {// All resources or data sources within this module.Resources []*StateResource `json:"resources,omitempty"`// The absolute module address, omitted for the root module.Addressstring `json:"address,omitempty"`// Any child modules within this module.ChildModules []*StateModule `json:"child_modules,omitempty"`}

StateModule is the representation of a module in the common staterepresentation. This can be the root module or a child module.

typeStateOutput

type StateOutput struct {// Whether or not the output was marked as sensitive.Sensitivebool `json:"sensitive"`// The value of the output.Value interface{} `json:"value,omitempty"`// The type of the output.Typecty.Type `json:"type,omitempty"`}

StateOutput represents an output value in a common staterepresentation.

func (*StateOutput)MarshalJSONadded inv0.14.0

func (so *StateOutput) MarshalJSON() ([]byte,error)

typeStateResource

type StateResource struct {// The absolute resource address.Addressstring `json:"address,omitempty"`// The resource mode.ModeResourceMode `json:"mode,omitempty"`// The resource type, example: "aws_instance" for aws_instance.foo.Typestring `json:"type,omitempty"`// The resource name, example: "foo" for aws_instance.foo.Namestring `json:"name,omitempty"`// The instance key for any resources that have been created using// "count" or "for_each". If neither of these apply the key will be// empty.//// This value can be either an integer (int) or a string.Index interface{} `json:"index,omitempty"`// The name of the provider this resource belongs to. This allows// the provider to be interpreted unambiguously in the unusual// situation where a provider offers a resource type whose name// does not start with its own name, such as the "googlebeta"// provider offering "google_compute_instance".ProviderNamestring `json:"provider_name,omitempty"`// The version of the resource type schema the "values" property// conforms to.SchemaVersionuint64 `json:"schema_version,"`// The JSON representation of the attribute values of the resource,// whose structure depends on the resource type schema. Any unknown// values are omitted or set to null, making them indistinguishable// from absent values.AttributeValues map[string]interface{} `json:"values,omitempty"`// The JSON representation of the sensitivity of the resource's// attribute values. Only attributes which are sensitive// are included in this structure.SensitiveValuesjson.RawMessage `json:"sensitive_values,omitempty"`// The addresses of the resources that this resource depends on.DependsOn []string `json:"depends_on,omitempty"`// If true, the resource has been marked as tainted and will be// re-created on the next update.Taintedbool `json:"tainted,omitempty"`// DeposedKey is set if the resource instance has been marked Deposed and// will be destroyed on the next apply.DeposedKeystring `json:"deposed_key,omitempty"`// The version of the resource identity schema the "identity" property// conforms to.IdentitySchemaVersion *uint64 `json:"identity_schema_version,omitempty"`// The JSON representation of the resource identity, whose structure// depends on the resource identity schema.IdentityValues map[string]interface{} `json:"identity,omitempty"`}

StateResource is the representation of a resource in the commonstate representation.

typeStateValues

type StateValues struct {// The Outputs for this common state representation.Outputs map[string]*StateOutput `json:"outputs,omitempty"`// The root module in this state representation.RootModule *StateModule `json:"root_module,omitempty"`}

StateValues is the common representation of resolved values for both theprior state (which is always complete) and the planned new state.

typeValidateOutputadded inv0.7.0

type ValidateOutput struct {FormatVersionstring `json:"format_version"`Validbool         `json:"valid"`ErrorCountint          `json:"error_count"`WarningCountint          `json:"warning_count"`Diagnostics  []Diagnostic `json:"diagnostics"`}

ValidateOutput represents JSON output from terraform validate(available from 0.12 onwards)

func (*ValidateOutput)UnmarshalJSONadded inv0.9.0

func (vo *ValidateOutput) UnmarshalJSON(b []byte)error

func (*ValidateOutput)Validateadded inv0.9.0

func (vo *ValidateOutput) Validate()error

Validate checks to ensure that data is present, and theversion matches the version supported by this library.

typeVersionOutputadded inv0.7.0

type VersionOutput struct {Versionstring            `json:"terraform_version"`Revisionstring            `json:"terraform_revision"`Platformstring            `json:"platform,omitempty"`ProviderSelections map[string]string `json:"provider_selections"`Outdatedbool              `json:"terraform_outdated"`}

VersionOutput represents output from the version -json commandadded in v0.13

Source Files

View all Source files

Directories

PathSynopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp