# withSecrets

Provides AWS Secrets Manager secrets as environment variables to the given steps.

## Parameters

The `withSecrets` step takes a Map of options and a Closure which defines the steps to execute.

The options available are as follows:

| Name         | Description                                                                                                                                                                                                                         | Type        | Default | Required |
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|---------|----------|
| awsAccountId | The AWS account ID which the `awsRole` belongs to.                                                                                                                                                                                  | `String`    | -       | `no`     |
| awsRole      | The name of the AWS role to assume to access the secrets. This role must have the `GetSecretValue` permission on all the provided secrets.                                                                                          | `String`    | -       | no       |
| secrets      | A list of secrets, each of which specifies the secret ID as `id`, the name of the environment variable to set as `environmentVariable` and optionally the AWS region that the secret belongs in as `region` (defaults to us-east-1) | `List<Map>` | -       | `yes`    |

## Examples

Use secrets, explicitly assuming a role in the specified AWS account which has access to read the provided secrets:

```groovy
withSecrets(awsAccountId: '123456789012', awsRole: 'role-to-assume', secrets: [
    [id: 'prod/foo', environmentVariable: 'FOO'],
    [id: 'prod/bar', environmentVariable: 'BAR']
]) {
    // Values of secrets are now available as environment variables $FOO and $BAR
}
```

Use secrets without providing an AWS account or role. This assumes that the calling pipeline has already provided the necessary credentials to access the secrets (e.g. via the `withAWS` step).

```groovy
withSecrets(secrets: [
    [id: 'prod/foo', environmentVariable: 'FOO'],
    [id: 'prod/bar', environmentVariable: 'BAR']
]) {
    // Values of secrets are now available as environment variables $FOO and $BAR
}
```
