github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.proto (about)

     1  // Terraform Plugin RPC protocol version 5.2
     2  //
     3  // This file defines version 5.2 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 not be updated. Any minor versions of protocol 5 to follow
     8  // should copy this file and modify the copy while maintaing backwards
     9  // compatibility. 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  enum StringKind {
    74      PLAIN = 0;
    75      MARKDOWN = 1;
    76  }
    77  
    78  // Schema is the configuration schema for a Resource, Provider, or Provisioner.
    79  message Schema {
    80      message Block {
    81          int64 version = 1;
    82          repeated Attribute attributes = 2;
    83          repeated NestedBlock block_types = 3;
    84          string description = 4;
    85          StringKind description_kind = 5;
    86          bool deprecated = 6;
    87      }
    88  
    89      message Attribute {
    90          string name = 1;
    91          bytes type = 2;
    92          string description = 3;
    93          bool required = 4;
    94          bool optional = 5;
    95          bool computed = 6;
    96          bool sensitive = 7;
    97          StringKind description_kind = 8;
    98          bool deprecated = 9;
    99      }
   100  
   101      message NestedBlock {
   102          enum NestingMode {
   103              INVALID = 0;
   104              SINGLE = 1;
   105              LIST = 2;
   106              SET = 3;
   107              MAP = 4;
   108              GROUP = 5;
   109          }
   110  
   111          string type_name = 1;
   112          Block block = 2;
   113          NestingMode nesting = 3;
   114          int64 min_items = 4;
   115          int64 max_items = 5;
   116      }
   117  
   118      // The version of the schema.
   119      // Schemas are versioned, so that providers can upgrade a saved resource
   120      // state when the schema is changed. 
   121      int64 version = 1;
   122  
   123      // Block is the top level configuration block for this schema.
   124      Block block = 2;
   125  }
   126  
   127  service Provider {
   128      //////// Information about what a provider supports/expects
   129      rpc GetSchema(GetProviderSchema.Request) returns (GetProviderSchema.Response);
   130      rpc PrepareProviderConfig(PrepareProviderConfig.Request) returns (PrepareProviderConfig.Response);
   131      rpc ValidateResourceTypeConfig(ValidateResourceTypeConfig.Request) returns (ValidateResourceTypeConfig.Response);
   132      rpc ValidateDataSourceConfig(ValidateDataSourceConfig.Request) returns (ValidateDataSourceConfig.Response);
   133      rpc UpgradeResourceState(UpgradeResourceState.Request) returns (UpgradeResourceState.Response);
   134  
   135      //////// One-time initialization, called before other functions below
   136      rpc Configure(Configure.Request) returns (Configure.Response);
   137  
   138      //////// Managed Resource Lifecycle
   139      rpc ReadResource(ReadResource.Request) returns (ReadResource.Response);
   140      rpc PlanResourceChange(PlanResourceChange.Request) returns (PlanResourceChange.Response);
   141      rpc ApplyResourceChange(ApplyResourceChange.Request) returns (ApplyResourceChange.Response);
   142      rpc ImportResourceState(ImportResourceState.Request) returns (ImportResourceState.Response);
   143  
   144      rpc ReadDataSource(ReadDataSource.Request) returns (ReadDataSource.Response);
   145  
   146      //////// Graceful Shutdown
   147      rpc Stop(Stop.Request) returns (Stop.Response);
   148  }
   149  
   150  message GetProviderSchema {
   151      message Request {
   152      }
   153      message Response {
   154          Schema provider = 1;
   155          map<string, Schema> resource_schemas = 2;
   156          map<string, Schema> data_source_schemas = 3;
   157          repeated Diagnostic diagnostics = 4;
   158          Schema provider_meta = 5;
   159      }
   160  }
   161  
   162  message PrepareProviderConfig {
   163      message Request {
   164          DynamicValue config = 1;
   165      }
   166      message Response {
   167          DynamicValue prepared_config = 1;
   168          repeated Diagnostic diagnostics = 2;
   169      }
   170  }
   171  
   172  message UpgradeResourceState {
   173      message Request {
   174          string type_name = 1;
   175  
   176          // version is the schema_version number recorded in the state file
   177          int64 version = 2;
   178  
   179          // raw_state is the raw states as stored for the resource.  Core does
   180          // not have access to the schema of prior_version, so it's the
   181          // provider's responsibility to interpret this value using the
   182          // appropriate older schema. The raw_state will be the json encoded
   183          // state, or a legacy flat-mapped format.
   184          RawState raw_state = 3;
   185      }
   186      message Response {
   187          // new_state is a msgpack-encoded data structure that, when interpreted with
   188          // the _current_ schema for this resource type, is functionally equivalent to
   189          // that which was given in prior_state_raw.
   190          DynamicValue upgraded_state = 1;
   191  
   192          // diagnostics describes any errors encountered during migration that could not
   193          // be safely resolved, and warnings about any possibly-risky assumptions made
   194          // in the upgrade process.
   195          repeated Diagnostic diagnostics = 2;
   196      }
   197  }
   198  
   199  message ValidateResourceTypeConfig {
   200      message Request {
   201          string type_name = 1;
   202          DynamicValue config = 2;
   203      }
   204      message Response {
   205          repeated Diagnostic diagnostics = 1;
   206      }
   207  }
   208  
   209  message ValidateDataSourceConfig {
   210      message Request {
   211          string type_name = 1;
   212          DynamicValue config = 2;
   213      }
   214      message Response {
   215          repeated Diagnostic diagnostics = 1;
   216      }
   217  }
   218  
   219  message Configure {
   220      message Request {
   221          string terraform_version = 1;
   222          DynamicValue config = 2;
   223      }
   224      message Response {
   225          repeated Diagnostic diagnostics = 1;
   226      }
   227  }
   228  
   229  message ReadResource {
   230      message Request {
   231          string type_name = 1;
   232          DynamicValue current_state = 2;
   233          bytes private = 3;
   234          DynamicValue provider_meta = 4;
   235      }
   236      message Response {
   237          DynamicValue new_state = 1;
   238          repeated Diagnostic diagnostics = 2;
   239          bytes private = 3;
   240      }
   241  }
   242  
   243  message PlanResourceChange {
   244      message Request {
   245          string type_name = 1;
   246          DynamicValue prior_state = 2;
   247          DynamicValue proposed_new_state = 3;
   248          DynamicValue config = 4;
   249          bytes prior_private = 5; 
   250          DynamicValue provider_meta = 6;
   251      }
   252  
   253      message Response {
   254          DynamicValue planned_state = 1;
   255          repeated AttributePath requires_replace = 2;
   256          bytes planned_private = 3; 
   257          repeated Diagnostic diagnostics = 4;
   258  
   259  
   260          // This may be set only by the helper/schema "SDK" in the main Terraform
   261          // repository, to request that Terraform Core >=0.12 permit additional
   262          // inconsistencies that can result from the legacy SDK type system
   263          // and its imprecise mapping to the >=0.12 type system.
   264          // The change in behavior implied by this flag makes sense only for the
   265          // specific details of the legacy SDK type system, and are not a general
   266          // mechanism to avoid proper type handling in providers.
   267          //
   268          //     ====              DO NOT USE THIS              ====
   269          //     ==== THIS MUST BE LEFT UNSET IN ALL OTHER SDKS ====
   270          //     ====              DO NOT USE THIS              ====
   271          bool legacy_type_system = 5;
   272      }
   273  }
   274  
   275  message ApplyResourceChange {
   276      message Request {
   277          string type_name = 1;
   278          DynamicValue prior_state = 2;
   279          DynamicValue planned_state = 3;
   280          DynamicValue config = 4;
   281          bytes planned_private = 5; 
   282          DynamicValue provider_meta = 6;
   283      }
   284      message Response {
   285          DynamicValue new_state = 1;
   286          bytes private = 2; 
   287          repeated Diagnostic diagnostics = 3;
   288  
   289          // This may be set only by the helper/schema "SDK" in the main Terraform
   290          // repository, to request that Terraform Core >=0.12 permit additional
   291          // inconsistencies that can result from the legacy SDK type system
   292          // and its imprecise mapping to the >=0.12 type system.
   293          // The change in behavior implied by this flag makes sense only for the
   294          // specific details of the legacy SDK type system, and are not a general
   295          // mechanism to avoid proper type handling in providers.
   296          //
   297          //     ====              DO NOT USE THIS              ====
   298          //     ==== THIS MUST BE LEFT UNSET IN ALL OTHER SDKS ====
   299          //     ====              DO NOT USE THIS              ====
   300          bool legacy_type_system = 4;
   301      }
   302  }
   303  
   304  message ImportResourceState {
   305      message Request {
   306          string type_name = 1;
   307          string id = 2;
   308      }
   309  
   310      message ImportedResource {
   311          string type_name = 1;
   312          DynamicValue state = 2;
   313          bytes private = 3;
   314      }
   315  
   316      message Response {
   317          repeated ImportedResource imported_resources = 1;
   318          repeated Diagnostic diagnostics = 2;
   319      }
   320  }
   321  
   322  message ReadDataSource {
   323      message Request {
   324          string type_name = 1;
   325          DynamicValue config = 2;
   326          DynamicValue provider_meta = 3;
   327      }
   328      message Response {
   329          DynamicValue state = 1;
   330          repeated Diagnostic diagnostics = 2;
   331      }
   332  }
   333  
   334  service Provisioner {
   335      rpc GetSchema(GetProvisionerSchema.Request) returns (GetProvisionerSchema.Response);
   336      rpc ValidateProvisionerConfig(ValidateProvisionerConfig.Request) returns (ValidateProvisionerConfig.Response);
   337      rpc ProvisionResource(ProvisionResource.Request) returns (stream ProvisionResource.Response);
   338      rpc Stop(Stop.Request) returns (Stop.Response);
   339  }
   340  
   341  message GetProvisionerSchema {
   342      message Request {
   343      }
   344      message Response {
   345          Schema provisioner = 1;
   346          repeated Diagnostic diagnostics = 2;
   347      }
   348  }
   349  
   350  message ValidateProvisionerConfig {
   351      message Request {
   352          DynamicValue config = 1;
   353      }
   354      message Response {
   355          repeated Diagnostic diagnostics = 1;
   356      }
   357  }
   358  
   359  message ProvisionResource {
   360      message Request {
   361          DynamicValue config = 1;
   362          DynamicValue connection = 2;
   363      }
   364      message Response {
   365          string output  = 1;
   366          repeated Diagnostic diagnostics = 2;
   367      }   
   368  }