terraform/website/source/docs/enterprise/packer/artifacts/creating-amis.html.md

58 lines
1.9 KiB
Markdown
Raw Normal View History

2017-03-21 23:01:58 +01:00
---
title: "Creating AMI Artifacts with Atlas"
---
# Creating AMI Artifacts with Atlas
In an [immutable infrastructure](/help/intro/use-cases/continuous-deployment-of-immutable-infrastructure)
workflow, it's important to version and store full images (artifacts)
to be deployed. This section covers storing [AWS AMI](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html)
images in Atlas to be queried and used later.
Note the actual AMI does _not get stored in Atlas_. Atlas
simply keeps the AMI ID as a reference to the target image. Tools
like Terraform can then use this in a deploy.
### Steps
If you run Packer in Atlas, the following will happen after a [push](/help/packer/builds/starting):
1. Atlas will run `packer build` against your template in our infrastructure.
This spins up an AWS instance in your account and provisions it with
any specified provisioners
1. Packer stops the instance and stores the result as an AMI in AWS
under your account. This then returns an ID (the artifact) that it passes to the Atlas post-processor
1. The Atlas post-processor creates and uploads the new artifact version with the
ID in Atlas of the type `amazon.image` for use later
### Example
Below is a complete example Packer template that starts an AWS instance.
{
"push": {
"name": "%{DEFAULT_USERNAME}/frontend"
},
"provisioners": [],
"builders": [
{
"type": "amazon-ebs",
"access_key": "",
"secret_key": "",
"region": "us-east-1",
"source_ami": "ami-2ccc7a44",
"instance_type": "c3.large",
"ssh_username": "ubuntu",
"ami_name": "Atlas Example {{ timestamp }}"
}
],
"post-processors": [
{
"type": "atlas",
"artifact": "%{DEFAULT_USERNAME}/web-server",
"artifact_type": "amazon.image"
}
]
}