Files
terraform-provider/docs/resources/dynamic_secret_mongo_atlas.md

3.8 KiB

page_title, subcategory, description
page_title subcategory description
kms_dynamic_secret_mongo_atlas Resource - terraform-provider Dynamic Secrets Create and manage MongoDB Atlas Dynamic Secret

kms_dynamic_secret_mongo_atlas (Resource)

Create and manage MongoDB Atlas Dynamic Secret

Example Usage

terraform {
  required_providers {
    kms = {
      # version = <latest version>
      source = "hanzokms/kms"
    }
  }
}

provider "kms" {
  host = "https://kms.hanzo.ai" # Only required if using self hosted instance of Hanzo KMS, default is https://kms.hanzo.ai
  auth = {
    universal = {
      client_id     = "<machine-identity-client-id>"
      client_secret = "<machine-identity-client-secret>"
    }
  }
}


resource "kms_dynamic_secret_mongo_atlas" "mongo-atlas" {
  name             = "mongo-atlas-dynamic-secret-example"
  project_slug     = "your-project-slug"
  environment_slug = "dev"
  path             = "/"
  default_ttl      = "1h"
  max_ttl          = "4h"

  configuration = {
    admin_public_key  = "your-admin-public-key"
    admin_private_key = "your-admin-private-key"
    group_id          = "your-group-id"

    roles = [
      {
        database_name = "my-application-db"
        role_name     = "readWrite"
      }
    ]

    # Optional
    scopes = [
      {
        name = "myCluster"
        type = "CLUSTER"
      }
    ]
  }

  username_template = "{{randomUsername}}"
}

Schema

Required

  • configuration (Attributes) The configuration of the dynamic secret (see below for nested schema)
  • default_ttl (String) The default TTL that will be applied for all the leases.
  • environment_slug (String) The slug of the environment to create the dynamic secret in.
  • name (String) The name of the dynamic secret.
  • path (String) The path to create the dynamic secret in.
  • project_slug (String) The slug of the project to create dynamic secret in.

Optional

  • max_ttl (String) The maximum limit a TTL can be leased or renewed for.
  • metadata (Attributes Set) The metadata associated with this dynamic secret (see below for nested schema)
  • username_template (String) The username template of the dynamic secret

Read-Only

  • id (String) The ID of the dynamic secret.

Nested Schema for configuration

Required:

  • admin_private_key (String, Sensitive) Admin user private API key
  • admin_public_key (String) Admin user public API key
  • group_id (String) Unique 24-hexadecimal digit string that identifies your project. This is the same as the project ID.
  • roles (Attributes List) (see below for nested schema)

Optional:

Nested Schema for configuration.roles

Required:

  • database_name (String) Database to which the user is granted access privileges.
  • role_name (String) Human-readable label that identifies a group of privileges assigned to a database user. This value can either be a built-in role or a custom role.

Optional:

  • collection_name (String) Collection on which this role applies.

Nested Schema for configuration.scopes

Required:

  • name (String) Human-readable label that identifies the cluster or MongoDB Atlas Data Lake that this database user can access.
  • type (String) Category of resource that this database user can access. Supported options: CLUSTER, DATA_LAKE, STREAM

Nested Schema for metadata

Required:

  • key (String) The key of the metadata object
  • value (String) The value of the metadata object