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

Extra tags #47

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ so don't bother manually changing them.
| snapshot\_identifier | DB snapshot to create this database from | `string` | `""` | no |
| storage\_encrypted | Specifies whether the underlying storage layer should be encrypted | `string` | `"true"` | no |
| username | Master DB username | `string` | `"root"` | no |
| extra_tags | A map of additional tags for resources | `map` | `{}` | no |

## Outputs

Expand Down
17 changes: 11 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ resource "aws_db_subnet_group" "main" {
description = "Group of DB subnets"
subnet_ids = var.subnets

tags = {
tags = merge({
envname = var.envname
envtype = var.envtype
}
}, var.extra_tags)
}

// Create single DB instance
Expand All @@ -32,10 +32,10 @@ resource "aws_rds_cluster_instance" "cluster_instance_0" {
promotion_tier = "0"
performance_insights_enabled = var.performance_insights_enabled

tags = {
tags = merge({
envname = var.envname
envtype = var.envtype
}
}, var.extra_tags)
}

// Create 'n' number of additional DB instance(s) in same cluster
Expand All @@ -58,10 +58,10 @@ resource "aws_rds_cluster_instance" "cluster_instance_n" {
promotion_tier = count.index + 1
performance_insights_enabled = var.performance_insights_enabled

tags = {
tags = merge({
envname = var.envname
envtype = var.envtype
}
}, var.extra_tags)
}

// Create DB Cluster
Expand Down Expand Up @@ -89,6 +89,11 @@ resource "aws_rds_cluster" "default" {
db_cluster_parameter_group_name = var.db_cluster_parameter_group_name
iam_database_authentication_enabled = var.iam_database_authentication_enabled
enabled_cloudwatch_logs_exports = var.enabled_cloudwatch_logs_exports

tags = merge({
envname = var.envname
envtype = var.envtype
}, var.extra_tags)
}

// Geneate an ID when an environment is initialised
Expand Down
13 changes: 13 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,16 @@ output "reader_endpoint" {
output "cluster_identifier" {
value = join("", aws_rds_cluster.default.*.id)
}

// List of all DB instance ids running in cluster
output "all_instance_ids_list" {
value = [concat(
aws_rds_cluster_instance.cluster_instance_0.*.id,
aws_rds_cluster_instance.cluster_instance_n.*.id,
)]
}

// A list of cluster members
output "cluster_members" {
value = flatten(aws_rds_cluster.default.*.cluster_members)
}
10 changes: 8 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ variable "storage_encrypted" {
}

variable "kms_key_id" {
type = string
default = ""
type = string
default = ""
description = "Specify the KMS Key to use for encryption"
}

Expand Down Expand Up @@ -265,3 +265,9 @@ variable "enabled_cloudwatch_logs_exports" {
default = []
description = "List of log types to export to CloudWatch Logs. If omitted, no logs will be exported. The following log types are supported: audit, error, general, slowquery, postgresql."
}

variable "extra_tags" {
type = map(string)
default = {}
description = "A map of extra tags for resources"
}