From 8df53baf47c1094f540fb23a6cbcfbc50befdf3a Mon Sep 17 00:00:00 2001 From: Tanay Jain <162029870+tj2905@users.noreply.github.com> Date: Sat, 22 Aug 2026 14:30:00 +0000 Subject: [PATCH] refactor: centralize outputs and import June website bucket --- PROJECT_STRUCTURE.md | 25 +++++++++++++++++++++++++ alb-usage.tf | 8 -------- asg-usage.tf | 20 -------------------- console-imports.tf | 3 +++ outputs.tf | 31 +++++++++++++++++++++++++++++++ rds-usage.tf | 14 +------------- vpc-usage.tf | 14 +------------- 7 files changed, 61 insertions(+), 54 deletions(-) create mode 100644 PROJECT_STRUCTURE.md create mode 100644 console-imports.tf create mode 100644 outputs.tf diff --git a/PROJECT_STRUCTURE.md b/PROJECT_STRUCTURE.md new file mode 100644 index 0000000..5bdd8fb --- /dev/null +++ b/PROJECT_STRUCTURE.md @@ -0,0 +1,25 @@ +# Project File Layout + +## Root-level files +- `main.tf` — provider + terraform block +- `backend.tf` — S3+DynamoDB remote state config +- `environment-vars.tf` — root variables consumed by *-usage.tf files +- `*-usage.tf` — one file per module call (vpc, alb, asg, rds, github-oidc). Each wires that module into the overall stack. +- `ansible-ssm-bucket.tf` — supporting S3 bucket for Ansible's SSM connection plugin (transient, 1-day lifecycle) + +## modules/ +- `vpc/` — networking foundation +- `alb/` — load balancer +- `asg/` — compute (autoscaling) +- `rds/` — database +- `github-oidc/` — CI identity federation +- `app-instance/`, `ec2/` — DEPRECATED (superseded by asg/ on Aug 17, kept for module-refactoring practice history, not called from root) + +## environments/ +Per-environment tfvars — dev.tfvars, prod.tfvars + +## tests/ +Native `.tftest.hcl` coverage (Aug 13) + +## packer/, ansible/ +Separate tool workflows, not Terraform-managed directly diff --git a/alb-usage.tf b/alb-usage.tf index acd7569..e4d3d7e 100644 --- a/alb-usage.tf +++ b/alb-usage.tf @@ -12,12 +12,4 @@ module "alb" { Project = "terraform-mastery" Environment = terraform.workspace } -} - -output "alb_url" { - value = "http://${module.alb.alb_dns_name}" -} - -output "alb_target_group_arn" { - value = module.alb.target_group_arn } \ No newline at end of file diff --git a/asg-usage.tf b/asg-usage.tf index 4e094d2..ee50e45 100644 --- a/asg-usage.tf +++ b/asg-usage.tf @@ -51,24 +51,4 @@ module "asg" { Project = "terraform-mastery" Environment = var.environment_name } -} - -output "app_security_group_id" { - description = "ID of the application security group" - value = module.asg.app_security_group_id -} - -output "asg_name" { - description = "Name of the application Auto Scaling Group" - value = module.asg.asg_name -} - -output "launch_template_id" { - description = "ID of the application Launch Template" - value = module.asg.launch_template_id -} - -output "target_group_arn" { - description = "ARN of the ALB target group used by the Auto Scaling Group" - value = module.alb.target_group_arn } \ No newline at end of file diff --git a/console-imports.tf b/console-imports.tf new file mode 100644 index 0000000..7d134c6 --- /dev/null +++ b/console-imports.tf @@ -0,0 +1,3 @@ +resource "aws_s3_bucket" "june_website" { + bucket = "tanay-website-june-2026" +} diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..a971947 --- /dev/null +++ b/outputs.tf @@ -0,0 +1,31 @@ +# Networking + +output "vpc_id" { + value = module.main_vpc.vpc_id +} + +# Compute + +output "asg_name" { + value = module.asg.asg_name +} + +output "app_security_group_id" { + value = module.asg.app_security_group_id +} + +# Load Balancer + +output "alb_url" { + value = "http://${module.alb.alb_dns_name}" +} + +# Database + +output "rds_endpoint" { + value = module.rds.db_endpoint +} + +output "rds_secret_arn" { + value = module.rds.secret_arn +} diff --git a/rds-usage.tf b/rds-usage.tf index 2096cf5..9677db5 100644 --- a/rds-usage.tf +++ b/rds-usage.tf @@ -22,16 +22,4 @@ module "rds" { Environment = terraform.workspace ManagedBy = "Terraform" } -} - -output "rds_endpoint" { - value = module.rds.db_endpoint -} - -output "rds_secret_arn" { - value = module.rds.secret_arn -} - -output "rds_security_group_id" { - value = module.rds.rds_security_group_id -} +} \ No newline at end of file diff --git a/vpc-usage.tf b/vpc-usage.tf index 5591cdb..1f986f6 100644 --- a/vpc-usage.tf +++ b/vpc-usage.tf @@ -26,16 +26,4 @@ module "main_vpc" { Project = "terraform-mastery" Environment = var.environment_name } -} - -output "vpc_id" { - value = module.main_vpc.vpc_id -} - -output "public_subnets" { - value = module.main_vpc.public_subnet_ids -} - -output "private_subnets" { - value = module.main_vpc.private_subnet_ids -} +} \ No newline at end of file