Skip to content

Instantly share code, notes, and snippets.

@pporada-gl
Created September 23, 2016 18:26
Show Gist options
  • Save pporada-gl/d85789230657777636e9d9e39d549e4a to your computer and use it in GitHub Desktop.
Save pporada-gl/d85789230657777636e9d9e39d549e4a to your computer and use it in GitHub Desktop.
{
"builders": [
{
"access_key": "{{user `var_aws_access_key`}}",
"ami_description": "My new AMI",
"ami_name": "CentOS 7 x86_64 Base {{timestamp}}",
"associate_public_ip_address": true,
"enhanced_networking": true,
"instance_type": "{{user `var_aws_instance_type`}}",
"region": "{{user `var_aws_region`}}",
"secret_key": "{{user `var_aws_secret_key`}}",
"source_ami": "{{user `var_aws_source_ami`}}",
"ssh_private_ip": false,
"ssh_pty": true,
"ssh_username": "{{user `var_ssh_username`}}",
"subnet_id": "{{user `var_aws_subnet_id`}}",
"tags": {
"Built": "{{isotime \"01-02-2006\"}}",
"Name": "{{user `var_atlas_buildname`}}",
"OS_Family": "RedHat",
"OS_Version": "CentOS",
"Release": "7"
},
"type": "amazon-ebs",
"vpc_id": "{{user `var_aws_vpc_id`}}"
}
],
"description": "My New AMI",
"min_packer_version": "0.10.2",
"post-processors": [
{
"artifact": "{{user `var_atlas_username`}}/{{user `var_atlas_buildname`}}",
"artifact_type": "amazon.image",
"metadata": {
"created_at": "{{timestamp}}"
},
"only": [
"amazon-ebs"
],
"token": "{{user `var_atlas_token`}}",
"type": "atlas"
}
],
"provisioners": [
{
"inline": [
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done"
],
"type": "shell"
},
{
"execute_command": "sudo -E -S sh '{{ .Path }}'",
"scripts": [
"scripts/install_packages.sh",
"scripts/install_packages.sh"
],
"type": "shell"
}
],
"push": {
"name": "{{user `var_atlas_username`}}/{{user `var_atlas_buildname`}}",
"vcs": false
},
"variables": {
"var_atlas_buildname": "my-new-ami",
"var_atlas_token": "{{env `ATLAS_TOKEN`}}",
"var_atlas_username": "{{env `ATLAS_USERNAME`}}",
"var_aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"var_aws_instance_type": "t2.micro",
"var_aws_region": "us-east-1",
"var_aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"var_aws_source_ami": "XXXXXXXXXXXXXXXX",
"var_aws_subnet_id": "XXXXXXXXXXXXXXX",
"var_aws_vpc_id": "XXXXXXXXXXXXXXXX",
"var_ssh_username": "XXXXXXXXXXXXXX"
}
}
############################
$ cat scripts/install_packages.sh
#!/bin/bash
set -o pipefail
set -x
echo "+) Updating system packages"
yum makecache
yum update -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment