Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 🐛 Fixed the comments as per the CD structure #13

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
## Copyright @ CloudDrove. All Right Reserved.

locals {
# Terragrunt users have to provide `records_jsonencoded` as jsonencode()'d string.
# See details: https://github.com/gruntwork-io/terragrunt/issues/1211
##-----------------------------------------------------------------------------
## Terragrunt users have to provide `records_jsonencoded` as jsonencode()'d string.
## See details: https://github.com/gruntwork-io/terragrunt/issues/1211
##-----------------------------------------------------------------------------
records = concat(var.records, try(jsondecode(var.records_jsonencoded), []))

# Convert `records` from list to map with unique keys
##-----------------------------------------------------------------------------
## Convert `records` from list to map with unique keys
##-----------------------------------------------------------------------------
recordsets = { for rs in local.records : try(rs.key, join(" ", compact(["${rs.name} ${rs.type}", try(rs.set_identifier, "")]))) => rs }
zone_id = var.zone_id != "" ? var.zone_id : (var.private_enabled ? aws_route53_zone.private.*.zone_id[0] : aws_route53_zone.public.*.zone_id[0])
}

#Module : label
#Description : This terraform module is designed to generate consistent label names and tags
# for resources. You can use terraform-labels to implement a strict naming
# convention.
##-----------------------------------------------------------------------------
## Locals declration to determine count of public subnet, private subnet, and nat gateway.
##-----------------------------------------------------------------------------
module "labels" {
source = "clouddrove/labels/aws"
version = "1.3.0"
Expand All @@ -28,9 +31,9 @@ module "labels" {

}

# Module : Route53
# Description : Terraform module to create Route53 zone resource on AWS for creating private
# hosted zones.
##-----------------------------------------------------------------------------
## Terraform module to create Route53 zone resource on AWS for creating private hosted zones.
##-----------------------------------------------------------------------------
resource "aws_route53_zone" "private" {
count = var.enabled && var.private_enabled ? 1 : 0

Expand All @@ -43,9 +46,9 @@ resource "aws_route53_zone" "private" {
}
}

# Module : Route53
# Description : Terraform module to create Route53 zone resource on AWS for creating public
# hosted zones.
##-----------------------------------------------------------------------------
## Terraform module to create Route53 zone resource on AWS for creating public hosted zones.
##-----------------------------------------------------------------------------
resource "aws_route53_zone" "public" {
count = var.enabled && var.public_enabled ? 1 : 0

Expand All @@ -56,9 +59,9 @@ resource "aws_route53_zone" "public" {
tags = module.labels.tags
}

# Module : Route53 Record Set
# Description : Terraform module to create Route53 record sets resource on AWS.

##-----------------------------------------------------------------------------
## Terraform module to create Route53 record sets resource on AWS.
##-----------------------------------------------------------------------------
resource "aws_route53_record" "this" {
for_each = { for k, v in local.recordsets : k => v if var.enabled && var.record_enabled && ( var.zone_id != null || var.public_enabled != null || var.private_enabled != null || var.domain_name != null) }

Expand Down Expand Up @@ -122,9 +125,9 @@ resource "aws_route53_record" "this" {
]
}

# Module : Route53
# Description : Terraform module to create Route53 record sets resource on AWS for Weighted
# Routing Policy.
##-----------------------------------------------------------------------------
## Terraform module to create Route53 record sets resource on AWS for Weighted Routing Policy.
##-----------------------------------------------------------------------------
resource "aws_route53_zone_association" "default" {
count = var.enabled && var.vpc_association_enabled && var.private_enabled ? 1 : 0
zone_id = aws_route53_zone.private.*.zone_id[0]
Expand Down
5 changes: 3 additions & 2 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Module : Route53
# Description : Terraform module to create Route53 resource on AWS for managing queue.
##-----------------------------------------------------------------------------
## Terraform module to create Route53 resource on AWS for managing queue.
##-----------------------------------------------------------------------------
output "zone_id" {
value = var.zone_id != "" ? "" : (var.public_enabled ? join("", aws_route53_zone.public.*.zone_id) : join("", aws_route53_zone.private.*.zone_id))
description = "The Hosted Zone ID. This can be referenced by zone records."
Expand Down
10 changes: 6 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Module : LABEL
#Description : Terraform label module variables
##-----------------------------------------------------------------------------
## Locals declration to determine count of public subnet, private subnet, and nat gateway.
##-----------------------------------------------------------------------------
variable "name" {
type = string
default = ""
Expand Down Expand Up @@ -36,8 +37,9 @@ variable "managedby" {
description = "ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'."
}

# Module : Route53
# Description : Terraform Route53 module variables.
##-----------------------------------------------------------------------------
## Terraform Route53 module variables.
##-----------------------------------------------------------------------------

variable "enabled" {
type = bool
Expand Down
Loading