Skip to content

Instantly share code, notes, and snippets.

@mooyoul
Created December 29, 2016 16:18
Show Gist options
  • Save mooyoul/3622099b93a14fe660291fc6a86614a9 to your computer and use it in GitHub Desktop.
Save mooyoul/3622099b93a14fe660291fc6a86614a9 to your computer and use it in GitHub Desktop.
Terraform 101 - Output Variables
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.region}"
}
resource "aws_instance" "example" {
ami = "${lookup(var.amis, var.region)}"
instance_type = "t2.micro"
provisioner "local-exec" {
command = "echo ${aws_instance.example.public_ip} > ip_address.txt"
}
}
resource "aws_eip" "ip" {
instance = "${aws_instance.example.id}"
depends_on = ["aws_instance.example"]
}
output "ip" {
value = "${aws_eip.ip.public_ip}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment