packer-cn/website/source/docs/templates/configuration-templates.html.markdown
David Zanetti 3c1013f098 Docs: Examples of templates need more assistance about AMI IDs
* Several places where AMI IDs are used now have more explanation about
   where to find information about them, or links to the builder docs
 * IDs present in examples have not been changed to valid ones, since
   this would be an on-going problem to maintain a current valid ID
 * See github.com issue #3132

Signed-off-by: David Zanetti <dave2@wetstring.net>
2016-02-17 10:49:38 +13:00

4.9 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

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-72b9e018",
      "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}}.