From 61e6cbb0f640c8bc62a66a9fc912310dfac1af3e Mon Sep 17 00:00:00 2001 From: Aaron Miller <32234519+ac-miller@users.noreply.github.com> Date: Mon, 11 Jan 2021 15:18:33 -0600 Subject: [PATCH] Adding Resource Tags (#20) * Added repo, owner, and desc tags on resources Co-authored-by: Aaron Miller --- README.md | 3 +++ examples/complete/main.tf | 3 +++ examples/complete/terraform.tfvars | 2 ++ examples/complete/variables.tf | 15 +++++++++++++++ load_balancers.tf | 2 ++ main.tf | 6 ++++++ variables.tf | 15 +++++++++++++++ 7 files changed, 46 insertions(+) diff --git a/README.md b/README.md index 948d670..17b9585 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ This module will use SemVer, and will stay on v0.X for the foreseeable future | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | additional\_tag\_map | Map of additional tags to apply to every taggable resource. If you don't want any use an empty map - '{}' | `map(string)` | n/a | yes | +| description | Short description of what/why this product exists | `string` | n/a | yes | | hosted\_zone\_domain\_name | Domain name of the hosted zone to create records in | `string` | n/a | yes | | hosted\_zone\_id | ID of Route53 hosted zone to create records in | `string` | n/a | yes | | instance\_type | Instance type to use for the cluster nodes | `string` | n/a | yes | @@ -185,8 +186,10 @@ This module will use SemVer, and will stay on v0.X for the foreseeable future | node\_group\_2\_subnet\_id | Subnet to deploy node group 2 to | `string` | n/a | yes | | node\_group\_3\_subnet\_id | Subnet to deploy node group 3 to | `string` | n/a | yes | | node\_volume\_size | Volume size of worker node disk in GB | `string` | n/a | yes | +| owner | Email address of owner | `string` | n/a | yes | | rancher\_letsencrypt\_email | Email address to use for Rancher's LetsEncrypt certificate | `string` | n/a | yes | | rancher\_letsencrypt\_environment | LetsEncrypt environment to use - Valid options: 'staging', 'production' | `string` | n/a | yes | +| repo | Repo URL that is responsible for this resource | `string` | n/a | yes | | stage | Stage, e.g. 'prod', 'staging', 'dev' | `string` | n/a | yes | | subdomain\_rancher | Rancher's endpoint will be '{subdomain\_rancher}.{hosted\_zone\_domain\_name}'. {subdomain\_rancher} can be multi-layered e.g. 'rancher.foo.bar' | `string` | n/a | yes | | vpc\_id | ID of the VPC to deploy to | `string` | n/a | yes | diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 9dd8a30..07de866 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -56,6 +56,7 @@ module "rke_rancher_master_cluster" { //source = "git::https://path/to/repo.git?ref=tags/x.y.z" source = "../.." additional_tag_map = {} + description = var.description instance_type = var.instance_type kubernetes_version = var.kubernetes_version name = var.name @@ -64,6 +65,8 @@ module "rke_rancher_master_cluster" { node_group_2_subnet_id = module.subnets.public_subnet_ids[1] node_group_3_subnet_id = module.subnets.public_subnet_ids[2] node_volume_size = var.node_volume_size + owner = var.owner + repo = var.repo stage = var.stage vpc_id = module.vpc.vpc_id hosted_zone_id = var.hosted_zone_id diff --git a/examples/complete/terraform.tfvars b/examples/complete/terraform.tfvars index f930c9b..48697bb 100644 --- a/examples/complete/terraform.tfvars +++ b/examples/complete/terraform.tfvars @@ -2,6 +2,8 @@ region = "us-east-1" namespace = "saic-oss" stage = "example" name = "terraform-aws-rke-rancher-master-cluster" +repo = "https://github.com/saic-oss/terraform-aws-rke-rancher-master-cluster" +description = "Example deployment of the Rancher Master cluster" instance_type = "t3a.medium" kubernetes_version = "v1.18.9-rancher1-1" node_volume_size = "50" diff --git a/examples/complete/variables.tf b/examples/complete/variables.tf index f3a8989..6b5c652 100644 --- a/examples/complete/variables.tf +++ b/examples/complete/variables.tf @@ -13,6 +13,21 @@ variable "name" { description = "Solution name" } +variable "repo" { + type = string + description = "Repo URL that is responsible for this resource" +} + +variable "owner" { + type = string + description = "Email address of owner" +} + +variable "description" { + type = string + description = "Short description of what/why this product exists" +} + variable "region" { type = string description = "AWS region to deploy to" diff --git a/load_balancers.tf b/load_balancers.tf index 6de7495..2bef78c 100644 --- a/load_balancers.tf +++ b/load_balancers.tf @@ -30,4 +30,6 @@ resource "aws_elb" "ingress" { #tfsec:ignore:AWS005 } instances = concat(tolist(aws_instance.node_group_1.*.id), tolist(aws_instance.node_group_2.*.id), tolist(aws_instance.node_group_3.*.id)) idle_timeout = 1800 + + tags = module.label.tags } diff --git a/main.tf b/main.tf index d964f2e..7742a14 100644 --- a/main.tf +++ b/main.tf @@ -30,4 +30,10 @@ module "label" { stage = var.stage name = var.name additional_tag_map = var.additional_tag_map + + tags = { + "Repo" = "${var.repo}", + "Owner" = "${var.owner}", + "Description" = "${var.description}" + } } diff --git a/variables.tf b/variables.tf index 9f467cf..dc9ea71 100644 --- a/variables.tf +++ b/variables.tf @@ -13,6 +13,21 @@ variable "name" { description = "Solution name" } +variable "repo" { + type = string + description = "Repo URL that is responsible for this resource" +} + +variable "owner" { + type = string + description = "Email address of owner" +} + +variable "description" { + type = string + description = "Short description of what/why this product exists" +} + variable "additional_tag_map" { type = map(string) description = "Map of additional tags to apply to every taggable resource. If you don't want any use an empty map - '{}'"