Skip to content

Terraform module that simplifies the creation of AWS Secrets from Secrets Manager and allows for the creation of the necessary number of secrets in a single module.

License

Notifications You must be signed in to change notification settings

zahornyak/terraform-aws-multiple-secrets

Repository files navigation

AWS Secrets manager multiple secrets creation

GitHub tag (latest by date)

Terraform module that allows for the creation of multiple secrets and significantly simplifies the process of creating them. Especially comfortable with Terragrunt.

secret rotation temporary disabled

Usage

module "secrets" {
  source  = "zahornyak/multiple-secrets/aws"

  secrets = {
    my_secret = {
      name                    = "my_secret_name"
      recovery_window_in_days = 10
      secret_string           = "example"
    }
    your_secret = {
      name                    = "your_secret_name"
      recovery_window_in_days = 10
      secret_binary           = "sha sjhgdhkajwndask"
    }
    foo = {
      name                    = "bar"
      recovery_window_in_days = 0
      secret_string           = "foo-bar"
    }
  }
}

Unlocked secrets

module "secrets" {
  source  = "zahornyak/multiple-secrets/aws"

  secrets = {
    my_secret = {
      name                    = "my_secret_name"
      recovery_window_in_days = 10
      secret_string           = "example"
    }
    your_secret = {
      name                    = "your_secret_name"
      recovery_window_in_days = 10
      secret_binary           = "sha sjhgdhkajwndask"
    }
  }

  # Terraform wont change secret string and binary value
  unlocked = true
}

Dynamically unlocked secrets

module "secrets" {
  source  = "zahornyak/multiple-secrets/aws"

  secrets = {
    my_secret = {
      name                    = "my_secret_name"
      recovery_window_in_days = 10
      secret_string           = "example"
    }
    your_secret = {
      name                    = "your_secret_name"
      recovery_window_in_days = 10
      secret_binary           = "sha sjhgdhkajwndask"
      unlocked                = true   # Terraform wont change secret string and binary value for only that secret
    }
  }
}

Requirements

Name Version
terraform >= 1.4
aws >= 4.37

Providers

Name Version
aws >= 4.37

Modules

No modules.

Resources

Name Type
aws_secretsmanager_secret.this resource
aws_secretsmanager_secret_version.this resource
aws_secretsmanager_secret_version.this_unlocked resource

Inputs

Name Description Type Default Required
recovery_window_in_days Specifies the number of days for recovery window number 30 no
secrets Map of secrets to keep in AWS Secrets Manager any {} no
tags Specifies a tags any {} no
unlocked if true - sets the ignore lifecycle policy and disable terraform managing the version of the resource bool false no

Outputs

Name Description
secret_arns Secrets arns map
secret_ids Secret ids map