From 9b112d9d9be4289931da0f883dc9786d2d5a53e4 Mon Sep 17 00:00:00 2001 From: pb Date: Sat, 17 Dec 2016 11:20:14 -0800 Subject: [PATCH 01/10] new branch --- no | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 no diff --git a/no b/no new file mode 100644 index 0000000..e69de29 From aaff4cc1c179ed242d88e984233c8518f7b4f80a Mon Sep 17 00:00:00 2001 From: pb Date: Sat, 17 Dec 2016 12:21:44 -0800 Subject: [PATCH 02/10] Added comments --- JavaHelloWorld.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/JavaHelloWorld.java b/JavaHelloWorld.java index 5e7ed71..ed05b0b 100644 --- a/JavaHelloWorld.java +++ b/JavaHelloWorld.java @@ -1,6 +1,7 @@ public class JavaHelloWorld { public static void main(String[] args) { - // Prints "Hello, World" in the terminal window. + // This is the only line I can edit + ≈// Prints "Hello, World" in the terminal window. System.out.println("Hello, JavaWorld"); } } From 478a8bcb83e06c3275db5a32b15765f525a669a0 Mon Sep 17 00:00:00 2001 From: Coder63 Date: Sat, 17 Dec 2016 12:23:02 -0800 Subject: [PATCH 03/10] Update JavaHelloWorld.java --- JavaHelloWorld.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JavaHelloWorld.java b/JavaHelloWorld.java index ed05b0b..aedd01e 100644 --- a/JavaHelloWorld.java +++ b/JavaHelloWorld.java @@ -1,7 +1,7 @@ public class JavaHelloWorld { public static void main(String[] args) { // This is the only line I can edit - ≈// Prints "Hello, World" in the terminal window. + // Prints "Hello, World" in the terminal window. System.out.println("Hello, JavaWorld"); } } From 1f3ee12c7c4ed2b42cefbc1252b49a6894521337 Mon Sep 17 00:00:00 2001 From: Coder63 Date: Tue, 13 Jun 2017 14:22:58 -0700 Subject: [PATCH 04/10] Add files via upload --- main.tf | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ outputs.tf | 3 +++ vars.tf | 16 ++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 main.tf create mode 100644 outputs.tf create mode 100644 vars.tf diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..8f4d8cb --- /dev/null +++ b/main.tf @@ -0,0 +1,50 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# DEPLOY A SINGLE EC2 INSTANCE +# This template uses runs a simple "Hello, World" web server on a single EC2 Instance +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ------------------------------------------------------------------------------ +# CONFIGURE OUR AWS CONNECTION +# ------------------------------------------------------------------------------ + +provider "aws" { + region = "us-east-2" + profile = "uit" +} + +# --------------------------------------------------------------------------------------------------------------------- +# DEPLOY A SINGLE EC2 INSTANCE +# --------------------------------------------------------------------------------------------------------------------- + +resource "aws_instance" "example" { + # Ubuntu Server 14.04 LTS (HVM), SSD Volume Type in us-east-1 + ami = "ami-2d39803a" + instance_type = "t2.micro" + vpc_security_group_ids = ["${aws_security_group.instance.id}"] + + user_data = <<-EOF + #!/bin/bash + echo "Hello, World" > index.html + nohup busybox httpd -f -p "${var.server_port}" & + EOF + + tags { + Name = "terraform-example" + } +} + +# --------------------------------------------------------------------------------------------------------------------- +# CREATE THE SECURITY GROUP THAT'S APPLIED TO THE EC2 INSTANCE +# --------------------------------------------------------------------------------------------------------------------- + +resource "aws_security_group" "instance" { + name = "terraform-example-instance" + + # Inbound HTTP from anywhere + ingress { + from_port = "${var.server_port}" + to_port = "${var.server_port}" + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } +} diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..66c344d --- /dev/null +++ b/outputs.tf @@ -0,0 +1,3 @@ +output "public_ip" { + value = "${aws_instance.example.public_ip}" +} \ No newline at end of file diff --git a/vars.tf b/vars.tf new file mode 100644 index 0000000..d4a87fc --- /dev/null +++ b/vars.tf @@ -0,0 +1,16 @@ +# --------------------------------------------------------------------------------------------------------------------- +# ENVIRONMENT VARIABLES +# Define these secrets as environment variables +# --------------------------------------------------------------------------------------------------------------------- + +# AWS_ACCESS_KEY_ID +# AWS_SECRET_ACCESS_KEY + +# --------------------------------------------------------------------------------------------------------------------- +# OPTIONAL PARAMETERS +# --------------------------------------------------------------------------------------------------------------------- + +variable "server_port" { + description = "The port the server will use for HTTP requests" + default = 8080 +} \ No newline at end of file From 3ede0b0baba625613404d453dd78c7e7a749a578 Mon Sep 17 00:00:00 2001 From: Coder63 Date: Tue, 13 Jun 2017 14:23:16 -0700 Subject: [PATCH 05/10] Delete Dockerfile --- Dockerfile | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6cfd4ef..0000000 --- a/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM java:7 -RUN echo "Base Image Java 7 " -COPY JavaHelloWorld.java . -RUN echo " copy .java file" -RUN javac JavaHelloWorld.java -RUN echo " Run java file with compiler " -CMD ["java", "JavaHelloWorld"] From d2c0e7ed034788e01b9d11b50a29c84fb5ba099c Mon Sep 17 00:00:00 2001 From: Coder63 Date: Tue, 13 Jun 2017 14:23:24 -0700 Subject: [PATCH 06/10] Delete JavaHelloWorld.java --- JavaHelloWorld.java | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 JavaHelloWorld.java diff --git a/JavaHelloWorld.java b/JavaHelloWorld.java deleted file mode 100644 index aedd01e..0000000 --- a/JavaHelloWorld.java +++ /dev/null @@ -1,7 +0,0 @@ -public class JavaHelloWorld { - public static void main(String[] args) { - // This is the only line I can edit - // Prints "Hello, World" in the terminal window. - System.out.println("Hello, JavaWorld"); - } -} From bb461868954a052d29eae07c9ebc8c97852b9871 Mon Sep 17 00:00:00 2001 From: Coder63 Date: Tue, 13 Jun 2017 14:23:29 -0700 Subject: [PATCH 07/10] Delete HelloWorld.java --- HelloWorld.java | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 HelloWorld.java diff --git a/HelloWorld.java b/HelloWorld.java deleted file mode 100644 index eb174ff..0000000 --- a/HelloWorld.java +++ /dev/null @@ -1,6 +0,0 @@ -public class HelloWorld { - public static void main(String[] args) { - // Prints "Hello, World" in the terminal window. - System.out.println("Hello, World"); - } -} From 8dc99496d3ae18aa4f199d0df8a41dfc706823c3 Mon Sep 17 00:00:00 2001 From: Coder63 Date: Tue, 13 Jun 2017 14:23:35 -0700 Subject: [PATCH 08/10] Delete 1 --- 1 | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 1 diff --git a/1 b/1 deleted file mode 100644 index 4cd8fb8..0000000 --- a/1 +++ /dev/null @@ -1,9 +0,0 @@ -public class JavaHelloWorld -{ - public static void main(String [] args) - { - System.out.println("Java Hello World"); - System.out.println("Hello world"); - } -} - From 99a2f9783ca2afa0c8592efb2a2216333e19add4 Mon Sep 17 00:00:00 2001 From: Coder63 Date: Tue, 13 Jun 2017 14:23:43 -0700 Subject: [PATCH 09/10] Delete no --- no | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 no diff --git a/no b/no deleted file mode 100644 index e69de29..0000000 From 534115bd5a78697268fd1bf85c9e881d9a51f54c Mon Sep 17 00:00:00 2001 From: Coder63 Date: Tue, 13 Jun 2017 14:24:06 -0700 Subject: [PATCH 10/10] Create README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f7b3c0..8336028 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# javahelloworld +#terraform-demo +