Skip to content

Instantly share code, notes, and snippets.

View bensojona's full-sized avatar

Jon Benson bensojona

  • HashiCorp
  • San Francisco, CA
View GitHub Profile
provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "${var.region}"
}
resource "aws_security_group" "allow_all" {
name = "allow_all"
description = "Allow all inbound traffic"
resource "aws_instance" "consul" {
ami = "${var.ami}"
security_groups = ["${var.security_group}"]
key_name = "${var.key_name}"
instance_type = "${var.instance_type}"
availability_zone = "${var.availability_zone}"
count = "${var.count}"
tags {
Name = "consul_${count.index+1}"
aws_security_group.allow_all: Creating...
description: "" => "Allow all inbound traffic"
egress.#: "" => "<computed>"
ingress.#: "" => "1"
ingress.532441254.cidr_blocks.#: "" => "1"
ingress.532441254.cidr_blocks.0: "" => "0.0.0.0/0"
ingress.532441254.from_port: "" => "0"
ingress.532441254.protocol: "" => "-1"
ingress.532441254.security_groups.#: "" => "0"
ingress.532441254.self: "" => "0"
Refreshing Terraform state prior to plan...
aws_key_pair.consul: Refreshing state... (ID: consul-key)
aws_security_group.allow_all: Refreshing state... (ID: sg-54bdc030)
module.consul.aws_instance.consul.0: Refreshing state... (ID: i-8a47e177)
module.consul.aws_instance.consul.1: Refreshing state... (ID: i-bd46e040)
module.consul.aws_instance.consul.2: Refreshing state... (ID: i-3f46e0c2)
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
Do you really want to destroy?
Terraform will delete all your managed infrastructure.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
aws_security_group.allow_all: Refreshing state... (ID: sg-54bdc030)
aws_key_pair.consul: Refreshing state... (ID: consul-key)
module.consul.aws_instance.consul.0: Refreshing state... (ID: i-8a47e177)
module.consul.aws_instance.consul.1: Refreshing state... (ID: i-bd46e040)
@bensojona
bensojona / terraform_error.txt
Created April 13, 2015 07:59
Attempting to create an infrastructure that will use the local-exec provisioner to call a shell script that creates a key pair on the atlas_artifact resource creation. After key pair creation, there is an aws_key_pair resource that depends on this atlas_artifact that will use the newly created public key to create the AWS key pair to be later us…
aws_security_group.allow_all: Creating...
description: "" => "Allow all inbound traffic"
egress.#: "" => "<computed>"
ingress.#: "" => "1"
ingress.532441254.cidr_blocks.#: "" => "1"
ingress.532441254.cidr_blocks.0: "" => "0.0.0.0/0"
ingress.532441254.from_port: "" => "0"
ingress.532441254.protocol: "" => "-1"
ingress.532441254.security_groups.#: "" => "0"
ingress.532441254.self: "" => "0"
@bensojona
bensojona / main.tf
Created April 13, 2015 08:00
Main Terraform template
provider "atlas" {
token = "${var.atlas_token}"
}
provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "${var.region}"
}
@bensojona
bensojona / metamon_main.tf
Created April 13, 2015 08:01
Metamon module
resource "aws_instance" "metamon" {
ami = "${var.ami}"
security_groups = ["${var.security_group}"]
key_name = "${var.key_name}"
instance_type = "${var.instance_type}"
availability_zone = "${var.availability_zone}"
count = "${var.count}"
tags {
Name = "metamon_${count.index+1}"
@bensojona
bensojona / consul_main.tf
Created April 13, 2015 08:02
Consule module
resource "aws_instance" "consul" {
ami = "${var.ami}"
security_groups = ["${var.security_group}"]
key_name = "${var.key_name}"
instance_type = "${var.instance_type}"
availability_zone = "${var.availability_zone}"
count = "${var.count}"
tags {
Name = "consul_${count.index+1}"
if [ -s "ssh_keys/$1-key.pem" ] && [ -s "ssh_keys/$1-key.pub" ]; then
echo Using existing $1-key pair...
else
echo No $1-key pair exists, generating new keys...
rm -rf ssh_keys/$1-key.pem
rm -rf ssh_keys/$1-key.pub
openssl genrsa -out ssh_keys/$1-key.pem 1024
chmod 400 ssh_keys/$1-key.pem
ssh-keygen -y -f ssh_keys/$1-key.pem > ssh_keys/$1-key.pub
echo ssh_keys/$1-key.pem contents...