From 9cabad470439a1f27742bc1b6c5cf24a078f933e Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Mon, 25 Nov 2013 13:27:38 +0100 Subject: [PATCH 1/4] website: move iam policy documentation to the root amazon page --- .../docs/builders/amazon-chroot.html.markdown | 37 ------------------- .../source/docs/builders/amazon.html.markdown | 37 +++++++++++++++++++ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/website/source/docs/builders/amazon-chroot.html.markdown b/website/source/docs/builders/amazon-chroot.html.markdown index 3ea0e456c..a1ef7a0ae 100644 --- a/website/source/docs/builders/amazon-chroot.html.markdown +++ b/website/source/docs/builders/amazon-chroot.html.markdown @@ -210,40 +210,3 @@ prevent packages installed by your provisioners from starting services: ] } - -## Using an IAM Instance Profile - -If AWS keys are not specified in the template or through environment variables -Packer will use credentials provided by the instance's IAM profile, if it has one. - -The following policy document provides the minimal set permissions necessary for Packer to work: - -
-{
-  "Statement": [{
-      "Effect": "Allow",
-      "Action" : [
-        "ec2:AttachVolume",
-        "ec2:CreateVolume",
-        "ec2:DeleteVolume",
-        "ec2:DescribeVolumes",
-        "ec2:DetachVolume",
-
-        "ec2:DescribeInstances",
-
-        "ec2:CreateSnapshot",
-        "ec2:DeleteSnapshot",
-        "ec2:DescribeSnapshots",
-
-        "ec2:DescribeImages",
-        "ec2:RegisterImage",
-
-        "ec2:CreateTags"
-      ],
-      "Resource" : "*"
-  }]
-}
-
- -Depending on what setting you use the following Actions might have to be allowed as well: -* `ec2:ModifyImageAttribute` when using `ami_description` diff --git a/website/source/docs/builders/amazon.html.markdown b/website/source/docs/builders/amazon.html.markdown index 604f2489a..e4e15f886 100644 --- a/website/source/docs/builders/amazon.html.markdown +++ b/website/source/docs/builders/amazon.html.markdown @@ -30,3 +30,40 @@ AMI. Packer supports the following builders at the moment: amazon-ebs builder. It is much easier to use and Amazon generally recommends EBS-backed images nowadays. + +## Using an IAM Instance Profile + +If AWS keys are not specified in the template or through environment variables +Packer will use credentials provided by the instance's IAM profile, if it has one. + +The following policy document provides the minimal set permissions necessary for Packer to work: + +
+{
+  "Statement": [{
+      "Effect": "Allow",
+      "Action" : [
+        "ec2:AttachVolume",
+        "ec2:CreateVolume",
+        "ec2:DeleteVolume",
+        "ec2:DescribeVolumes",
+        "ec2:DetachVolume",
+
+        "ec2:DescribeInstances",
+
+        "ec2:CreateSnapshot",
+        "ec2:DeleteSnapshot",
+        "ec2:DescribeSnapshots",
+
+        "ec2:DescribeImages",
+        "ec2:RegisterImage",
+
+        "ec2:CreateTags"
+      ],
+      "Resource" : "*"
+  }]
+}
+
+ +Depending on what setting you use the following Actions might have to be allowed as well: +* `ec2:ModifyImageAttribute` when using `ami_description` From 5c1f9e4cd3ecfa650f2d6cb2aaa57a89b576f632 Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Mon, 25 Nov 2013 13:36:32 +0100 Subject: [PATCH 2/4] website: use user variables in the intro (ec2) --- .../getting-started/build-image.html.markdown | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/website/source/intro/getting-started/build-image.html.markdown b/website/source/intro/getting-started/build-image.html.markdown index 7e91de208..e37f56664 100644 --- a/website/source/intro/getting-started/build-image.html.markdown +++ b/website/source/intro/getting-started/build-image.html.markdown @@ -46,10 +46,14 @@ briefly. Create a file `example.json` and fill it with the following contents:
 {
+  "variables": {
+    "aws_access_key": "",
+    "aws_secret_key": ""
+  },
   "builders": [{
     "type": "amazon-ebs",
-    "access_key": "YOUR KEY HERE",
-    "secret_key": "YOUR SECRET KEY HERE",
+    "access_key": "{{user `aws_access_key`}}",
+    "secret_key": "{{user `aws_secret_key`}}",
     "region": "us-east-1",
     "source_ami": "ami-de0d9eb7",
     "instance_type": "t1.micro",
@@ -59,9 +63,11 @@ briefly. Create a file `example.json` and fill it with the following contents:
 }
 
-Please fill in the `access_key` and `secret_key` with the proper values -for your account. Your security credentials can be found on -[this page](https://console.aws.amazon.com/iam/home?#security_credential). +When building, you'll pass in the `aws_access_key` and `aws_access_key` as +a [user variable](/docs/templates/user-variables.html), keeping your secret +keys out of the template. You can create security credentials +on [this page](https://console.aws.amazon.com/iam/home?#security_credential). +An example IAM policy document can be found in the [Amazon EC2 builder docs](/docs/builders/amazon.html). This is a basic template that is ready-to-go. It should be immediately recognizable as a normal, basic JSON object. Within the object, the `builders` section @@ -106,7 +112,10 @@ should look similar to below. Note that this process typically takes a few minutes. ``` -$ packer build example.json +$ packer build \ + -var 'aws_access_key=YOUR ACCESS KEY' \ + -var 'aws_secret_key=YOUR SECRET KEY' \ + example.json ==> amazon-ebs: amazon-ebs output will be in this color. ==> amazon-ebs: Creating temporary keypair for this instance... From 2da4af816641d9c33351b7a3583747ee3ba92cc2 Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Mon, 25 Nov 2013 13:47:23 +0100 Subject: [PATCH 3/4] website: user user varibles in the intro (parallel builds) --- .../parallel-builds.html.markdown | 27 ++++++++++++++----- .../getting-started/provision.html.markdown | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/website/source/intro/getting-started/parallel-builds.html.markdown b/website/source/intro/getting-started/parallel-builds.html.markdown index 2a5b422f8..c53dfd249 100644 --- a/website/source/intro/getting-started/parallel-builds.html.markdown +++ b/website/source/intro/getting-started/parallel-builds.html.markdown @@ -63,13 +63,23 @@ array.
 {
   "type": "digitalocean",
-  "api_key": "INSERT API KEY HERE",
-  "client_id": "INSERT CLIENT ID HERE"
+  "api_key": "{{user `do_api_key`}}",
+  "client_id": "{{user `do_client_id`}}"
 }
 
-Fill in your `api_key` and `client_id` for DigitalOcean as necessary. -The entire template should now [look like this](https://gist.github.com/mitchellh/51a447e38e7e496eb29c). +You'll also need to modify the `variables` section of the template +to include the access keys for DigitalOcean. + +
+"variables": {
+  ...
+  "do_api_key": "",
+  "do_client_id": ""
+}
+
+ +The entire template should now [look like this](https://gist.github.com/pearkes/cc5f8505eee5403a43a6). Additional builders are simply added to the `builders` array in the template. This tells Packer to build multiple images. The builder `type` values don't @@ -87,13 +97,18 @@ manual that contains a listing of all the available configuration options. ## Build -Now run `packer build example.json`. The output is too verbose to include +Now run `packer build` with your user variables. The output is too verbose to include all of it, but a portion of it is reproduced below. Note that the ordering and wording of the lines may be slightly different, but the effect is the same. ``` -$ packer build example.json +$ packer build \ + -var 'aws_access_key=YOUR ACCESS KEY' \ + -var 'aws_secret_key=YOUR SECRET KEY' \ + -var 'do_api_key=YOUR API KEY' \ + -var 'do_client_id=YOUR CLIENT ID' \ + example.json ==> amazon-ebs: amazon-ebs output will be in this color. ==> digitalocean: digitalocean output will be in this color. diff --git a/website/source/intro/getting-started/provision.html.markdown b/website/source/intro/getting-started/provision.html.markdown index fa6016744..4276ae089 100644 --- a/website/source/intro/getting-started/provision.html.markdown +++ b/website/source/intro/getting-started/provision.html.markdown @@ -37,6 +37,7 @@ block below.
 {
+  "variables": [...],
   "builders": [...],
 
   "provisioners": [{

From 3591e35617dad1f352d8eb99ad1977979c5afe79 Mon Sep 17 00:00:00 2001
From: Jack Pearkes 
Date: Mon, 25 Nov 2013 13:51:32 +0100
Subject: [PATCH 4/4] website: prettyprint variables examle in parallel builds

---
 .../source/intro/getting-started/parallel-builds.html.markdown  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/website/source/intro/getting-started/parallel-builds.html.markdown b/website/source/intro/getting-started/parallel-builds.html.markdown
index c53dfd249..e51311214 100644
--- a/website/source/intro/getting-started/parallel-builds.html.markdown
+++ b/website/source/intro/getting-started/parallel-builds.html.markdown
@@ -71,7 +71,7 @@ array.
 You'll also need to modify the `variables` section of the template
 to include the access keys for DigitalOcean.
 
-
+
 "variables": {
   ...
   "do_api_key": "",