Fixing a blunder that I did using this fabulous version control tool
authorCássio Gabriel <cassiogabrielcontato@gmail.com>
Sat, 24 Jan 2026 01:50:46 +0000 (22:50 -0300)
committerCássio Gabriel <cassiogabrielcontato@gmail.com>
Sat, 24 Jan 2026 01:50:46 +0000 (22:50 -0300)
terraform/main.tf
terraform/outputs.tf
terraform/variables.tf
terraform/versions.tf

index 1a8a9aaaed8b3bb5bd2f323785eaa76e1d3a7b19..bfb7e9d0c677e24e880305bda2b2b53676b6f6cf 100644 (file)
@@ -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***
+  }
+}
index 1777fed2287031f774afae1d67e8dddc69cbab86..98bff08b042bfdb75d7a0182691c5b555ccd64bb 100644 (file)
@@ -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 <yourkey.pem> 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"
+}
index 7b1799b2d234061dd94bfd0c222c1e0657e28b40..dbac5eb3e8a539760ed97e1e3c242077c8c1a3ca 100644 (file)
@@ -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"
+}
index 657d00be6e08bb86fcc7d86c086d7800fbe0788a..71b0a775adcf95b21c16be3410f6cf29e9ee6c8f 100644 (file)
@@ -5,6 +5,6 @@ terraform {
     aws = {
       source  = "hashicorp/aws"
       version = ">= 6.0"
-    ***REMOVED***
-  ***REMOVED***
-***REMOVED***
+    }
+  }
+}