github.com/hs0210/hashicorp-terraform@v0.11.12-beta1/terraform/state_v1.go (about) 1 package terraform 2 3 // stateV1 keeps track of a snapshot state-of-the-world that Terraform 4 // can use to keep track of what real world resources it is actually 5 // managing. 6 // 7 // stateV1 is _only used for the purposes of backwards compatibility 8 // and is no longer used in Terraform. 9 // 10 // For the upgrade process, see state_upgrade_v1_to_v2.go 11 type stateV1 struct { 12 // Version is the protocol version. "1" for a StateV1. 13 Version int `json:"version"` 14 15 // Serial is incremented on any operation that modifies 16 // the State file. It is used to detect potentially conflicting 17 // updates. 18 Serial int64 `json:"serial"` 19 20 // Remote is used to track the metadata required to 21 // pull and push state files from a remote storage endpoint. 22 Remote *remoteStateV1 `json:"remote,omitempty"` 23 24 // Modules contains all the modules in a breadth-first order 25 Modules []*moduleStateV1 `json:"modules"` 26 } 27 28 type remoteStateV1 struct { 29 // Type controls the client we use for the remote state 30 Type string `json:"type"` 31 32 // Config is used to store arbitrary configuration that 33 // is type specific 34 Config map[string]string `json:"config"` 35 } 36 37 type moduleStateV1 struct { 38 // Path is the import path from the root module. Modules imports are 39 // always disjoint, so the path represents amodule tree 40 Path []string `json:"path"` 41 42 // Outputs declared by the module and maintained for each module 43 // even though only the root module technically needs to be kept. 44 // This allows operators to inspect values at the boundaries. 45 Outputs map[string]string `json:"outputs"` 46 47 // Resources is a mapping of the logically named resource to 48 // the state of the resource. Each resource may actually have 49 // N instances underneath, although a user only needs to think 50 // about the 1:1 case. 51 Resources map[string]*resourceStateV1 `json:"resources"` 52 53 // Dependencies are a list of things that this module relies on 54 // existing to remain intact. For example: an module may depend 55 // on a VPC ID given by an aws_vpc resource. 56 // 57 // Terraform uses this information to build valid destruction 58 // orders and to warn the user if they're destroying a module that 59 // another resource depends on. 60 // 61 // Things can be put into this list that may not be managed by 62 // Terraform. If Terraform doesn't find a matching ID in the 63 // overall state, then it assumes it isn't managed and doesn't 64 // worry about it. 65 Dependencies []string `json:"depends_on,omitempty"` 66 } 67 68 type resourceStateV1 struct { 69 // This is filled in and managed by Terraform, and is the resource 70 // type itself such as "mycloud_instance". If a resource provider sets 71 // this value, it won't be persisted. 72 Type string `json:"type"` 73 74 // Dependencies are a list of things that this resource relies on 75 // existing to remain intact. For example: an AWS instance might 76 // depend on a subnet (which itself might depend on a VPC, and so 77 // on). 78 // 79 // Terraform uses this information to build valid destruction 80 // orders and to warn the user if they're destroying a resource that 81 // another resource depends on. 82 // 83 // Things can be put into this list that may not be managed by 84 // Terraform. If Terraform doesn't find a matching ID in the 85 // overall state, then it assumes it isn't managed and doesn't 86 // worry about it. 87 Dependencies []string `json:"depends_on,omitempty"` 88 89 // Primary is the current active instance for this resource. 90 // It can be replaced but only after a successful creation. 91 // This is the instances on which providers will act. 92 Primary *instanceStateV1 `json:"primary"` 93 94 // Tainted is used to track any underlying instances that 95 // have been created but are in a bad or unknown state and 96 // need to be cleaned up subsequently. In the 97 // standard case, there is only at most a single instance. 98 // However, in pathological cases, it is possible for the number 99 // of instances to accumulate. 100 Tainted []*instanceStateV1 `json:"tainted,omitempty"` 101 102 // Deposed is used in the mechanics of CreateBeforeDestroy: the existing 103 // Primary is Deposed to get it out of the way for the replacement Primary to 104 // be created by Apply. If the replacement Primary creates successfully, the 105 // Deposed instance is cleaned up. If there were problems creating the 106 // replacement, the instance remains in the Deposed list so it can be 107 // destroyed in a future run. Functionally, Deposed instances are very 108 // similar to Tainted instances in that Terraform is only tracking them in 109 // order to remember to destroy them. 110 Deposed []*instanceStateV1 `json:"deposed,omitempty"` 111 112 // Provider is used when a resource is connected to a provider with an alias. 113 // If this string is empty, the resource is connected to the default provider, 114 // e.g. "aws_instance" goes with the "aws" provider. 115 // If the resource block contained a "provider" key, that value will be set here. 116 Provider string `json:"provider,omitempty"` 117 } 118 119 type instanceStateV1 struct { 120 // A unique ID for this resource. This is opaque to Terraform 121 // and is only meant as a lookup mechanism for the providers. 122 ID string `json:"id"` 123 124 // Attributes are basic information about the resource. Any keys here 125 // are accessible in variable format within Terraform configurations: 126 // ${resourcetype.name.attribute}. 127 Attributes map[string]string `json:"attributes,omitempty"` 128 129 // Ephemeral is used to store any state associated with this instance 130 // that is necessary for the Terraform run to complete, but is not 131 // persisted to a state file. 132 Ephemeral ephemeralStateV1 `json:"-"` 133 134 // Meta is a simple K/V map that is persisted to the State but otherwise 135 // ignored by Terraform core. It's meant to be used for accounting by 136 // external client code. 137 Meta map[string]string `json:"meta,omitempty"` 138 } 139 140 type ephemeralStateV1 struct { 141 // ConnInfo is used for the providers to export information which is 142 // used to connect to the resource for provisioning. For example, 143 // this could contain SSH or WinRM credentials. 144 ConnInfo map[string]string `json:"-"` 145 }