github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/docs/plugin-protocol/tfplugin5.0.proto (about) 1 // Terraform Plugin RPC protocol version 5.0 2 // 3 // This file defines version 5.0 of the RPC protocol. To implement a plugin 4 // against this protocol, copy this definition into your own codebase and 5 // use protoc to generate stubs for your target language. 6 // 7 // This file will be updated in-place in the source Terraform repository for 8 // any minor versions of protocol 5, but later minor versions will always be 9 // backwards compatible. Breaking changes, if any are required, will come 10 // in a subsequent major version with its own separate proto definition. 11 // 12 // Note that only the proto files included in a release tag of Terraform are 13 // official protocol releases. Proto files taken from other commits may include 14 // incomplete changes or features that did not make it into a final release. 15 // In all reasonable cases, plugin developers should take the proto file from 16 // the tag of the most recent release of Terraform, and not from the master 17 // branch or any other development branch. 18 // 19 syntax = "proto3"; 20 21 package tfplugin5; 22 23 // DynamicValue is an opaque encoding of terraform data, with the field name 24 // indicating the encoding scheme used. 25 message DynamicValue { 26 bytes msgpack = 1; 27 bytes json = 2; 28 } 29 30 message Diagnostic { 31 enum Severity { 32 INVALID = 0; 33 ERROR = 1; 34 WARNING = 2; 35 } 36 Severity severity = 1; 37 string summary = 2; 38 string detail = 3; 39 AttributePath attribute = 4; 40 } 41 42 message AttributePath { 43 message Step { 44 oneof selector { 45 // Set "attribute_name" to represent looking up an attribute 46 // in the current object value. 47 string attribute_name = 1; 48 // Set "element_key_*" to represent looking up an element in 49 // an indexable collection type. 50 string element_key_string = 2; 51 int64 element_key_int = 3; 52 } 53 } 54 repeated Step steps = 1; 55 } 56 57 message Stop { 58 message Request { 59 } 60 message Response { 61 string Error = 1; 62 } 63 } 64 65 // RawState holds the stored state for a resource to be upgraded by the 66 // provider. It can be in one of two formats, the current json encoded format 67 // in bytes, or the legacy flatmap format as a map of strings. 68 message RawState { 69 bytes json = 1; 70 map<string, string> flatmap = 2; 71 } 72 73 // Schema is the configuration schema for a Resource, Provider, or Provisioner. 74 message Schema { 75 message Block { 76 int64 version = 1; 77 repeated Attribute attributes = 2; 78 repeated NestedBlock block_types = 3; 79 } 80 81 message Attribute { 82 string name = 1; 83 bytes type = 2; 84 string description = 3; 85 bool required = 4; 86 bool optional = 5; 87 bool computed = 6; 88 bool sensitive = 7; 89 } 90 91 message NestedBlock { 92 enum NestingMode { 93 INVALID = 0; 94 SINGLE = 1; 95 LIST = 2; 96 SET = 3; 97 MAP = 4; 98 GROUP = 5; 99 } 100 101 string type_name = 1; 102 Block block = 2; 103 NestingMode nesting = 3; 104 int64 min_items = 4; 105 int64 max_items = 5; 106 } 107 108 // The version of the schema. 109 // Schemas are versioned, so that providers can upgrade a saved resource 110 // state when the schema is changed. 111 int64 version = 1; 112 113 // Block is the top level configuration block for this schema. 114 Block block = 2; 115 } 116 117 service Provider { 118 //////// Information about what a provider supports/expects 119 rpc GetSchema(GetProviderSchema.Request) returns (GetProviderSchema.Response); 120 rpc PrepareProviderConfig(PrepareProviderConfig.Request) returns (PrepareProviderConfig.Response); 121 rpc ValidateResourceTypeConfig(ValidateResourceTypeConfig.Request) returns (ValidateResourceTypeConfig.Response); 122 rpc ValidateDataSourceConfig(ValidateDataSourceConfig.Request) returns (ValidateDataSourceConfig.Response); 123 rpc UpgradeResourceState(UpgradeResourceState.Request) returns (UpgradeResourceState.Response); 124 125 //////// One-time initialization, called before other functions below 126 rpc Configure(Configure.Request) returns (Configure.Response); 127 128 //////// Managed Resource Lifecycle 129 rpc ReadResource(ReadResource.Request) returns (ReadResource.Response); 130 rpc PlanResourceChange(PlanResourceChange.Request) returns (PlanResourceChange.Response); 131 rpc ApplyResourceChange(ApplyResourceChange.Request) returns (ApplyResourceChange.Response); 132 rpc ImportResourceState(ImportResourceState.Request) returns (ImportResourceState.Response); 133 134 rpc ReadDataSource(ReadDataSource.Request) returns (ReadDataSource.Response); 135 136 //////// Graceful Shutdown 137 rpc Stop(Stop.Request) returns (Stop.Response); 138 } 139 140 message GetProviderSchema { 141 message Request { 142 } 143 message Response { 144 Schema provider = 1; 145 map<string, Schema> resource_schemas = 2; 146 map<string, Schema> data_source_schemas = 3; 147 repeated Diagnostic diagnostics = 4; 148 } 149 } 150 151 message PrepareProviderConfig { 152 message Request { 153 DynamicValue config = 1; 154 } 155 message Response { 156 DynamicValue prepared_config = 1; 157 repeated Diagnostic diagnostics = 2; 158 } 159 } 160 161 message UpgradeResourceState { 162 message Request { 163 string type_name = 1; 164 165 // version is the schema_version number recorded in the state file 166 int64 version = 2; 167 168 // raw_state is the raw states as stored for the resource. Core does 169 // not have access to the schema of prior_version, so it's the 170 // provider's responsibility to interpret this value using the 171 // appropriate older schema. The raw_state will be the json encoded 172 // state, or a legacy flat-mapped format. 173 RawState raw_state = 3; 174 } 175 message Response { 176 // new_state is a msgpack-encoded data structure that, when interpreted with 177 // the _current_ schema for this resource type, is functionally equivalent to 178 // that which was given in prior_state_raw. 179 DynamicValue upgraded_state = 1; 180 181 // diagnostics describes any errors encountered during migration that could not 182 // be safely resolved, and warnings about any possibly-risky assumptions made 183 // in the upgrade process. 184 repeated Diagnostic diagnostics = 2; 185 } 186 } 187 188 message ValidateResourceTypeConfig { 189 message Request { 190 string type_name = 1; 191 DynamicValue config = 2; 192 } 193 message Response { 194 repeated Diagnostic diagnostics = 1; 195 } 196 } 197 198 message ValidateDataSourceConfig { 199 message Request { 200 string type_name = 1; 201 DynamicValue config = 2; 202 } 203 message Response { 204 repeated Diagnostic diagnostics = 1; 205 } 206 } 207 208 message Configure { 209 message Request { 210 string terraform_version = 1; 211 DynamicValue config = 2; 212 } 213 message Response { 214 repeated Diagnostic diagnostics = 1; 215 } 216 } 217 218 message ReadResource { 219 message Request { 220 string type_name = 1; 221 DynamicValue current_state = 2; 222 bytes private = 3; 223 } 224 message Response { 225 DynamicValue new_state = 1; 226 repeated Diagnostic diagnostics = 2; 227 bytes private = 3; 228 } 229 } 230 231 message PlanResourceChange { 232 message Request { 233 string type_name = 1; 234 DynamicValue prior_state = 2; 235 DynamicValue proposed_new_state = 3; 236 DynamicValue config = 4; 237 bytes prior_private = 5; 238 } 239 240 message Response { 241 DynamicValue planned_state = 1; 242 repeated AttributePath requires_replace = 2; 243 bytes planned_private = 3; 244 repeated Diagnostic diagnostics = 4; 245 246 247 // This may be set only by the helper/schema "SDK" in the main Terraform 248 // repository, to request that Terraform Core >=0.12 permit additional 249 // inconsistencies that can result from the legacy SDK type system 250 // and its imprecise mapping to the >=0.12 type system. 251 // The change in behavior implied by this flag makes sense only for the 252 // specific details of the legacy SDK type system, and are not a general 253 // mechanism to avoid proper type handling in providers. 254 // 255 // ==== DO NOT USE THIS ==== 256 // ==== THIS MUST BE LEFT UNSET IN ALL OTHER SDKS ==== 257 // ==== DO NOT USE THIS ==== 258 bool legacy_type_system = 5; 259 } 260 } 261 262 message ApplyResourceChange { 263 message Request { 264 string type_name = 1; 265 DynamicValue prior_state = 2; 266 DynamicValue planned_state = 3; 267 DynamicValue config = 4; 268 bytes planned_private = 5; 269 } 270 message Response { 271 DynamicValue new_state = 1; 272 bytes private = 2; 273 repeated Diagnostic diagnostics = 3; 274 275 // This may be set only by the helper/schema "SDK" in the main Terraform 276 // repository, to request that Terraform Core >=0.12 permit additional 277 // inconsistencies that can result from the legacy SDK type system 278 // and its imprecise mapping to the >=0.12 type system. 279 // The change in behavior implied by this flag makes sense only for the 280 // specific details of the legacy SDK type system, and are not a general 281 // mechanism to avoid proper type handling in providers. 282 // 283 // ==== DO NOT USE THIS ==== 284 // ==== THIS MUST BE LEFT UNSET IN ALL OTHER SDKS ==== 285 // ==== DO NOT USE THIS ==== 286 bool legacy_type_system = 4; 287 } 288 } 289 290 message ImportResourceState { 291 message Request { 292 string type_name = 1; 293 string id = 2; 294 } 295 296 message ImportedResource { 297 string type_name = 1; 298 DynamicValue state = 2; 299 bytes private = 3; 300 } 301 302 message Response { 303 repeated ImportedResource imported_resources = 1; 304 repeated Diagnostic diagnostics = 2; 305 } 306 } 307 308 message ReadDataSource { 309 message Request { 310 string type_name = 1; 311 DynamicValue config = 2; 312 } 313 message Response { 314 DynamicValue state = 1; 315 repeated Diagnostic diagnostics = 2; 316 } 317 } 318 319 service Provisioner { 320 rpc GetSchema(GetProvisionerSchema.Request) returns (GetProvisionerSchema.Response); 321 rpc ValidateProvisionerConfig(ValidateProvisionerConfig.Request) returns (ValidateProvisionerConfig.Response); 322 rpc ProvisionResource(ProvisionResource.Request) returns (stream ProvisionResource.Response); 323 rpc Stop(Stop.Request) returns (Stop.Response); 324 } 325 326 message GetProvisionerSchema { 327 message Request { 328 } 329 message Response { 330 Schema provisioner = 1; 331 repeated Diagnostic diagnostics = 2; 332 } 333 } 334 335 message ValidateProvisionerConfig { 336 message Request { 337 DynamicValue config = 1; 338 } 339 message Response { 340 repeated Diagnostic diagnostics = 1; 341 } 342 } 343 344 message ProvisionResource { 345 message Request { 346 DynamicValue config = 1; 347 DynamicValue connection = 2; 348 } 349 message Response { 350 string output = 1; 351 repeated Diagnostic diagnostics = 2; 352 } 353 }