Last active
August 9, 2018 07:04
-
-
Save hvalls/200723bcf3992df907f803f8c4193531 to your computer and use it in GitHub Desktop.
Terraform Configuration: Hashicorp Vault dev server on AWS EC2 instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Vault dev server | |
[Service] | |
Type=simple | |
ExecStart=/home/ec2-user/vault server -dev -dev-listen-address=0.0.0.0:8200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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