From d7e77202baf1d54281285fe4e3de0f04719e53d4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 13 Oct 2014 12:14:56 -0700 Subject: [PATCH] website: started updating examples --- .../source/intro/examples/aws.html.markdown | 42 +++++++------------ .../source/intro/examples/index.html.markdown | 9 ++-- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/website/source/intro/examples/aws.html.markdown b/website/source/intro/examples/aws.html.markdown index 272362f8c..83928ab18 100644 --- a/website/source/intro/examples/aws.html.markdown +++ b/website/source/intro/examples/aws.html.markdown @@ -9,7 +9,7 @@ sidebar_current: "examples-aws" This provides a template for running a simple two-tier architecture on Amazon Web services. -The basic premise is you have stateless app servers running behind +The premise is that you have stateless app servers running behind an ELB serving traffic. To simplify the example, this intentionally ignores deploying and @@ -22,26 +22,14 @@ After you run `terraform apply` on this configuration, it will automatically output the DNS address of the ELB. After your instance registers, this should respond with the default nginx web page. -The configuration file contains comments describing each -resource. - -## Command - -``` - terraform apply \ - -var 'aws_access_key=YOUR_ACCESS_KEY' \ - -var 'aws_secret_key=YOUR_SECRET_KEY' \ - -var 'key_path=/path/to/key/pair.pem' \ - -var 'key_name=keypair-name' -``` +As with all examples, just copy and paste the example and run +`terraform apply` to see it work. ## Configuration ``` -variable "aws_access_key" {} -variable "aws_secret_key" {} -variable "key_path" {} variable "key_name" {} +variable "key_path" {} variable "aws_region" { default = "us-west-2" } @@ -58,8 +46,6 @@ variable "aws_amis" { # Specify the provider and access details provider "aws" { - access_key = "${var.aws_access_key}" - secret_key = "${var.aws_secret_key}" region = "${var.aws_region}" } @@ -106,16 +92,6 @@ resource "aws_elb" "web" { resource "aws_instance" "web" { - # The connection block tells our provisioner how to - # communicate with the resource (instance) - connection { - # The default username for our AMI - user = "ubuntu" - - # The path to your keyfile - key_file = "${var.key_path}" - } - instance_type = "m1.small" # Lookup the correct AMI based on the region @@ -132,6 +108,16 @@ resource "aws_instance" "web" { # Our Security group to allow HTTP and SSH access security_groups = ["${aws_security_group.default.name}"] + # The connection block tells our provisioner how to + # communicate with the resource (instance) + connection { + # The default username for our AMI + user = "ubuntu" + + # The path to your keyfile + key_file = "${var.key_path}" + } + # We run a remote provisioner on the instance after creating it. # In this case, we just install nginx and start it. By default, # this should be on port 80 diff --git a/website/source/intro/examples/index.html.markdown b/website/source/intro/examples/index.html.markdown index aaf837e63..76753c1d2 100644 --- a/website/source/intro/examples/index.html.markdown +++ b/website/source/intro/examples/index.html.markdown @@ -9,14 +9,15 @@ sidebar_current: "examples" These examples are designed to help you understand some of the ways Terraform can be used. -Other than configuring the provider (with, for example, an API key), -the examples are ready to run as-is. - +All examples in this section are ready to run as-is. Terraform will +ask for input of things such as variables and API keys. If you want to +conitnue using the example, you should save those parameters in a +"terraform.tfvars" file or in a `provider` config bock.
Note: The examples use real providers that launch -real resources. That means they can cost money to +real resources. That means they can cost money to experiment with. To avoid unexpected charges, be sure to understand the price of resources before launching them, and verify any unneeded resources are cleaned up afterwards.