packer-cn/website/source/docs/templates/configuration-templates.htm...

5.0 KiB

01 02 03 (15) 04 05 06 -0700 Textual Monday (Mon) January (Jan) - - - - - MST

The values in parentheses are the abbreviated, or 24-hour clock values

Note that "-0700" is always formatted into "+0000" because isotime is always UTC time.

Here are some example formated time, using the above format options:

isotime = June 7, 7:22:43pm 2014

{{isotime "2006-01-02"}} = 2014-06-07
{{isotime "Mon 1504"}} = Sat 1922
{{isotime "02-Jan-06 03\_04\_05"}} = 07-Jun-2014 07\_22\_43
{{isotime "Hour15Year200603"}} = Hour19Year201407

Please note that double quote characters need escaping inside of templates (in this case, on the ami_name value):

{
  "builders": [
    {
      "type": "amazon-ebs",
      "access_key": "...",
      "secret_key": "...",
      "region": "us-east-1",
      "source_ami": "ami-fce3c696",
      "instance_type": "t2.micro",
      "ssh_username": "ubuntu",
      "ami_name": "packer {{isotime \"2006-01-02\"}}"
    }
  ]
}

-> Note: See the Amazon builder documentation for more information on how to correctly configure the Amazon builder in this example.

Amazon Specific Functions

Specific to Amazon builders:

  • clean_ami_name - AMI names can only contain certain characters. This function will replace illegal characters with a '-" character. Example usage since ":" is not a legal AMI name is: {{isotime | clean_ami_name}}.