Skip to content

Instantly share code, notes, and snippets.

@hvalls
Last active August 9, 2018 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hvalls/200723bcf3992df907f803f8c4193531 to your computer and use it in GitHub Desktop.
Save hvalls/200723bcf3992df907f803f8c4193531 to your computer and use it in GitHub Desktop.
Terraform Configuration: Hashicorp Vault dev server on AWS EC2 instance
[Unit]
Description=Vault dev server
[Service]
Type=simple
ExecStart=/home/ec2-user/vault server -dev -dev-listen-address=0.0.0.0:8200
resource "aws_instance" "vault" {
ami = "ami-466768ac"
instance_type = "t2.micro"
key_name = "vault_instance_keypair"
tags {
Name = "Vault"
}
provisioner "file" {
connection {
type = "ssh"
agent = false
user = "ec2-user"
private_key = "${file("/path/to/key.pem")}"
timeout = "10m"
}
source = "./vault.service"
destination = "/home/ec2-user/vault.service"
}
provisioner "remote-exec" {
connection {
type = "ssh"
agent = false
user = "ec2-user"
private_key = "${file("/path/to/key.pem")}"
timeout = "10m"
}
inline = [
"curl -O https://releases.hashicorp.com/vault/0.10.4/vault_0.10.4_linux_amd64.zip",
"unzip vault_0.10.4_linux_amd64.zip",
"sudo mv /home/ec2-user/vault.service /etc/systemd/system/",
"sudo systemctl start vault.service"
]
}
}
output "ip" {
value = "${aws_instance.vault.public_ip}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment