Skip to content

Commit

Permalink
pass environment through to database sub-module (#24)
Browse files Browse the repository at this point in the history
use environment name in kms alias and rds cluster
resolves #23

Signed-off-by: Daniel Hill <[email protected]>
  • Loading branch information
dan-hill2802 authored Mar 4, 2021
1 parent 9557704 commit 7577af6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ module "database" {
count = var.skip_rds_creation ? 0 : 1
source = "./modules/database"
name = var.kong_database_config.name
environment = var.environment
vpc = local.vpc_object
allowed_security_groups = local.security_groups
database_credentials = { # FIXME: secretes_manager
Expand Down
4 changes: 2 additions & 2 deletions modules/database/rds.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ resource "aws_kms_key" "aurora" {
}

resource "aws_kms_alias" "aurora" {
name = "alias/${var.name}-db-key"
name = "alias/${var.name}-db-key-${var.environment}"
target_key_id = aws_kms_key.aurora.key_id
}

resource "aws_rds_cluster" "cluster" {
cluster_identifier = var.name
cluster_identifier = "${var.name}-${var.environment}"
engine = var.database.engine
engine_version = var.database.engine_version
availability_zones = local.zone_names
Expand Down
6 changes: 6 additions & 0 deletions modules/database/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ variable "name" {
type = string
}

variable "environment" {
description = "Resource environment tag (i.e. dev, stage, prod). Used in resource names"
type = string
default = "test"
}

variable "tags" {
description = "Tags to apply to aws resources"
type = map(string)
Expand Down

0 comments on commit 7577af6

Please sign in to comment.