--- subcategory: "Secrets Manager" layout: "aws" page_title: "AWS: aws_secretsmanager_secret" description: |- Provides a resource to manage AWS Secrets Manager secret metadata --- # Resource: aws_secretsmanager_secret Provides a resource to manage AWS Secrets Manager secret metadata. To manage secret rotation, see the [`aws_secretsmanager_secret_rotation` resource](/docs/providers/aws/r/secretsmanager_secret_rotation.html). To manage a secret value, see the [`aws_secretsmanager_secret_version` resource](/docs/providers/aws/r/secretsmanager_secret_version.html). ## Example Usage ### Basic ```terraform resource "aws_secretsmanager_secret" "example" { name = "example" } ``` ### Managed External Secret ```terraform resource "aws_secretsmanager_secret" "example" { name = "bigid-client-secret" type = "BigIDClientSecret" } ``` For more information about managed external secrets and supported partners, see the [AWS documentation](https://docs.aws.amazon.com/secretsmanager/latest/userguide/managed-external-secrets.html). ## Argument Reference This resource supports the following arguments: * `description` - (Optional) Description of the secret. * `force_overwrite_replica_secret` - (Optional) Accepts boolean value to specify whether to overwrite a secret with the same name in the destination Region. * `kms_key_id` - (Optional) ARN or ID of the AWS KMS key to be used to encrypt the secret values in the versions stored in this secret. If you need to reference a CMK in a different account, you can use only the key ARN. If you don't specify this value, then Secrets Manager defaults to using the AWS account's default KMS key (the one named `aws/secretsmanager`). If the default KMS key with that name doesn't yet exist, then AWS Secrets Manager creates it for you automatically the first time. * `name` - (Optional) Friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters: `/_+=.@-` Conflicts with `name_prefix`. * `name_prefix` - (Optional) Creates a unique name beginning with the specified prefix. Conflicts with `name`. * `policy` - (Optional) Valid JSON document representing a [resource policy](https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_resource-based-policies.html). For more information about building AWS IAM policy documents with Terraform, see the [AWS IAM Policy Document Guide](https://learn.hashicorp.com/terraform/aws/iam-policy). Removing `policy` from your configuration or setting `policy` to null or an empty string (i.e., `policy = ""`) _will not_ delete the policy since it could have been set by `aws_secretsmanager_secret_policy`. To delete the `policy`, set it to `"{}"` (an empty JSON document). * `recovery_window_in_days` - (Optional) Number of days that AWS Secrets Manager waits before it can delete the secret. This value can be `0` to force deletion without recovery or range from `7` to `30` days. The default value is `30`. * `region` - (Optional) Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the [provider configuration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#aws-configuration-reference). * `replica` - (Optional) Configuration block to support secret replication. See details below. * `tags` - (Optional) Key-value map of user-defined tags that are attached to the secret. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. * `type` - (Optional) Type of secret for managed external secrets. Valid values are `SalesforceClientSecret`, `BigIDClientSecret`, and `SnowflakeKeyPairAuthentication`. For more information about supported partners and their specific requirements, see [Managed external secret partners](https://docs.aws.amazon.com/secretsmanager/latest/userguide/mes-partners.html). This attribute cannot be changed after creation. ### `replica` Block * `kms_key_id` - (Optional) ARN, Key ID, or Alias of the AWS KMS key within the region secret is replicated to. If one is not specified, then Secrets Manager defaults to using the AWS account's default KMS key (`aws/secretsmanager`) in the region or creates one for use if non-existent. * `region` - (Required) Region for replicating the secret. ## Attribute Reference This resource exports the following attributes in addition to the arguments above: * `arn` - ARN of the secret. * `id` - ARN of the secret. * `replica` - Attributes of a replica are described below. * `tags_all` - Map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block). ### `replica` Block * `last_accessed_date` - Date that you last accessed the secret in the Region. * `status` - Status can be `InProgress`, `Failed`, or `InSync`. * `status_message` - Message such as `Replication succeeded` or `Secret with this name already exists in this region`. ## Import In Terraform v1.12.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `identity` attribute. For example: ```terraform import { to = aws_secretsmanager_secret.example identity = { "arn" = "arn:aws:secretsmanager:us-east-1:123456789012:secret:example-123456" } } resource "aws_secretsmanager_secret" "example" { ### Configuration omitted for brevity ### } ``` ### Identity Schema #### Required - `arn` (String) ARN of the Secrets Manager secret. In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import `aws_secretsmanager_secret` using the secret ARN. For example: ```terraform import { to = aws_secretsmanager_secret.example id = "arn:aws:secretsmanager:us-east-1:123456789012:secret:example-123456" } ``` Using `terraform import`, import `aws_secretsmanager_secret` using the secret ARN. For example: ```console % terraform import aws_secretsmanager_secret.example arn:aws:secretsmanager:us-east-1:123456789012:secret:example-123456 ```