-
-
Save baleyko/197aebbb2eec41b778146c92c5a5ef88 to your computer and use it in GitHub Desktop.
Terraform Hello World
This file contains 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
provider "aws" { | |
region = "us-east-1" | |
} | |
resource "aws_security_group" "instance" { | |
name = "terraform-example-instance" | |
ingress { | |
from_port = "${var.server_port}" | |
to_port = "${var.server_port}" | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
} | |
} | |
resource "aws_instance" "web" { | |
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 8080 & | |
EOF | |
tags { | |
Name = "terraform-example" | |
} | |
} |
This file contains 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
output "public_ip" { | |
value = "${aws_instance.web.public_ip}" | |
} |
This file contains 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 "server_port" { | |
description = "The port the server will use for HTTP requests" | |
default = 8080 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment