github.com/hashicorp/packer@v1.14.3/hcl2template/testdata/complete/build.pkr.hcl (about)

     1  
     2  packer {
     3      required_version = ">= v1"
     4  }
     5  
     6  // starts resources to provision them.
     7  build {
     8      sources = [ 
     9          "source.virtualbox-iso.ubuntu-1204",
    10      ]
    11  
    12      source "source.amazon-ebs.ubuntu-1604" {
    13          string = "setting from build section"
    14          nested {
    15              dynamic "tag" {
    16              for_each = local.standard_tags
    17                  content {
    18                      key                 = tag.key
    19                      value               = tag.value
    20                  }
    21              }
    22          }
    23      }
    24  
    25      provisioner "shell" {
    26          name     = "provisioner that does something"
    27          not_squashed = "${var.foo} ${upper(build.ID)}"
    28          string   = "string"
    29          int      = "${41 + 1}"
    30          int64    = "${42 + 1}"
    31          bool     = "true"
    32          trilean  = true
    33          duration = "${9 + 1}s"
    34          map_string_string = {
    35              a = "b"
    36              c = "d"
    37          }
    38          slice_string = [for s in var.availability_zone_names : lower(s)]
    39          slice_slice_string = [
    40              ["a","b"],
    41              ["c","d"]
    42          ]
    43  
    44          nested {
    45              string   = "string"
    46              int      = 42
    47              int64    = 43
    48              bool     = true
    49              trilean  = true
    50              duration = "10s"
    51              map_string_string = {
    52                  a = "b"
    53                  c = "d"
    54              }
    55              slice_string = [for s in var.availability_zone_names : lower(s)]
    56              slice_slice_string = [
    57                  ["a","b"],
    58                  ["c","d"]
    59              ]
    60          }
    61  
    62          nested_slice {
    63              tag {
    64                  key = "first_tag_key"
    65                  value = "first_tag_value"
    66              }
    67              dynamic "tag" {
    68                  for_each = local.standard_tags
    69                  content {
    70                      key                 = tag.key
    71                      value               = tag.value
    72                  }
    73              }
    74          }
    75      }
    76  
    77      provisioner "file" {
    78          not_squashed = "${var.foo} ${upper(build.ID)}"
    79          string   = "string"
    80          int      = 42
    81          int64    = 43
    82          bool     = true
    83          trilean  = true
    84          duration = "10s"
    85          map_string_string = {
    86              a = "b"
    87              c = "d"
    88          }
    89          slice_string = local.abc_map[*].id
    90          slice_slice_string = [
    91              ["a","b"],
    92              ["c","d"]
    93          ]
    94  
    95          nested {
    96              string   = "string"
    97              int      = 42
    98              int64    = 43
    99              bool     = true
   100              trilean  = true
   101              duration = "10s"
   102              map_string_string = {
   103                  a = "b"
   104                  c = "d"
   105              }
   106              slice_string = [
   107                  "a",
   108                  "b",
   109                  "c",
   110              ]
   111              slice_slice_string = [
   112                  ["a","b"],
   113                  ["c","d"]
   114              ]
   115          }
   116  
   117          nested_slice {
   118              tag {
   119                  key = "first_tag_key"
   120                  value = "first_tag_value"
   121              }
   122              dynamic "tag" {
   123                  for_each = local.standard_tags
   124                  content {
   125                      key                 = tag.key
   126                      value               = tag.value
   127                  }
   128              }
   129          }
   130      }
   131  
   132      error-cleanup-provisioner "shell" {
   133          name     = "error-cleanup-provisioner that does something"
   134          not_squashed = "${var.foo} ${upper(build.ID)}"
   135          string   = "string"
   136          int      = "${41 + 1}"
   137          int64    = "${42 + 1}"
   138          bool     = "true"
   139          trilean  = true
   140          duration = "${9 + 1}s"
   141          map_string_string = {
   142              a = "b"
   143              c = "d"
   144          }
   145          slice_string = [for s in var.availability_zone_names : lower(s)]
   146          slice_slice_string = [
   147              ["a","b"],
   148              ["c","d"]
   149          ]
   150  
   151          nested {
   152              string   = "string"
   153              int      = 42
   154              int64    = 43
   155              bool     = true
   156              trilean  = true
   157              duration = "10s"
   158              map_string_string = {
   159                  a = "b"
   160                  c = "d"
   161              }
   162              slice_string = [for s in var.availability_zone_names : lower(s)]
   163              slice_slice_string = [
   164                  ["a","b"],
   165                  ["c","d"]
   166              ]
   167          }
   168  
   169          nested_slice {
   170              tag {
   171                  key = "first_tag_key"
   172                  value = "first_tag_value"
   173              }
   174              dynamic "tag" {
   175                  for_each = local.standard_tags
   176                  content {
   177                      key                 = tag.key
   178                      value               = tag.value
   179                  }
   180              }
   181          }
   182      }
   183  
   184      post-processor "amazon-import" {
   185          name     = "something"
   186          string   = "string"
   187          int      = 42
   188          int64    = 43
   189          bool     = true
   190          trilean  = true
   191          duration = "10s"
   192          keep_input_artifact = true
   193          map_string_string = {
   194              a = "b"
   195              c = "d"
   196          }
   197          slice_string = [
   198              "a",
   199              "b",
   200              "c",
   201          ]
   202          slice_slice_string = [
   203              ["a","b"],
   204              ["c","d"]
   205          ]
   206          not_squashed = "${var.foo} ${upper(build.ID)}"
   207  
   208          nested {
   209              string   = "string"
   210              int      = 42
   211              int64    = 43
   212              bool     = true
   213              trilean  = true
   214              duration = "10s"
   215              map_string_string = {
   216                  a = "b"
   217                  c = "d"
   218              }
   219              slice_string = [
   220                  "a",
   221                  "b",
   222                  "c",
   223              ]
   224              slice_slice_string = [
   225                  ["a","b"],
   226                  ["c","d"]
   227              ]
   228          }
   229  
   230          tag {
   231              key = "first_tag_key"
   232              value = "first_tag_value"
   233          }
   234          dynamic "tag" {
   235              for_each = local.standard_tags
   236              content {
   237                  key                 = tag.key
   238                  value               = tag.value
   239              }
   240          }
   241      }
   242  
   243      post-processor "amazon-import" {
   244          string   = "string"
   245          int      = 42
   246          int64    = 43
   247          bool     = true
   248          trilean  = true
   249          duration = "10s"
   250          map_string_string = {
   251              a = "b"
   252              c = "d"
   253          }
   254          slice_string = [
   255              "a",
   256              "b",
   257              "c",
   258          ]
   259          slice_slice_string = [
   260              ["a","b"],
   261              ["c","d"]
   262          ]
   263          not_squashed = "${var.foo} ${upper(build.ID)}"
   264  
   265          nested {
   266              string   = "string"
   267              int      = 42
   268              int64    = 43
   269              bool     = true
   270              trilean  = true
   271              duration = "10s"
   272              map_string_string = {
   273                  a = "b"
   274                  c = "d"
   275              }
   276              slice_string = [
   277                  "a",
   278                  "b",
   279                  "c",
   280              ]
   281              slice_slice_string = [
   282                  ["a","b"],
   283                  ["c","d"]
   284              ]
   285          }
   286  
   287          nested_slice {
   288          }
   289      }
   290  
   291      post-processors {
   292  
   293          post-processor "amazon-import" {
   294              name     = "first-nested-post-processor"
   295              string   = "string"
   296              int      = 42
   297              int64    = 43
   298              bool     = true
   299              trilean  = true
   300              duration = "10s"
   301              map_string_string = {
   302                  a = "b"
   303                  c = "d"
   304              }
   305              slice_string = [
   306                  "a",
   307                  "b",
   308                  "c",
   309              ]
   310              slice_slice_string = [
   311                  ["a","b"],
   312                  ["c","d"]
   313              ]
   314              not_squashed = "${var.foo} ${upper(build.ID)}"
   315  
   316              nested {
   317                  string   = "string"
   318                  int      = 42
   319                  int64    = 43
   320                  bool     = true
   321                  trilean  = true
   322                  duration = "10s"
   323                  map_string_string = {
   324                      a = "b"
   325                      c = "d"
   326                  }
   327                  slice_string = [
   328                      "a",
   329                      "b",
   330                      "c",
   331                  ]
   332                  slice_slice_string = [
   333                      ["a","b"],
   334                      ["c","d"]
   335                  ]
   336              }
   337  
   338              nested_slice {
   339              }
   340          }
   341  
   342          post-processor "amazon-import" {
   343              name     = "second-nested-post-processor"
   344              string   = "string"
   345              int      = 42
   346              int64    = 43
   347              bool     = true
   348              trilean  = true
   349              duration = "10s"
   350              map_string_string = {
   351                  a = "b"
   352                  c = "d"
   353              }
   354              slice_string = [
   355                  "a",
   356                  "b",
   357                  "c",
   358              ]
   359              slice_slice_string = [
   360                  ["a","b"],
   361                  ["c","d"]
   362              ]
   363              not_squashed = "${var.foo} ${upper(build.ID)}"
   364  
   365              nested {
   366                  string   = "string"
   367                  int      = 42
   368                  int64    = 43
   369                  bool     = true
   370                  trilean  = true
   371                  duration = "10s"
   372                  map_string_string = {
   373                      a = "b"
   374                      c = "d"
   375                  }
   376                  slice_string = [
   377                      "a",
   378                      "b",
   379                      "c",
   380                  ]
   381                  slice_slice_string = [
   382                      ["a","b"],
   383                      ["c","d"]
   384                  ]
   385              }
   386  
   387              nested_slice {
   388              }
   389          }
   390  
   391      }
   392  
   393      post-processors {
   394  
   395          post-processor "amazon-import" {
   396              name     = "third-nested-post-processor"
   397              string   = "string"
   398              int      = 42
   399              int64    = 43
   400              bool     = true
   401              trilean  = true
   402              duration = "10s"
   403              map_string_string = {
   404                  a = "b"
   405                  c = "d"
   406              }
   407              slice_string = [
   408                  "a",
   409                  "b",
   410                  "c",
   411              ]
   412              slice_slice_string = [
   413                  ["a","b"],
   414                  ["c","d"]
   415              ]
   416              not_squashed = "${var.foo} ${upper(build.ID)}"
   417  
   418              nested {
   419                  string   = "string"
   420                  int      = 42
   421                  int64    = 43
   422                  bool     = true
   423                  trilean  = true
   424                  duration = "10s"
   425                  map_string_string = {
   426                      a = "b"
   427                      c = "d"
   428                  }
   429                  slice_string = [
   430                      "a",
   431                      "b",
   432                      "c",
   433                  ]
   434                  slice_slice_string = [
   435                      ["a","b"],
   436                      ["c","d"]
   437                  ]
   438              }
   439  
   440              nested_slice {
   441              }
   442          }
   443  
   444          post-processor "amazon-import" {
   445              name     = "fourth-nested-post-processor"
   446              string   = "string"
   447              int      = 42
   448              int64    = 43
   449              bool     = true
   450              trilean  = true
   451              duration = "10s"
   452              map_string_string = {
   453                  a = "b"
   454                  c = "d"
   455              }
   456              slice_string = [
   457                  "a",
   458                  "b",
   459                  "c",
   460              ]
   461              slice_slice_string = [
   462                  ["a","b"],
   463                  ["c","d"]
   464              ]
   465              not_squashed = "${var.foo} ${upper(build.ID)}"
   466  
   467              nested {
   468                  string   = "string"
   469                  int      = 42
   470                  int64    = 43
   471                  bool     = true
   472                  trilean  = true
   473                  duration = "10s"
   474                  map_string_string = {
   475                      a = "b"
   476                      c = "d"
   477                  }
   478                  slice_string = [
   479                      "a",
   480                      "b",
   481                      "c",
   482                  ]
   483                  slice_slice_string = [
   484                      ["a","b"],
   485                      ["c","d"]
   486                  ]
   487              }
   488  
   489              nested_slice {
   490              }
   491          }
   492  
   493      }
   494  }