Skip to content

Created inital RDS module#56

Draft
uzairharoon20 wants to merge 3 commits into
mainfrom
feature/BCSS-23564-rds-tf-module
Draft

Created inital RDS module#56
uzairharoon20 wants to merge 3 commits into
mainfrom
feature/BCSS-23564-rds-tf-module

Conversation

@uzairharoon20

Copy link
Copy Markdown
Contributor

Description

Context

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

@nhs-oliverslater nhs-oliverslater added enhancement New feature or request terraform Pull request that updates terraform code / modules labels Jun 16, 2026
Comment thread infrastructure/modules/rds/main.tf Outdated
Comment on lines +1 to +62
data "aws_vpc" "selected" {
id = var.vpc_id
}

locals {
create_security_group = length(var.vpc_security_group_ids) == 0
effective_ingress_cidr_blocks = length(var.ingress_cidr_blocks) > 0 ? var.ingress_cidr_blocks : [data.aws_vpc.selected.cidr_block]
}

# ----------------------------------------------------------------------------
# Security group for the RDS instance.
#
# Only created when vpc_security_group_ids is not provided. The security group
# allows inbound traffic on the DB port (and optionally the Performance Insights
# agent port) from the VPC CIDR or caller-supplied CIDR blocks, and restricts
# outbound traffic to HTTPS only.
# ----------------------------------------------------------------------------

# tflint-ignore: terraform_required_providers
resource "aws_security_group" "this" {
# checkov:skip=CKV2_AWS_5: SG is attached to the RDS instance via vpc_security_group_ids in the community module below
count = local.create_security_group ? 1 : 0

name_prefix = "${module.this.id}-rds-"
description = "Allow VPC traffic to ${var.engine} RDS instance on port ${var.port}"
vpc_id = var.vpc_id

ingress {
description = "DB port from VPC"
from_port = var.port
to_port = var.port
protocol = "tcp"
cidr_blocks = local.effective_ingress_cidr_blocks
}

dynamic "ingress" {
for_each = var.pi_port != null ? [1] : []
content {
description = "Performance Insights agent port"
from_port = var.pi_port
to_port = var.pi_port
protocol = "tcp"
cidr_blocks = length(var.pi_cidr_block) > 0 ? var.pi_cidr_block : local.effective_ingress_cidr_blocks
}
}

egress {
description = "HTTPS egress for AWS service communication"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}

tags = merge(module.this.tags, { Name = "${module.this.id}-rds" })

lifecycle {
create_before_destroy = true
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have a dedicated module for security group don't think we need to create it here. See here: #53
We'd have the caller create the SG and pass its ID into the RDS module.

Need to update this across the various files - Outputs, readme and variables

uzairharoon20 and others added 3 commits June 19, 2026 14:27
- Added support for a new RDS module path in dependabot.yaml.
- Created .terraform.lock.hcl for the new RDS module.
- Updated README.md to include usage examples for PostgreSQL and Oracle RDS instances, along with security group and secrets manager integration.
- Modified context.tf to enable module creation based on the 'enabled' variable.
- Introduced locals.tf to define rds_identifier based on provided names.
- Updated main.tf to conditionally create RDS resources based on the 'enabled' variable.
- Enhanced variables.tf to include custom_name variable for explicit RDS instance naming.
- Updated versions.tf to require Terraform version >= 1.13 and AWS provider version >= 6.42.
@nhs-oliverslater nhs-oliverslater force-pushed the feature/BCSS-23564-rds-tf-module branch from 4ee8a5a to 07288ef Compare June 19, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request terraform Pull request that updates terraform code / modules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants