53 lines
1.3 KiB
Plaintext
53 lines
1.3 KiB
Plaintext
|
---
|
||
|
layout: guides
|
||
|
sidebar_current: hcl
|
||
|
page_title: Getting started configuring Packer with HCL2 files
|
||
|
---
|
||
|
|
||
|
# Introduction to Packer HCL2
|
||
|
|
||
|
-> **Note:** Starting from version **1.5.0** Packer can read HCL2 files.
|
||
|
|
||
|
It is not necessary to know all of the details of the HCL syntax in order to
|
||
|
use Packer, and so this page summarizes the most important details to get you
|
||
|
started. If you are interested, you can find a [full definition of HCL
|
||
|
syntax](https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md) in
|
||
|
the HCL native syntax specification.
|
||
|
|
||
|
## Arguments and Blocks
|
||
|
|
||
|
The HCL syntax is built around two key syntax constructs: arguments and blocks.
|
||
|
|
||
|
```hcl
|
||
|
# block
|
||
|
source "amazon-ebs" "example" {
|
||
|
|
||
|
# argument
|
||
|
ami_name = "abc123"
|
||
|
}
|
||
|
```
|
||
|
|
||
|
## Comments
|
||
|
|
||
|
The HCL language supports three different syntaxes for comments:
|
||
|
|
||
|
* ```#``` begins a single-line comment, ending at the end of the line.
|
||
|
* ```//``` also begins a single-line comment, as an alternative to ```#```.
|
||
|
* ```/*``` and ```*/``` are start and end delimiters for a comment that might
|
||
|
span over multiple lines.
|
||
|
|
||
|
## Multi-line strings
|
||
|
|
||
|
A multi-line string value can be provided using heredoc syntax.
|
||
|
|
||
|
```hcl
|
||
|
variable "long_key" {
|
||
|
type = "string"
|
||
|
default = <<EOF
|
||
|
This is a long key.
|
||
|
Running over several lines.
|
||
|
It could be super handy for a boot_command.
|
||
|
EOF
|
||
|
}
|
||
|
```
|