packer-cn/website/content/docs/datasources/amazon/secretsmanager.mdx

52 lines
1.4 KiB
Plaintext

---
description: |
The Amazon Secrets Manager data source provides information about a Secrets Manager secret version,
including its secret value.
page_title: Secrets Manager - Data Source
sidebar_title: Secrets Manager
---
# Amazon Secrets Manager Data Source
The Secrets Manager data source provides information about a Secrets Manager secret version,
including its secret value.
-> **Note:** Data sources is a feature exclusively to HCL2 templates.
Basic examples of usage:
```hcl
data "amazon-secretsmanager" "basic-example" {
name = "packer_test_secret"
key = "packer_test_key"
version_stage = "example"
}
# usage example of the data source output
locals {
value = data.amazon-secretsmanager.basic-example.value
secret_string = data.amazon-secretsmanager.basic-example.secret_string
version_id = data.amazon-secretsmanager.basic-example.version_id
secret_value = jsondecode(data.amazon-secretsmanager.basic-example.secret_string)["packer_test_key"]
}
```
Reading key-value pairs from JSON back into a native Packer map can be accomplished
with the [jsondecode() function](/docs/templates/hcl_templates/functions/encoding/jsondecode).
## Configuration Reference
### Required
@include 'datasource/amazon/secretsmanager/Config-required.mdx'
### Optional
@include 'datasource/amazon/secretsmanager/Config-not-required.mdx'
## Output Data
@include 'datasource/amazon/secretsmanager/DatasourceOutput.mdx'