Created inital RDS module#56
Draft
uzairharoon20 wants to merge 3 commits into
Draft
Conversation
Pira-nhs
reviewed
Jun 16, 2026
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 | ||
| } | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
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
- 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.
4ee8a5a to
07288ef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Context
Type of changes
Checklist
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.