diff --git a/README.md b/README.md index de3007a4e..9a6fa37f3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Packer [![Build Status][circleci-badge]][circleci] -[![Windows Build Status][appveyor-badge]][appveyor] +[![Discuss](https://img.shields.io/badge/discuss-packer-3d89ff?style=flat)](https://discuss.hashicorp.com/c/packer) [![PkgGoDev](https://pkg.go.dev/badge/github.com/hashicorp/packer)](https://pkg.go.dev/github.com/hashicorp/packer) [![GoReportCard][report-badge]][report] [![codecov](https://codecov.io/gh/hashicorp/packer/branch/master/graph/badge.svg)](https://codecov.io/gh/hashicorp/packer) @@ -9,15 +9,16 @@ [circleci-badge]: https://circleci.com/gh/hashicorp/packer.svg?style=svg [circleci]: https://app.circleci.com/pipelines/github/hashicorp/packer [appveyor-badge]: https://ci.appveyor.com/api/projects/status/miavlgnp989e5obc/branch/master?svg=true -[appveyor]: https://ci.appveyor.com/project/hashicorp/packer [godoc-badge]: https://godoc.org/github.com/hashicorp/packer?status.svg -[godoc]: https://godoc.org/github.com/hashicorp/packer -[report-badge]: https://goreportcard.com/badge/github.com/hashicorp/packer +[godoc]: https://godoc.org/github.com/hashicorp/packer +[report-badge]: https://goreportcard.com/badge/github.com/hashicorp/packer [report]: https://goreportcard.com/report/github.com/hashicorp/packer -* Website: https://www.packer.io -* IRC: `#packer-tool` on Freenode -* Mailing list: [Google Groups](https://groups.google.com/forum/#!forum/packer-tool) +

+ + HashiCorp Packer logo + +

Packer is a tool for building identical machine images for multiple platforms from a single source configuration. @@ -47,33 +48,43 @@ yourself](https://github.com/hashicorp/packer/blob/master/.github/CONTRIBUTING.m After Packer is installed, create your first template, which tells Packer what platforms to build images for and how you want to build them. In our -case, we'll create a simple AMI that has Redis pre-installed. Save this -file as `quick-start.json`. Export your AWS credentials as the +case, we'll create a simple AMI that has Redis pre-installed. + +Save this file as `quick-start.pkr.hcl`. Export your AWS credentials as the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. -```json -{ - "variables": { - "access_key": "{{env `AWS_ACCESS_KEY_ID`}}", - "secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}" - }, - "builders": [{ - "type": "amazon-ebs", - "access_key": "{{user `access_key`}}", - "secret_key": "{{user `secret_key`}}", - "region": "us-east-1", - "source_ami": "ami-af22d9b9", - "instance_type": "t2.micro", - "ssh_username": "ubuntu", - "ami_name": "packer-example {{timestamp}}" - }] +```hcl +variable "access_key" { + type = string + default = "${env("AWS_ACCESS_KEY_ID")}" +} + +variable "secret_key" { + type = string + default = "${env("AWS_SECRET_ACCESS_KEY")}" +} + +locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") } + +source "amazon-ebs" "quick-start" { + access_key = "${var.access_key}" + ami_name = "packer-example ${local.timestamp}" + instance_type = "t2.micro" + region = "us-east-1" + secret_key = "${var.secret_key}" + source_ami = "ami-af22d9b9" + ssh_username = "ubuntu" +} + +build { + sources = ["source.amazon-ebs.quick-start"] } ``` Next, tell Packer to build the image: ``` -$ packer build quick-start.json +$ packer build quick-start.pkr.hcl ... ``` @@ -85,11 +96,9 @@ they're run, etc., is up to you. ## Documentation -Comprehensive documentation is viewable on the Packer website: - -https://www.packer.io/docs +Comprehensive documentation is viewable on the Packer website at https://www.packer.io/docs. -## Developing Packer +## Contributing to Packer See [CONTRIBUTING.md](https://github.com/hashicorp/packer/blob/master/.github/CONTRIBUTING.md)