diff --git a/ntools/one-m/aws/amis.tf b/ntools/one-m/aws/amis.tf index fd2d36b8..1e3910cc 100644 --- a/ntools/one-m/aws/amis.tf +++ b/ntools/one-m/aws/amis.tf @@ -1,3 +1,7 @@ +# Each AWS region has a different AMI name +# even though the contents are the same. +# This file has the mapping from region --> AMI name. +# # These are all Ubuntu 14.04 LTS AMIs # with Arch = amd64, Instance Type = hvm:ebs-ssd # from https://cloud-images.ubuntu.com/locator/ec2/ diff --git a/ntools/one-m/aws/outputs.tf b/ntools/one-m/aws/outputs.tf new file mode 100644 index 00000000..4124df09 --- /dev/null +++ b/ntools/one-m/aws/outputs.tf @@ -0,0 +1,6 @@ +# You can get the value of "ip_address" after running terraform apply using: +# $ terraform output ip_address +# You could use that in a script, for example +output "ip_address" { + value = "${aws_eip.ip.public_ip}" +} diff --git a/ntools/one-m/aws/providers.tf b/ntools/one-m/aws/providers.tf new file mode 100644 index 00000000..a5426feb --- /dev/null +++ b/ntools/one-m/aws/providers.tf @@ -0,0 +1,6 @@ +provider "aws" { + # An AWS access_key and secret_key are needed; Terraform looks + # for an AWS credentials file in the default location. + # See https://tinyurl.com/pu8gd9h + region = "${var.aws_region}" +} diff --git a/ntools/one-m/aws/main.tf b/ntools/one-m/aws/resources.tf similarity index 77% rename from ntools/one-m/aws/main.tf rename to ntools/one-m/aws/resources.tf index 8e2a7ea0..1f3b352a 100644 --- a/ntools/one-m/aws/main.tf +++ b/ntools/one-m/aws/resources.tf @@ -1,10 +1,4 @@ -provider "aws" { - # An AWS access_key and secret_key are needed; Terraform looks - # for an AWS credentials file in the default location. - # See https://tinyurl.com/pu8gd9h - region = "${var.aws_region}" -} - +# One instance (virtual machine) on AWS: # https://www.terraform.io/docs/providers/aws/r/instance.html resource "aws_instance" "instance" { ami = "${lookup(var.amis, var.aws_region)}" @@ -43,6 +37,7 @@ resource "aws_eip" "ip" { vpc = true } +# This attaches the instance to the EBS volume for RethinkDB storage # https://www.terraform.io/docs/providers/aws/r/volume_attachment.html resource "aws_volume_attachment" "ebs_att" { # Why /dev/sdp? See https://tinyurl.com/z2zqm6n @@ -50,10 +45,3 @@ resource "aws_volume_attachment" "ebs_att" { volume_id = "${aws_ebs_volume.db_storage.id}" instance_id = "${aws_instance.instance.id}" } - -# You can get the value of "ip_address" after running terraform apply using: -# $ terraform output ip_address -# You could use that in a script, for example -output "ip_address" { - value = "${aws_eip.ip.public_ip}" -}