Skip to content

Add Tags and refactor terraform script#47

Open
yash2189 wants to merge 1 commit into
openshift-sustaining:mainfrom
yash2189:add_tags
Open

Add Tags and refactor terraform script#47
yash2189 wants to merge 1 commit into
openshift-sustaining:mainfrom
yash2189:add_tags

Conversation

@yash2189

Copy link
Copy Markdown
Collaborator
  • Added common_tags for resources and made it reusable.
  • Introduced dynamic availability zones

@yash2189 yash2189 requested a review from prabhapa as a code owner July 16, 2025 11:30

@prabhapa prabhapa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not creating any IAC code here. But the best implementation would be below (modularising vpc)
structure:

main.tf
vars.tf
vpc_module/
       main.tf    # keep current main.tf code here
       vars.tf    # module inputs**

top level vars.tf should have below vars only:

variable "regions_to_be_deployed" {
  description = "List of AWS regions to deploy the VPC"
  type        = list(string)
  default     = ["ap-south-1", "us-east-1"] # these can be chaged as per requirement
}
output "vpc_ids" {
  value = { for region, mod in module.multi_region_vpc : region => mod.vpc_id }
}

top level main.tf should be like it:

module "multi_region_vpc" {
  for_each = toset(var.regions_to_be_deployed)

  source = "./vpc_module"

  aws_region            = each.key
  vpc_cidr              = "10.0.0.0/16"
  vpc_name              = "openshift-sustaining-vpc-${each.key}"
  vpc_owner             = "openshift sustaining slack bot"
  public_subnet_cidr_1  = "10.0.1.0/24"
  public_subnet_cidr_2  = "10.0.2.0/24"
  common_tags           = {
    "app-code"      = "OSUS-002"
    "service-phase" = "dev"
    "cost-center"   = "136"
  }
}

You can try this when you have time..Also add a readme as to how to run this (steps)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants