Skip to content

Instantly share code, notes, and snippets.

@mooyoul
Created December 27, 2016 17:40
Show Gist options
  • Save mooyoul/12fa08f71c06078eb6ccbeae300ef90f to your computer and use it in GitHub Desktop.
Save mooyoul/12fa08f71c06078eb6ccbeae300ef90f to your computer and use it in GitHub Desktop.
Terraform 101 - Provision
provider "aws" {
access_key = "ACCESS_KEY_HERE"
secret_key = "SECRET_KEY_HERE"
region = "ap-northeast-2"
}
resource "aws_instance" "example" {
ami = "ami-983ce8f6"
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"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment