Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/learning-terraform-3087701.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 51 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,70 @@ data "aws_ami" "app_ami" {
most_recent = true

filter {
name = "name"
name = "name"
values = ["bitnami-tomcat-*-x86_64-hvm-ebs-nami"]
}

filter {
name = "virtualization-type"
name = "virtualization-type"
values = ["hvm"]
}

owners = ["979382823631"] # Bitnami

}

data "aws_vpc" "default" {
default = true
}

resource "aws_instance" "web" {
resource "aws_instance" "blog" {
ami = data.aws_ami.app_ami.id
instance_type = "t3.nano"
instance_type = var.instance_type

vpc_security_group_ids = [aws_security_group.blog.id]

tags = {
Name = "HelloWorld"
}
}

resource "aws_security_group" "blog" {
name = "blog"
description = "Allow HTTP inbound traffic. Allow everything out."

vpc_id = data.aws_vpc.default.id
}

resource "aws_security_group_rule" "blog_http_in" {
type = "ingress"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]


security_group_id = aws_security_group.blog.id
}

resource "aws_security_group_rule" "blog_https_in" {
type = "ingress"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]


security_group_id = aws_security_group.blog.id
}

resource "aws_security_group_rule" "blog_all_out" {
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]


security_group_id = aws_security_group.blog.id
}
12 changes: 6 additions & 6 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#output "instance_ami" {
# value = aws_instance.web.ami
#}
output "instance_ami" {
value = aws_instance.blog.ami
}

#output "instance_arn" {
# value = aws_instance.web.arn
#}
output "instance_arn" {
value = aws_instance.blog.arn
}
13 changes: 9 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#variable "instance_type" {
# description = "Type of EC2 instance to provision"
# default = "t3.nano"
#}
variable "instance_type" {
description = "Type of EC2 instance to provision"
default = "t3.nano"
}

variable "region" {
description = "AWS region to launch servers."
default = "eu-west-1"
}