Last active
August 29, 2015 14:08
-
-
Save gosuri/563070be0392a3d07431 to your computer and use it in GitHub Desktop.
aws demo terraform template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "aws_key" { } | |
variable "aws_secret" { } | |
variable "key_name" {} | |
variable "key_path" {} | |
provider "aws" { | |
access_key = "${var.aws_key}" | |
secret_key = "${var.aws_secret}" | |
region = "us-east-1" | |
} | |
resource "aws_security_group" "allow_all" { | |
name = "allow_all" | |
description = "Allow all inbound traffic" | |
ingress { | |
from_port = 0 | |
to_port = 65535 | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
} | |
} | |
resource "aws_instance" "test-virginia-remote-exec" { | |
ami = "ami-8caa1ce4" | |
instance_type = "m3.medium" | |
key_name = "deploy-gosuri" | |
tags { Name = "test-virginia-remote-exec" } | |
security_groups = ["${aws_security_group.allow_all.name}"] | |
connection { | |
user = "ubuntu" | |
type = "ssh" | |
key_file = "${var.key_path}" | |
} | |
provisioner "remote-exec" { | |
inline = ["sudo echo `date` > /var/log/terraform-remote-exec.log"] | |
} | |
} | |
resource "aws_instance" "test-virginia-user-data" { | |
ami = "ami-8caa1ce4" | |
instance_type = "m3.medium" | |
key_name = "${var.key_name}" | |
tags { Name = "test-virginia-user-data" } | |
security_groups = ["${aws_security_group.allow_all.name}"] | |
user_data = "echo `date` > /var/log/terraform-remote-exec.log" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment