Created
April 27, 2016 12:16
-
-
Save mryoshio/06be4f9b45c88510bdeda7c0599d3a80 to your computer and use it in GitHub Desktop.
Terraform Sample Configuration
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
# | |
# aws | |
# | |
# declare variables | |
variable "aws_access_key" {} | |
variable "aws_secret_access_key" {} | |
# connection | |
provider "aws" { | |
access_key = "${var.aws_access_key}" | |
secret_key = "${var.aws_secret_access_key}" | |
region = "ap-northeast-1" | |
} | |
# resources from here | |
resource "aws_vpc" "sample" { | |
cidr_block = "10.10.0.0/16" | |
instance_tenancy = "default" | |
enable_dns_support = "true" | |
enable_dns_hostnames = "false" | |
tags { | |
Name = "sample" | |
} | |
} | |
resource "aws_internet_gateway" "sample" { | |
vpc_id = "${aws_vpc.sample.id}" | |
tags { | |
Name = "sample" | |
} | |
} | |
resource "aws_eip" "sample" { | |
instance = "${aws_instance.sample.id}" | |
vpc = true | |
} | |
resource "aws_subnet" "sample" { | |
vpc_id = "${aws_vpc.sample.id}" | |
cidr_block = "10.10.1.0/24" | |
tags { | |
Name = "sample" | |
} | |
} | |
resource "aws_instance" "sample" { | |
ami = "ami-f80e0596" | |
instance_type = "t2.micro" | |
tags { | |
Name = "sample" | |
} | |
subnet_id = "${aws_subnet.sample.id}" | |
vpc_security_group_ids = ["${aws_vpc.sample.default_security_group_id}"] | |
depends_on = ["aws_internet_gateway.sample"] | |
} | |
output "address" { | |
value = "${aws_eip.sample.public_ip}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment