github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/plans/internal/planproto/planfile.proto (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  syntax = "proto3";
     5  package tfplan;
     6  
     7  // For Terraform's own parsing, the proto stub types go into an internal Go
     8  // package. The public API is in github.com/terramate-io/tf/plans/planfile .
     9  option go_package = "github.com/terramate-io/tf/internal/plans/internal/planproto";
    10  
    11  // Plan is the root message type for the tfplan file
    12  message Plan {
    13      // Version is incremented whenever there is a breaking change to
    14      // the serialization format. Programs reading serialized plans should
    15      // verify that version is set to the expected value and abort processing
    16      // if not. A breaking change is any change that may cause an older
    17      // consumer to interpret the structure incorrectly. This number will
    18      // not be incremented if an existing consumer can either safely ignore
    19      // changes to the format or if an existing consumer would fail to process
    20      // the file for another message- or field-specific reason.
    21      uint64 version = 1;
    22  
    23      // The mode that was active when this plan was created.
    24      //
    25      // This is saved only for UI purposes, so that Terraform can tailor its
    26      // rendering of the plan depending on the mode. This must never be used to
    27      // make decisions in Terraform Core during the applying of a plan.
    28      Mode ui_mode = 17;
    29  
    30      // Errored is true for any plan whose creation was interrupted by an
    31      // error. A plan with this flag set cannot be applied, and the changes
    32      // it proposes are likely to be incomplete.
    33      bool errored = 20;
    34  
    35      // The variables that were set when creating the plan. Each value is
    36      // a msgpack serialization of an HCL value.
    37      map<string, DynamicValue> variables = 2;
    38  
    39      // An unordered set of proposed changes to resources throughout the
    40      // configuration, including any nested modules. Use the address of
    41      // each resource to determine which module it belongs to.
    42      repeated ResourceInstanceChange resource_changes = 3;
    43  
    44      // An unordered set of detected drift: changes made to resources outside of
    45      // Terraform, computed by comparing the previous run's state to the state
    46      // after refresh.
    47      repeated ResourceInstanceChange resource_drift = 18;
    48  
    49      // An unordered set of proposed changes to outputs in the root module
    50      // of the configuration. This set also includes "no action" changes for
    51      // outputs that are not changing, as context for detecting inconsistencies
    52      // at apply time.
    53      repeated OutputChange output_changes = 4;
    54  
    55      // An unordered set of check results for the entire configuration.
    56      //
    57      // Each element represents a single static configuration object that has
    58      // checks, and each of those may have zero or more dynamic objects that
    59      // the checks were applied to nested within.
    60      repeated CheckResults check_results = 19;
    61  
    62      // An unordered set of target addresses to include when applying. If no
    63      // target addresses are present, the plan applies to the whole
    64      // configuration.
    65      repeated string target_addrs = 5;
    66  
    67      // An unordered set of force-replace addresses to include when applying.
    68      // This must match the set of addresses that was used when creating the
    69      // plan, or else applying the plan will fail when it reaches a different
    70      // conclusion about what action a particular resource instance needs.
    71      repeated string force_replace_addrs = 16;
    72  
    73      // The version string for the Terraform binary that created this plan.
    74      string terraform_version = 14;
    75  
    76      // Backend is a description of the backend configuration and other related
    77      // settings at the time the plan was created.
    78      Backend backend = 13;
    79  
    80      message resource_attr {
    81         string resource = 1;
    82         Path attr= 2;
    83      };
    84  
    85      // RelevantAttributes lists individual resource attributes from
    86      // ResourceDrift which may have contributed to the plan changes.
    87      repeated resource_attr relevant_attributes = 15;
    88  
    89      // timestamp is the record of truth for when the plan happened.
    90      string timestamp = 21;
    91  }
    92  
    93  // Mode describes the planning mode that created the plan.
    94  enum Mode {
    95      NORMAL = 0;
    96      DESTROY = 1;
    97      REFRESH_ONLY = 2;
    98  }
    99  
   100  // Backend is a description of backend configuration and other related settings.
   101  message Backend {
   102      string type = 1;
   103      DynamicValue config = 2;
   104      string workspace = 3;
   105  }
   106  
   107  // Action describes the type of action planned for an object.
   108  // Not all action values are valid for all object types.
   109  enum Action {
   110      NOOP = 0;
   111      CREATE = 1;
   112      READ = 2;
   113      UPDATE = 3;
   114      DELETE = 5;
   115      DELETE_THEN_CREATE = 6;
   116      CREATE_THEN_DELETE = 7;
   117  }
   118  
   119  // Change represents a change made to some object, transforming it from an old
   120  // state to a new state.
   121  message Change {
   122      // Not all action values are valid for all object types. Consult
   123      // the documentation for any message that embeds Change.
   124      Action action = 1;
   125  
   126      // msgpack-encoded HCL values involved in the change.
   127      // - For update and replace, two values are provided that give the old and new values,
   128      //   respectively.
   129      // - For create, one value is provided that gives the new value to be created
   130      // - For delete, one value is provided that describes the value being deleted
   131      // - For read, two values are provided that give the prior value for this object
   132      //   (or null, if no prior value exists) and the value that was or will be read,
   133      //   respectively.
   134      // - For no-op, one value is provided that is left unmodified by this non-change.
   135      repeated DynamicValue values = 2;
   136  
   137      // An unordered set of paths into the old value which are marked as
   138      // sensitive. Values at these paths should be obscured in human-readable
   139      // output. This set is always empty for create.
   140      repeated Path before_sensitive_paths = 3;
   141  
   142      // An unordered set of paths into the new value which are marked as
   143      // sensitive. Values at these paths should be obscured in human-readable
   144      // output. This set is always empty for delete.
   145      repeated Path after_sensitive_paths = 4;
   146  
   147      // Importing, if true, specifies that the resource is being imported as part
   148      // of the change.
   149      Importing importing = 5;
   150  
   151      // GeneratedConfig contains any configuration that was generated as part of
   152      // the change, as an HCL string.
   153      string generated_config = 6;
   154  }
   155  
   156  // ResourceInstanceActionReason sometimes provides some additional user-facing
   157  // context for why a particular action was chosen for a resource instance.
   158  // This is for user feedback only and never used to drive behavior during the
   159  // subsequent apply step.
   160  enum ResourceInstanceActionReason {
   161      NONE = 0;
   162      REPLACE_BECAUSE_TAINTED = 1;
   163      REPLACE_BY_REQUEST = 2;
   164      REPLACE_BECAUSE_CANNOT_UPDATE = 3;
   165      DELETE_BECAUSE_NO_RESOURCE_CONFIG = 4;
   166      DELETE_BECAUSE_WRONG_REPETITION = 5;
   167      DELETE_BECAUSE_COUNT_INDEX = 6;
   168      DELETE_BECAUSE_EACH_KEY = 7;
   169      DELETE_BECAUSE_NO_MODULE = 8;
   170      REPLACE_BY_TRIGGERS = 9;
   171      READ_BECAUSE_CONFIG_UNKNOWN = 10;
   172      READ_BECAUSE_DEPENDENCY_PENDING = 11;
   173      READ_BECAUSE_CHECK_NESTED = 13;
   174      DELETE_BECAUSE_NO_MOVE_TARGET = 12;
   175  }
   176  
   177  message ResourceInstanceChange {
   178      // addr is a string representation of the resource instance address that
   179      // this change will apply to.
   180      string addr = 13;
   181  
   182      // prev_run_addr is a string representation of the address at which
   183      // this resource instance was tracked during the previous apply operation.
   184      //
   185      // This is populated only if it would be different from addr due to
   186      // Terraform having reacted to refactoring annotations in the configuration.
   187      // If empty, the previous run address is the same as the current address.
   188      string prev_run_addr = 14;
   189  
   190      // NOTE: Earlier versions of this format had fields 1 through 6 describing
   191      // various indivdual parts of "addr". We're now using our standard compact
   192      // string representation to capture the same information. We don't support
   193      // preserving plan files from one Terraform version to the next, so we
   194      // no longer declare nor accept those fields.
   195  
   196      // deposed_key, if set, indicates that this change applies to a deposed
   197      // object for the indicated instance with the given deposed key. If not
   198      // set, the change applies to the instance's current object.
   199      string deposed_key = 7;
   200  
   201      // provider is the address of the provider configuration that this change
   202      // was planned with, and thus the configuration that must be used to
   203      // apply it.
   204      string provider = 8;
   205  
   206      // Description of the proposed change. May use "create", "read", "update",
   207      // "replace", "delete" and "no-op" actions.
   208      Change change = 9;
   209  
   210      // raw blob value provided by the provider as additional context for the
   211      // change. Must be considered an opaque value for any consumer other than
   212      // the provider that generated it, and will be returned verbatim to the
   213      // provider during the subsequent apply operation.
   214      bytes private = 10;
   215  
   216      // An unordered set of paths that prompted the change action to be
   217      // "replace" rather than "update". Empty for any action other than
   218      // "replace".
   219      repeated Path required_replace = 11;
   220  
   221      // Optional extra user-oriented context for why change.Action was chosen.
   222      // This is for user feedback only and never used to drive behavior during
   223      // apply.
   224      ResourceInstanceActionReason action_reason = 12;
   225  }
   226  
   227  message OutputChange {
   228      // Name of the output as defined in the root module.
   229      string name = 1;
   230  
   231      // Description of the proposed change. May use "no-op", "create",
   232      // "update" and "delete" actions.
   233      Change change = 2;
   234  
   235      // Sensitive, if true, indicates that one or more of the values given
   236      // in "change" is sensitive and should not be shown directly in any
   237      // rendered plan.
   238      bool sensitive = 3;
   239  }
   240  
   241  message CheckResults {
   242      // Status describes the status of a particular checkable object at the
   243      // completion of the plan.
   244      enum Status {
   245          UNKNOWN = 0;
   246          PASS    = 1;
   247          FAIL    = 2;
   248          ERROR   = 3;
   249      }
   250  
   251      enum ObjectKind {
   252          UNSPECIFIED = 0;
   253          RESOURCE = 1;
   254          OUTPUT_VALUE = 2;
   255          CHECK = 3;
   256          INPUT_VARIABLE = 4;
   257      }
   258  
   259      message ObjectResult {
   260          string object_addr = 1;
   261          Status status = 2;
   262          repeated string failure_messages = 3;
   263      }
   264  
   265      ObjectKind kind = 1;
   266  
   267      // Address of the configuration object that declared the checks.
   268      string config_addr = 2;
   269  
   270      // The aggregate status of the entire configuration object, based on
   271      // the statuses of its zero or more checkable objects.
   272      Status status = 3;
   273  
   274      // The results for individual objects that were declared by the
   275      // configuration object named in config_addr.
   276      repeated ObjectResult objects = 4;
   277  }
   278  
   279  // DynamicValue represents a value whose type is not decided until runtime,
   280  // often based on schema information obtained from a plugin.
   281  //
   282  // At present dynamic values are always encoded as msgpack, with extension
   283  // id 0 used to represent the special "unknown" value indicating results
   284  // that won't be known until after apply.
   285  //
   286  // In future other serialization formats may be used, possibly with a
   287  // transitional period of including both as separate attributes of this type.
   288  // Consumers must ignore attributes they don't support and fail if no supported
   289  // attribute is present. The top-level format version will not be incremented
   290  // for changes to the set of dynamic serialization formats.
   291  message DynamicValue {
   292      bytes msgpack = 1;
   293  }
   294  
   295  // Path represents a set of steps to traverse into a data structure. It is
   296  // used to refer to a sub-structure within a dynamic data structure presented
   297  // separately.
   298  message Path {
   299      message Step {
   300          oneof selector {
   301              // Set "attribute_name" to represent looking up an attribute
   302              // in the current object value.
   303              string attribute_name = 1;
   304  
   305              // Set "element_key" to represent looking up an element in
   306              // an indexable collection type.
   307              DynamicValue element_key = 2;
   308          }
   309      }
   310      repeated Step steps = 1;
   311  }
   312  
   313  // Importing contains the embedded metadata about the import operation if this
   314  // change describes it.
   315  message Importing {
   316      // The original ID of the resource.
   317      string id = 1;
   318  }