Skip to content

Instantly share code, notes, and snippets.

@RupGautam
Last active September 13, 2019 20:00
Show Gist options
  • Save RupGautam/9abf135b6c3e020ba19e79bea82de276 to your computer and use it in GitHub Desktop.
Save RupGautam/9abf135b6c3e020ba19e79bea82de276 to your computer and use it in GitHub Desktop.
AWS find latest ubuntu image and prep for nodejs app using packer
{
"builders": [{
"type": "amazon-ebs",
"region": "us-east-1",
"instance_type": "t2.micro",
"ena_support": true,
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},
"ssh_username": "ubuntu",
"ami_name": "api-instance {{timestamp}}"
}],
"provisioners": [
{
"type": "shell",
"inline": ["mkdir api", "sudo apt-get update", "sudo apt-get -y install npm nodejs"],
"pause_before": "10s"
},
{
"type": "file",
"source" : "files-from",
"destination" : "files-to"
},
{
"type": "shell",
"inline": ["cd api", "npm install"],
"pause_before": "10s"
}
]
}
{
"builders": [{
"type": "amazon-ebs",
"region": "us-east-1",
"instance_type": "t2.micro",
"ena_support": true,
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},
"ssh_username": "ubuntu",
"ami_name": "api-instance {{timestamp}}"
}],
"provisioners": [
{
"type": "shell",
"inline": ["mkdir web", "sudo apt-get update", "sudo apt-get -y install npm nodejs"],
"pause_before": "10s"
},
{
"type": "file",
"source" : "files-from",
"destination" : "files-to"
},
{
"type": "shell",
"inline": ["cd web", "npm install"],
"pause_before": "10s"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment