This repo is a customized version from the Hashicorp official module vault-consul-ami from this Module and the install-consul and install-dnsmasq modules from the Consul AWS Module with Packer to create Amazon Machine Images (AMIs) that have Vault and Consul installed on top of:
- Ubuntu 16.04
- Amazon Linux
You can use this AMI to deploy a Vault cluster by using the vault-cluster module. This Vault cluster will use Consul as its storage backend, so you can also use the same AMI to deploy a separate Consul server cluster by using the consul-cluster module.
-
git clone
this repo to your computer. -
Install Packer.
-
Configure your AWS credentials using one of the options supported by the AWS SDK. Usually, the easiest option is to set the
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
environment variables.export AWS_ACCESS_KEY_ID = "" export AWS_SECRET_ACCESS_KEY = ""
mkdir $HOME/.aws echo "[default] aws_access_key_id= aws_secret_access_key= " >> $HOME/.aws/credentials
if you are using multiple AWS Profiles, make sure you create your AMIs in the desired one using the following env variables, otherwise they will be created in the default profile:
export AWS_PROFILE=profilename export AWS_DEFAULT_PROFILE=profilename
-
In this repo we are using the TLS certificates that come with the official template due to this is only for demo purposes. If you are planning to use it in a production environment or another managing sensitive data, you must use the private-tls-cert module TLS cert:
-
Update the
variables
section of thevault-consul-ami.json
Packer template to specify the: AWS region Vault version Consul version Paths to the TLS cert files you just generated. If you want to install Consul Enterprise, Vault Enterprise or obtain the files from a specific location no matter if Enterprise or not, skip the version variables and instead set theconsul_download_url
andvault_download_url
to the full urls that point to the respective enterprise zipped packages or your on-premises location.
Example:
export VAULT_DOWNLOAD_URL="https://releases.hashicorp.com/vault/0.11.5/vault_0.11.5_linux_amd64.zip"
export CONSUL_DOWNLOAD_URL="https://releases.hashicorp.com/consul/1.3.1/consul_1.3.1_linux_amd64.zip"
- Run
packer build vault-consul.json
.