Skip to content

Commit

Permalink
Merge pull request #3129 from berendt/example_unify_syntax
Browse files Browse the repository at this point in the history
examples: unify the configuration file syntax
  • Loading branch information
radeksimko committed Aug 31, 2015
2 parents d688c3b + 6e92813 commit 7d14213
Show file tree
Hide file tree
Showing 26 changed files with 379 additions and 382 deletions.
70 changes: 35 additions & 35 deletions examples/aws-asg/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Specify the provider and access details
provider "aws" {
region = "${var.aws_region}"
region = "${var.aws_region}"
}

resource "aws_elb" "web-elb" {
Expand Down Expand Up @@ -36,49 +36,49 @@ resource "aws_autoscaling_group" "web-asg" {
load_balancers = ["${aws_elb.web-elb.name}"]
#vpc_zone_identifier = ["${split(",", var.availability_zones)}"]
tag {
key = "Name"
value = "web-asg"
propagate_at_launch = "true"
}
key = "Name"
value = "web-asg"
propagate_at_launch = "true"
}
}

resource "aws_launch_configuration" "web-lc" {
name = "terraform-example-lc"
image_id = "${lookup(var.aws_amis, var.aws_region)}"
instance_type = "${var.instance_type}"
# Security group
security_groups = ["${aws_security_group.default.name}"]
user_data = "${file("userdata.sh")}"
key_name = "${var.key_name}"
name = "terraform-example-lc"
image_id = "${lookup(var.aws_amis, var.aws_region)}"
instance_type = "${var.instance_type}"
# Security group
security_groups = ["${aws_security_group.default.name}"]
user_data = "${file("userdata.sh")}"
key_name = "${var.key_name}"
}

# Our default security group to access
# the instances over SSH and HTTP
resource "aws_security_group" "default" {
name = "terraform_example_sg"
description = "Used in the terraform"
name = "terraform_example_sg"
description = "Used in the terraform"

# SSH access from anywhere
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# SSH access from anywhere
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

# HTTP access from anywhere
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# HTTP access from anywhere
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

# outbound internet access
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
# outbound internet access
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
10 changes: 5 additions & 5 deletions examples/aws-asg/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
output "security_group" {
value = "${aws_security_group.default.id}"
value = "${aws_security_group.default.id}"
}
output "launch_configuration" {
value = "${aws_launch_configuration.web-lc.id}"
value = "${aws_launch_configuration.web-lc.id}"
}
output "asg_name" {
value = "${aws_autoscaling_group.web-asg.id}"
value = "${aws_autoscaling_group.web-asg.id}"
}
output "elb_name" {
value = "${aws_elb.web-elb.dns_name}"
}
value = "${aws_elb.web-elb.dns_name}"
}
34 changes: 17 additions & 17 deletions examples/aws-asg/variables.tf
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
variable "aws_region" {
description = "The AWS region to create things in."
default = "us-east-1"
description = "The AWS region to create things in."
default = "us-east-1"
}

# ubuntu-trusty-14.04 (x64)
variable "aws_amis" {
default = {
"us-east-1" = "ami-5f709f34"
"us-west-2" = "ami-7f675e4f"
}
default = {
"us-east-1" = "ami-5f709f34"
"us-west-2" = "ami-7f675e4f"
}
}

variable "availability_zones" {
default = "us-east-1b,us-east-1c,us-east-1d,us-east-1e"
description = "List of availability zones, use AWS CLI to find your "
default = "us-east-1b,us-east-1c,us-east-1d,us-east-1e"
description = "List of availability zones, use AWS CLI to find your "
}

variable "key_name" {
description = "Name of AWS key pair"
description = "Name of AWS key pair"
}

variable "instance_type" {
default = "t2.micro"
description = "AWS instance type"
default = "t2.micro"
description = "AWS instance type"
}

variable "asg_min" {
description = "Min numbers of servers in ASG"
default = "1"
description = "Min numbers of servers in ASG"
default = "1"
}

variable "asg_max" {
description = "Max numbers of servers in ASG"
default = "2"
description = "Max numbers of servers in ASG"
default = "2"
}

variable "asg_desired" {
description = "Desired numbers of servers in ASG"
default = "1"
description = "Desired numbers of servers in ASG"
default = "1"
}

2 changes: 1 addition & 1 deletion examples/aws-count/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Specify the provider and access details
provider "aws" {
region = "${var.aws_region}"
region = "${var.aws_region}"
}

resource "aws_elb" "web" {
Expand Down
16 changes: 8 additions & 8 deletions examples/aws-count/variables.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
variable "aws_region" {
description = "The AWS region to create things in."
default = "us-west-2"
description = "The AWS region to create things in."
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"
}
default = {
"eu-west-1" = "ami-b1cf19c6"
"us-east-1" = "ami-de7ab6b6"
"us-west-1" = "ami-3f75767a"
"us-west-2" = "ami-21f78e11"
}
}
59 changes: 29 additions & 30 deletions examples/aws-eip/main.tf
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
# Specify the provider and access details
provider "aws" {
region = "${var.aws_region}"
region = "${var.aws_region}"
}

resource "aws_eip" "default" {
instance = "${aws_instance.web.id}"
vpc = true
instance = "${aws_instance.web.id}"
vpc = true
}

# Our default security group to access
# the instances over SSH and HTTP
resource "aws_security_group" "default" {
name = "eip_example"
description = "Used in the terraform"
name = "eip_example"
description = "Used in the terraform"

# SSH access from anywhere
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# SSH access from anywhere
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

# HTTP access from anywhere
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# HTTP access from anywhere
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

# outbound internet access
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
# outbound internet access
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}


Expand All @@ -62,8 +62,7 @@ resource "aws_instance" "web" {
# this should be on port 80
user_data = "${file("userdata.sh")}"
#Instance tags
tags {
Name = "eip-example"
}
tags {
Name = "eip-example"
}
}

14 changes: 7 additions & 7 deletions examples/aws-eip/variables.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
variable "aws_region" {
description = "The AWS region to create things in."
default = "us-east-1"
description = "The AWS region to create things in."
default = "us-east-1"
}

# ubuntu-trusty-14.04 (x64)
variable "aws_amis" {
default = {
"us-east-1" = "ami-5f709f34"
"us-west-2" = "ami-7f675e4f"
}
default = {
"us-east-1" = "ami-5f709f34"
"us-west-2" = "ami-7f675e4f"
}
}

variable "key_name" {
description = "Name of the SSH keypair to use in AWS."
description = "Name of the SSH keypair to use in AWS."
}

Loading

0 comments on commit 7d14213

Please sign in to comment.