lgallard / terraform-aws-secrets-manager

Terraform module to create Amazon Secrets Manager resources.
Apache License 2.0
63 stars 50 forks source link

Support for cloudposse null-label #12

Closed caulagi closed 3 years ago

caulagi commented 3 years ago

Hi,

I was wondering if you would be open to changing this module to use https://github.com/cloudposse/terraform-null-label for the names and tags of the resources? I have seen null-label being used to streamline naming for different environments. I have been playing around a bit and the output I have so far looks like this -

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_secretsmanager_secret.sm[0] will be created
  + resource "aws_secretsmanager_secret" "sm" {
      + arn                     = (known after apply)
      + description             = "My secret 1"
      + id                      = (known after apply)
      + name                    = "uat1-example-secret-1"
      + name_prefix             = (known after apply)
      + policy                  = (known after apply)
      + recovery_window_in_days = 7
      + rotation_enabled        = (known after apply)
      + rotation_lambda_arn     = (known after apply)
      + tags                    = {
          + "environment" = "uat1"
          + "name"        = "uat1-example-secret"
        }
      + tags_all                = {
          + "environment" = "uat1"
          + "name"        = "uat1-example-secret"
        }

      + rotation_rules {
          + automatically_after_days = (known after apply)
        }
    }

  # aws_secretsmanager_secret.sm[1] will be created
  + resource "aws_secretsmanager_secret" "sm" {
      + arn                     = (known after apply)
      + description             = "This is a key/value secret"
      + id                      = (known after apply)
      + name                    = "uat1-example-secret-2"
      + name_prefix             = (known after apply)
      + policy                  = (known after apply)
      + recovery_window_in_days = 7
      + rotation_enabled        = (known after apply)
      + rotation_lambda_arn     = (known after apply)
      + tags                    = {
          + "environment" = "uat1"
          + "name"        = "uat1-example-secret"
        }
      + tags_all                = {
          + "environment" = "uat1"
          + "name"        = "uat1-example-secret"
        }

      + rotation_rules {
          + automatically_after_days = (known after apply)
        }
    }

  # aws_secretsmanager_secret.sm[2] will be created
  + resource "aws_secretsmanager_secret" "sm" {
      + arn                     = (known after apply)
      + description             = "Another binary secret"
      + id                      = (known after apply)
      + name                    = "uat1-example-secret-3"
      + name_prefix             = (known after apply)
      + policy                  = (known after apply)
      + recovery_window_in_days = 7
      + rotation_enabled        = (known after apply)
      + rotation_lambda_arn     = (known after apply)
      + tags                    = {
          + "app"         = "web"
          + "environment" = "uat1"
          + "name"        = "uat1-example-secret"
        }
      + tags_all                = {
          + "app"         = "web"
          + "environment" = "uat1"
          + "name"        = "uat1-example-secret"
        }

      + rotation_rules {
          + automatically_after_days = (known after apply)
        }
    }

  # aws_secretsmanager_secret_version.sm-sv[0] will be created
  + resource "aws_secretsmanager_secret_version" "sm-sv" {
      + arn            = (known after apply)
      + id             = (known after apply)
      + secret_id      = (known after apply)
      + secret_string  = (sensitive value)
      + version_id     = (known after apply)
      + version_stages = (known after apply)
    }

  # aws_secretsmanager_secret_version.sm-sv[1] will be created
  + resource "aws_secretsmanager_secret_version" "sm-sv" {
      + arn            = (known after apply)
      + id             = (known after apply)
      + secret_id      = (known after apply)
      + secret_string  = (sensitive value)
      + version_id     = (known after apply)
      + version_stages = (known after apply)
    }

  # aws_secretsmanager_secret_version.sm-sv[2] will be created
  + resource "aws_secretsmanager_secret_version" "sm-sv" {
      + arn            = (known after apply)
      + id             = (known after apply)
      + secret_binary  = (sensitive value)
      + secret_id      = (known after apply)
      + version_id     = (known after apply)
      + version_stages = (known after apply)
    }

Plan: 6 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + rotate_secret_arns = []
  + rotate_secret_ids  = []
  + secret_arns        = [
      + (known after apply),
      + (known after apply),
      + (known after apply),
    ]
  + secret_ids         = [
      + (known after apply),
      + (known after apply),
      + (known after apply),
    ]
lgallard commented 3 years ago

@caulagi you can use terraform-null-label or any other naming module to tag your resources by creating your tags in a locals block and passing them as local.tags.

caulagi commented 3 years ago

@lgallard thanks! That works for me!