Skip to content

Commit

Permalink
feat(terraform): add tags variable
Browse files Browse the repository at this point in the history
A map of tags to assign to all resources
deployed with this module.
  • Loading branch information
diodonfrost committed Jan 1, 2021
1 parent 417deb7 commit 19bb8d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module "nuke_everything_older_than_7d" {
| cloudwatch_schedule_expression | The scheduling expression | string | `"cron(0 22 ? * MON-FRI *)"` | yes |
| exclude_resources | Define the resources that will be not destroyed | string | null | no |
| older_than | Only destroy resources that were created before a certain period | string | 0d | no |
| tags | A map of tags to assign to the resources. | map(any) | null | no |

## Outputs

Expand Down
4 changes: 4 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ resource "aws_iam_role" "this" {
name = "${var.name}-lambda-nuke"
description = "Allows Lambda functions to destroy all aws resources"
assume_role_policy = data.aws_iam_policy_document.this.json
tags = var.tags
}

data "aws_iam_policy_document" "this" {
Expand Down Expand Up @@ -312,6 +313,7 @@ resource "aws_lambda_function" "this" {
runtime = "python3.7"
timeout = "900"
kms_key_arn = var.kms_key_arn == null ? "" : var.kms_key_arn
tags = var.tags

environment {
variables = {
Expand All @@ -331,6 +333,7 @@ resource "aws_cloudwatch_event_rule" "this" {
name = "trigger-lambda-nuke-${var.name}"
description = "Trigger lambda nuke"
schedule_expression = var.cloudwatch_schedule_expression
tags = var.tags
}

resource "aws_cloudwatch_event_target" "this" {
Expand All @@ -349,4 +352,5 @@ resource "aws_lambda_permission" "this" {
resource "aws_cloudwatch_log_group" "this" {
name = "/aws/lambda/${var.name}"
retention_in_days = 14
tags = var.tags
}
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ variable "older_than" {
default = "0d"
}

variable "tags" {
description = "A map of tags to assign to the resources."
type = map(any)
default = null
}

0 comments on commit 19bb8d4

Please sign in to comment.