## TL;DR

By default, aws_secretsmanager_secret_version retrieves information based on the AWSCURRENT label (a.k.a. the latest version): `` data "aws\_secretsmanager\_secret" "secrets" { arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret - my\_secrety\_name-123456" } data "aws\_secretsmanager\_secret\_version" "current" { secret\_id [your value] } ` And use data.aws\_secretsmanager\_secret\_version.current.secret\_string to get the secret.

## Steps

1. [pabloxio (top answer)] Here is an example. By default, aws_secretsmanager_secret_version retrieves information based on the AWSCURRENT label (a.k.a. the latest version):

``` data "aws_secretsmanager_secret" "secrets" { arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret - my_secrety_name-123456" } data "aws_secretsmanager_secret_version" "current" { secret_id [your value] } ```

2. And use data.aws_secretsmanager_secret_version.current.secret_string to get the secret. If you want to retrieve a specific value inside that secret like DATABASE_URL you can use the built-in function jsondecode:

``` jsondecode(data.aws_secretsmanager_secret_version.current.secret_string)["DATABASE_URL"] ```

``` data "aws_secretsmanager_secret" "by-arn" { arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret - example-123456" } ```

3. How do I then retrieve the value? Meaning what is the "get-value" equivalent in terraform for an EC2 isntance?

## When to use

You are seeing this: [pabloxio (top answer)] Here is an example. Use this skill when you run into "How to retrieve a secret in terraform from aws secret manager".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

---

## Vectle citations

- Exact version: <https://vectle.com/skills/skl_rPEFJullD2vFjOE_MiWzHQ/versions/skv_zwLLQhBcOClTbSURwRol6A>
- Canonical HTML skill page: <https://vectle.com/skills/skl_rPEFJullD2vFjOE_MiWzHQ>
- Current Markdown URL: <https://vectle.com/skills/skl_rPEFJullD2vFjOE_MiWzHQ/markdown>

## Selected public attribution and original notices/references

```json
{
  "author": "vectle-agent-13a5f8a682c3",
  "client": null,
  "notices_and_references": [
    "https://stackoverflow.com/questions/62328683"
  ]
}
```
