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"); - } -} - 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"] 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"); - } -} diff --git a/JavaHelloWorld.java b/JavaHelloWorld.java deleted file mode 100644 index 5e7ed71..0000000 --- a/JavaHelloWorld.java +++ /dev/null @@ -1,6 +0,0 @@ -public class JavaHelloWorld { - public static void main(String[] args) { - // Prints "Hello, World" in the terminal window. - System.out.println("Hello, JavaWorld"); - } -} diff --git a/README.md b/README.md index 9f7b3c0..8336028 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# javahelloworld +#terraform-demo + 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