From b27fe3cffa5d37cf7d9e00bd5aa2a40bcff47737 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A1ssio=20Gabriel?= Date: Fri, 23 Jan 2026 22:50:46 -0300 Subject: [PATCH] Fixing a blunder that I did using this fabulous version control tool --- terraform/main.tf | 73 +++++++++++++++++++++--------------------- terraform/outputs.tf | 10 +++--- terraform/variables.tf | 24 +++++++------- terraform/versions.tf | 6 ++-- 4 files changed, 56 insertions(+), 57 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 1a8a9aa..bfb7e9d 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -1,21 +1,21 @@ provider "aws" { region = var.region -***REMOVED*** +} # Default VPC data "aws_vpc" "default" { default = true -***REMOVED*** +} # Default subnet in us-east-1a resource "aws_default_subnet" "a" { availability_zone = "us-east-1a" -***REMOVED*** +} # Internet Gateway for default VPC resource "aws_internet_gateway" "igw" { vpc_id = data.aws_vpc.default.id -***REMOVED*** +} # Public route table (0.0.0.0/0 -> IGW) resource "aws_route_table" "public" { @@ -24,18 +24,18 @@ resource "aws_route_table" "public" { route { cidr_block = "0.0.0.0/0" gateway_id = aws_internet_gateway.igw.id - ***REMOVED*** + } tags = { - Name = "${var.project_name***REMOVED***-rt-public" - ***REMOVED*** -***REMOVED*** + Name = "${var.project_name}-rt-public" + } +} # Associate route table to subnet resource "aws_route_table_association" "a" { subnet_id = aws_default_subnet.a.id route_table_id = aws_route_table.public.id -***REMOVED*** +} # Ubuntu AMI data "aws_ami" "ubuntu" { @@ -45,17 +45,17 @@ data "aws_ami" "ubuntu" { filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] - ***REMOVED*** -***REMOVED*** + } +} # CloudFront origin-facing managed prefix list data "aws_ec2_managed_prefix_list" "cloudfront_origin" { name = "com.amazonaws.global.cloudfront.origin-facing" -***REMOVED*** +} # SG resource "aws_security_group" "gitweb" { - name = "${var.project_name***REMOVED***-sg" + name = "${var.project_name}-sg" description = "SSH from my IP; HTTP only from CloudFront origin-facing" vpc_id = data.aws_vpc.default.id @@ -65,7 +65,7 @@ resource "aws_security_group" "gitweb" { to_port = 22 protocol = "tcp" cidr_blocks = [var.my_ip_cidr] - ***REMOVED*** + } ingress { description = "HTTP only from CloudFront origin-facing" @@ -73,7 +73,7 @@ resource "aws_security_group" "gitweb" { to_port = 80 protocol = "tcp" prefix_list_ids = [data.aws_ec2_managed_prefix_list.cloudfront_origin.id] - ***REMOVED*** + } egress { description = "Allow outbound" @@ -81,8 +81,8 @@ resource "aws_security_group" "gitweb" { to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] - ***REMOVED*** -***REMOVED*** + } +} # EC2 resource "aws_instance" "gitweb" { @@ -92,12 +92,12 @@ resource "aws_instance" "gitweb" { vpc_security_group_ids = [aws_security_group.gitweb.id] key_name = var.key_name - user_data = file("${path.module***REMOVED***/user_data_config.sh") + user_data = file("${path.module}/user_data_config.sh") tags = { - Name = "${var.project_name***REMOVED***-ec2" - ***REMOVED*** -***REMOVED*** + Name = "${var.project_name}-ec2" + } +} # EIP resource "aws_eip" "gitweb" { @@ -105,9 +105,9 @@ resource "aws_eip" "gitweb" { instance = aws_instance.gitweb.id tags = { - Name = "${var.project_name***REMOVED***-eip" - ***REMOVED*** -***REMOVED*** + Name = "${var.project_name}-eip" + } +} # CloudFront distribution resource "aws_cloudfront_distribution" "gitweb" { @@ -116,20 +116,19 @@ resource "aws_cloudfront_distribution" "gitweb" { comment = "GitWeb behind CloudFront (origin restricted)" origin { - # Use CloudFront dns - domain_name = aws_eip.gitweb.public_dns - origin_id = "${var.project_name***REMOVED***-origin" + domain_name = aws_eip.gitweb.public_dns + origin_id = "${var.project_name}-origin" custom_origin_config { http_port = 80 https_port = 443 origin_protocol_policy = "http-only" origin_ssl_protocols = ["TLSv1.2"] - ***REMOVED*** - ***REMOVED*** + } + } default_cache_behavior { - target_origin_id = "${var.project_name***REMOVED***-origin" + target_origin_id = "${var.project_name}-origin" viewer_protocol_policy = "redirect-to-https" allowed_methods = ["GET", "HEAD"] @@ -137,19 +136,19 @@ resource "aws_cloudfront_distribution" "gitweb" { forwarded_values { query_string = true - cookies { forward = "none" ***REMOVED*** - ***REMOVED*** + cookies { forward = "none" } + } min_ttl = 0 default_ttl = 0 max_ttl = 60 - ***REMOVED*** + } restrictions { - geo_restriction { restriction_type = "none" ***REMOVED*** - ***REMOVED*** + geo_restriction { restriction_type = "none" } + } viewer_certificate { cloudfront_default_certificate = true - ***REMOVED*** -***REMOVED*** + } +} diff --git a/terraform/outputs.tf b/terraform/outputs.tf index 1777fed..98bff08 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -1,11 +1,11 @@ output "instance_public_ip" { value = aws_eip.gitweb.public_ip -***REMOVED*** +} output "ssh_command" { - value = "ssh -i gitweb-pem.pem ubuntu@${aws_eip.gitweb.public_ip***REMOVED***" -***REMOVED*** + value = "ssh -i ubuntu@${aws_eip.gitweb.public_ip}" +} output "gitweb_url" { - value = "https://${aws_cloudfront_distribution.gitweb.domain_name***REMOVED***/cgi-bin/gitweb.cgi" -***REMOVED*** + value = "https://${aws_cloudfront_distribution.gitweb.domain_name}/cgi-bin/gitweb.cgi" +} diff --git a/terraform/variables.tf b/terraform/variables.tf index 7b1799b..dbac5eb 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -1,24 +1,24 @@ variable "region" { type = string default = "us-east-1" -***REMOVED*** +} -***REMOVED*** -***REMOVED*** -***REMOVED*** -***REMOVED*** +variable "my_ip_cidr" { + type = string + description = "Your public IP in CIDR format, e.g. 203.0.113.10/32" +} variable "key_name" { -***REMOVED*** - description = "gitweb-pem" -***REMOVED*** + type = string + description = "Existing EC2 Key Pair name in the target region" +} variable "instance_type" { type = string default = "t3.small" -***REMOVED*** +} variable "project_name" { -***REMOVED*** - description = "host-gitweb" -***REMOVED*** + type = string + default = "host-gitweb" +} diff --git a/terraform/versions.tf b/terraform/versions.tf index 657d00b..71b0a77 100644 --- a/terraform/versions.tf +++ b/terraform/versions.tf @@ -5,6 +5,6 @@ terraform { aws = { source = "hashicorp/aws" version = ">= 6.0" - ***REMOVED*** - ***REMOVED*** -***REMOVED*** + } + } +} -- 2.34.1