Skip to content

Instantly share code, notes, and snippets.

@kikitux
Created November 9, 2014 23:39
Show Gist options
  • Save kikitux/4430a102d4a30a7c17c5 to your computer and use it in GitHub Desktop.
Save kikitux/4430a102d4a30a7c17c5 to your computer and use it in GitHub Desktop.
{
"variables": {
"aws_access_key": "",
"aws_secret_key": ""
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "ap-southeast-2",
"source_ami": "ami-1f117325",
"instance_type": "t1.micro",
"ssh_username": "ubuntu",
"ami_name": "packer-{{timestamp}}"
}
],
"provisioners": [
{
"type": "shell",
"only": ["amazon-ebs"],
"inline": ["mkdir -p /home/ubuntu/.ssh/"]
},
{
"type": "file",
"only": ["amazon-ebs"],
"source": "/Users/kikitux/.ssh/id_rsa.pub",
"destination": "/home/ubuntu/.ssh/authorized_keys"
},
{
"type": "shell",
"only": ["amazon-ebs"],
"inline": ["sudo chmod -R 0600 /home/ubuntu/.ssh/; sudo chmod 0700 /home/ubuntu/.ssh/"]
}
]
}
amazon-ebs output will be in this color.
==> amazon-ebs: Inspecting the source AMI...
==> amazon-ebs: Creating temporary keypair: packer 545ff0f5-9174-6895-327d-44be0be1f424
==> amazon-ebs: Creating temporary security group for this instance...
==> amazon-ebs: Authorizing SSH access on the temporary security group...
==> amazon-ebs: Launching a source AWS instance...
 amazon-ebs: Instance ID: i-1bfe75d4
==> amazon-ebs: Waiting for instance (i-1bfe75d4) to become ready...
==> amazon-ebs: Waiting for SSH to become available...
==> amazon-ebs: Connected to SSH!
==> amazon-ebs: Provisioning with shell script: /var/folders/zg/dw2mgnh135l9976wfs62tsmh0000gp/T/packer-shell985537322
 amazon-ebs:
 amazon-ebs:
 amazon-ebs:
 amazon-ebs:
 amazon-ebs:
 amazon-ebs:
 amazon-ebs:
==> amazon-ebs: Uploading /Users/kikitux/.ssh/id_rsa.pub => /home/ubuntu/.ssh/authorized_keys
==> amazon-ebs: Provisioning with shell script: /var/folders/zg/dw2mgnh135l9976wfs62tsmh0000gp/T/packer-shell246848067
==> amazon-ebs: Stopping the source instance...
==> amazon-ebs: Waiting for the instance to stop...
==> amazon-ebs: Creating the AMI: packer-1415573748
 amazon-ebs: AMI: ami-9d81eea7
==> amazon-ebs: Waiting for AMI to become ready...
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: Deleting temporary security group...
==> amazon-ebs: Deleting temporary keypair...
Build 'amazon-ebs' finished.
==> Builds finished. The artifacts of successful builds are:
--> amazon-ebs: AMIs were created:
ap-southeast-2: ami-9d81eea7
{
"variables": {
"aws_access_key": "",
"aws_secret_key": "",
"ssh_private_key_file": "/Users/kikitux/.ssh/id_rsa"
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "ap-southeast-2",
"ssh_private_key_file": "{{user `ssh_private_key_file`}}",
"source_ami": "ami-9d81eea7",
"instance_type": "t1.micro",
"ssh_username": "ubuntu",
"ami_name": "packer-{{timestamp}}"
}
],
"provisioners": [
{
"type": "shell",
"only": ["amazon-ebs"],
"inline": ["touch second base"]
}
]
}
amazon-ebs output will be in this color.
==> amazon-ebs: Inspecting the source AMI...
==> amazon-ebs: Creating temporary security group for this instance...
==> amazon-ebs: Authorizing SSH access on the temporary security group...
==> amazon-ebs: Launching a source AWS instance...
 amazon-ebs: Instance ID: i-7dfc77b2
==> amazon-ebs: Waiting for instance (i-7dfc77b2) to become ready...
==> amazon-ebs: Waiting for SSH to become available...
==> amazon-ebs: Connected to SSH!
==> amazon-ebs: Provisioning with shell script: /var/folders/zg/dw2mgnh135l9976wfs62tsmh0000gp/T/packer-shell241255542
==> amazon-ebs: Stopping the source instance...
==> amazon-ebs: Waiting for the instance to stop...
==> amazon-ebs: Creating the AMI: packer-1415574159
 amazon-ebs: AMI: ami-db81eee1
==> amazon-ebs: Waiting for AMI to become ready...
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: Deleting temporary security group...
Build 'amazon-ebs' finished.
==> Builds finished. The artifacts of successful builds are:
--> amazon-ebs: AMIs were created:
ap-southeast-2: ami-db81eee1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment