Formatting

This commit is contained in:
Daniel Mason 2023-04-22 13:19:00 +12:00
parent 2d32a3c4bb
commit 6d36a3aa71
Signed by: idanoo
GPG key ID: 387387CDBC02F132
4 changed files with 37 additions and 37 deletions

2
ec2.tf
View file

@ -3,7 +3,7 @@
resource "aws_instance" "instance" { resource "aws_instance" "instance" {
ami = data.aws_ami.ubuntu.id ami = data.aws_ami.ubuntu.id
instance_type = var.instance_type instance_type = var.instance_type
iam_instance_profile = aws_iam_instance_profile.profile.name iam_instance_profile = aws_iam_instance_profile.profile.name
availability_zone = element(aws_subnet.subnet.*.availability_zone, 1) availability_zone = element(aws_subnet.subnet.*.availability_zone, 1)
user_data = data.template_file.userdata.rendered user_data = data.template_file.userdata.rendered
subnet_id = element(aws_subnet.subnet.*.id, 1) subnet_id = element(aws_subnet.subnet.*.id, 1)

6
iam.tf
View file

@ -25,10 +25,10 @@ resource "aws_iam_instance_profile" "profile" {
} }
resource "aws_iam_role_policy" "policy" { resource "aws_iam_role_policy" "policy" {
name = aws_iam_role.role.name name = aws_iam_role.role.name
role = aws_iam_role.role.id role = aws_iam_role.role.id
policy = <<EOF policy = <<EOF
{ {
"Version": "2012-10-17", "Version": "2012-10-17",
"Statement": [ "Statement": [

44
sg.tf
View file

@ -3,38 +3,38 @@ resource "aws_security_group" "sg" {
name = "status.fediservices.nz" name = "status.fediservices.nz"
description = "status.fediservices.nz" description = "status.fediservices.nz"
vpc_id = aws_vpc.vpc.id vpc_id = aws_vpc.vpc.id
} }
# Allow out # Allow out
resource "aws_security_group_rule" "allow_egress" { resource "aws_security_group_rule" "allow_egress" {
security_group_id = aws_security_group.sg.id security_group_id = aws_security_group.sg.id
type = "egress" type = "egress"
from_port = 0 from_port = 0
to_port = 0 to_port = 0
protocol = "-1" protocol = "-1"
cidr_blocks = ["0.0.0.0/0"] cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"] ipv6_cidr_blocks = ["::/0"]
} }
# Allow HTTP traffic # Allow HTTP traffic
resource "aws_security_group_rule" "http" { resource "aws_security_group_rule" "http" {
security_group_id = aws_security_group.sg.id security_group_id = aws_security_group.sg.id
type = "ingress" type = "ingress"
from_port = 80 from_port = 80
to_port = 80 to_port = 80
protocol = "tcp" protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"] ipv6_cidr_blocks = ["::/0"]
} }
# Allow HTTPS traffic # Allow HTTPS traffic
resource "aws_security_group_rule" "https" { resource "aws_security_group_rule" "https" {
security_group_id = aws_security_group.sg.id security_group_id = aws_security_group.sg.id
type = "ingress" type = "ingress"
from_port = 443 from_port = 443
to_port = 443 to_port = 443
protocol = "tcp" protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"] ipv6_cidr_blocks = ["::/0"]
} }

22
vpc.tf
View file

@ -1,24 +1,24 @@
resource "aws_vpc" "vpc" { resource "aws_vpc" "vpc" {
cidr_block = "10.10.10.0/24" cidr_block = "10.10.10.0/24"
enable_dns_hostnames = true enable_dns_hostnames = true
enable_dns_support = true enable_dns_support = true
tags = {Name = "mainVPC"} tags = { Name = "mainVPC" }
} }
resource "aws_subnet" "subnet" { resource "aws_subnet" "subnet" {
count = length(data.aws_availability_zones.available.names) count = length(data.aws_availability_zones.available.names)
vpc_id = aws_vpc.vpc.id vpc_id = aws_vpc.vpc.id
cidr_block = "10.10.10.${16*count.index}/28" cidr_block = "10.10.10.${16 * count.index}/28"
availability_zone= "${data.aws_availability_zones.available.names[count.index]}" availability_zone = data.aws_availability_zones.available.names[count.index]
tags = {Name = "mainSubnet"} tags = { Name = "mainSubnet" }
} }
resource "aws_internet_gateway" "igw" { resource "aws_internet_gateway" "igw" {
vpc_id = aws_vpc.vpc.id vpc_id = aws_vpc.vpc.id
tags = {Name = "mainIGW"} tags = { Name = "mainIGW" }
} }
data "aws_route_table" "rt" { data "aws_route_table" "rt" {
@ -32,7 +32,7 @@ resource "aws_route" "igw" {
} }
resource "aws_route_table_association" "association" { resource "aws_route_table_association" "association" {
count = length(data.aws_availability_zones.available.names) count = length(data.aws_availability_zones.available.names)
subnet_id = element(aws_subnet.subnet.*.id, count.index) subnet_id = element(aws_subnet.subnet.*.id, count.index)
route_table_id = data.aws_route_table.rt.id route_table_id = data.aws_route_table.rt.id
} }