Skip to content

Commit

Permalink
[ISSUE-14] Add tags to resources (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfcaro committed Jul 21, 2021
1 parent 150874a commit 0700c92
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 10 deletions.
57 changes: 57 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ In order to run all checks at any point run the following command:

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
| <a name="provider_random"></a> [random](#provider\_random) | n/a |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.50.0 |
| <a name="provider_random"></a> [random](#provider\_random) | 3.1.0 |

## Modules

Expand Down Expand Up @@ -76,6 +76,7 @@ In order to run all checks at any point run the following command:
| <a name="input_public_subnets_ids"></a> [public\_subnets\_ids](#input\_public\_subnets\_ids) | List of Public Subnets IDs | `list(string)` | n/a | yes |
| <a name="input_region"></a> [region](#input\_region) | AWS Region the infrastructure is hosted in | `string` | n/a | yes |
| <a name="input_sonarqube_image"></a> [sonarqube\_image](#input\_sonarqube\_image) | Sonarqube image | `string` | `"sonarqube:lts"` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Resource tags | `map(string)` | `{}` | no |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | ID of the VPC | `string` | n/a | yes |

## Outputs
Expand Down
21 changes: 14 additions & 7 deletions database.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ resource "aws_kms_key" "encryption_key" {
description = "Sonar Encryption Key"
is_enabled = true
enable_key_rotation = true

tags = merge({
Name = "${var.name_prefix}-sonar-kms-key"
}, var.tags)
}

#------------------------------------------------------------------------------
Expand All @@ -13,6 +17,10 @@ resource "aws_kms_key" "encryption_key" {
resource "aws_db_subnet_group" "aurora_db_subnet_group" {
name = "${var.name_prefix}-sonar-aurora-db-subnet-group"
subnet_ids = var.private_subnets_ids

tags = merge({
Name = "${var.name_prefix}-sonar-aurora-db-subnet-group"
}, var.tags)
}

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -43,9 +51,9 @@ resource "aws_rds_cluster" "aurora_db" {
backup_retention_period = 3
preferred_backup_window = "07:00-09:00"
skip_final_snapshot = true
tags = {
tags = merge({
Name = "${var.name_prefix}-sonar-aurora-db"
}
}, var.tags)
}

#------------------------------------------------------------------------------
Expand All @@ -60,9 +68,9 @@ resource "aws_rds_cluster_instance" "aurora_db_cluster_instances" {
engine_version = local.sonar_db_engine_version
instance_class = local.sonar_db_instance_size
publicly_accessible = true
tags = {
tags = merge({
Name = "${var.name_prefix}-sonar-aurora-db-cluster-instances-${count.index}"
}
}, var.tags)
}

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -91,8 +99,7 @@ resource "aws_security_group" "aurora_sg" {
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
tags = merge({
Name = "${var.name_prefix}-sonar-aurora-sg"
}
}, var.tags)
}

57 changes: 57 additions & 0 deletions examples/test/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module "aws_cw_logs" {
# source = "../terraform-aws-cloudwatch-logs"

logs_path = "/ecs/service/${var.name_prefix}-sonar"
tags = var.tags
}

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -93,4 +94,6 @@ module "ecs_fargate" {
}
secretOptions = null
}
}

tags = var.tags
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ variable "name_prefix" {
description = "Name prefix for resources on AWS"
}

variable "tags" {
type = map(string)
default = {}
description = "Resource tags"
}

#------------------------------------------------------------------------------
# AWS REGION
#------------------------------------------------------------------------------
Expand Down

0 comments on commit 0700c92

Please sign in to comment.