From 98765f0de75712ddb74a2cc5c64307c4bb34ae5e Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Mon, 28 Jul 2014 11:11:23 -0400 Subject: [PATCH] website: best practices for aws example --- .../source/intro/examples/aws.html.markdown | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/website/source/intro/examples/aws.html.markdown b/website/source/intro/examples/aws.html.markdown index 245784250..64cce1be7 100644 --- a/website/source/intro/examples/aws.html.markdown +++ b/website/source/intro/examples/aws.html.markdown @@ -25,6 +25,29 @@ registers, this should respond with the default nginx web page. ## Configuration ``` +variable "aws_access_key" {} +variable "aws_secret_key" {} +variable "aws_region" { + default = "us-west-2" +} + +# Ubuntu Precise 12.04 LTS (x64) +variable "aws_amis" { + default = { + "eu-west-1": "ami-b1cf19c6", + "us-east-1": "ami-de7ab6b6", + "us-west-1": "ami-3f75767a", + "us-west-2": "ami-21f78e11" + } +} + +# Specify the provider and access details +provider "aws" { + access_key = "${var.aws_access_key}" + secret_key = "${var.aws_secret_key}" + region = "${var.aws_region}" +} + # Our default security group to access # the instances over SSH and HTTP resource "aws_security_group" "default" { @@ -80,8 +103,9 @@ resource "aws_instance" "web" { instance_type = "m1.small" - # ubuntu-precise-12.04-amd64-server - ami = "ami-4fccb37f" + # Loookup the correct AMI based on the region + # we specified + ami = "${lookup(var.aws_amis, var.aws_region)}" # The name of our SSH keypair you've created and downloaded # from the AWS console.