Created
April 15, 2015 14:28
-
-
Save phinze/2f1d347d9a59e06d7fdb to your computer and use it in GitHub Desktop.
Terraform Example: injecting config into an AWS instance
This file contains hidden or 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
variable "instance_type" { | |
default = "t2.micro" | |
} | |
variable "region" { | |
default = "us-west-2" | |
} | |
variable "custom" { | |
default = "env-specific-value" | |
} | |
module "ami" { | |
source = "github.com/terraform-community-modules/tf_aws_ubuntu_ami/ebs" | |
region = "${var.region}" | |
distribution = "trusty" | |
instance_type = "${var.instance_type}" | |
} | |
resource "aws_instance" "web" { | |
ami = "${module.ami.ami_id}" | |
instance_type = "${var.instance_type}" | |
key_name = "tftest" | |
connection { | |
user = "ubuntu" | |
agent = true | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"echo ${self.public_ip} | sudo tee /var/run/public_ip", | |
"echo ${var.custom} | sudo tee /var/run/custom" | |
] | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment