AWS Secrets Manager vault

You can set up an AWS Secrets Manager vault in one of the following ways:

The Vault entity can only be used once the database is initialized. Secrets for values that are used before the database is initialized can’t make use of the Vaults entity.

AWS Secrets Manager credentials

To access secrets stored in AWS Secrets Manager, Kong Gateway needs an IAM Role that has sufficient permissions to read the required secret values.

Kong Gateway can automatically fetch IAM role credentials based on your AWS environment, using the following precedence order:

  1. Fetch from credentials defined in environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
  2. Fetch from profile and credential file, defined by AWS_PROFILE and AWS_SHARED_CREDENTIALS_FILE.
  3. Fetch from an ECS container credential provider.
  4. Fetch from an EKS IAM roles for service account.
  5. Fetch from EC2 IMDS metadata. Both v1 and v2 are supported.

Kong Gateway also supports role assuming using vaults.config.assume_role_arn and vaults.config.role_session_name, which lets you use a different IAM role to fetch secrets from AWS Secrets Manager. This is a common practice for permission division, governance, and cross-AWS account management.

Note: IAM Identity Center credential provider and process credential provider are not supported.

Create an AWS Secrets Manager vault

The following example creates an aws Vault entity in the AWS region us-east-1. The Vault name must be aws. The vault.prefix value can be your own custom prefix:

Vault configuration options

The following table lists all of the available configuration parameters for an AWS Secrets Manager Vault:

Field name

Parameter format

Description

AWS region
  • Vault entity: vaults.config.region
  • kong.conf parameter: vault_aws_region
  • Environment variable: KONG_VAULT_AWS_REGION
The AWS region where your vault is located.
AWS Secrets Manager Endpoint URL
v3.4+
  • Vault entity: vaults.config.endpoint_url
  • kong.conf parameter: vault_aws_endpoint_url
  • Environment variable: KONG_VAULT_AWS_ENDPOINT_URL
The endpoint URL of the AWS Secrets Manager service. If not specified, the default is https://secretsmanager.{region}.amazonaws.com. You can override this by specifying a complete URL including the http/https scheme.
Assume AWS IAM Role ARN
v3.4+
  • Vault entity: vaults.config.assume_role_arn
  • kong.conf parameter: vault_aws_assume_role_arn
  • Environment variable: KONG_VAULT_AWS_ASSUME_ROLE_ARN
The target IAM role ARN to assume when accessing AWS Secrets Manager. If specified, the backend will assume this role using your current runtime’s IAM Role. Leave empty if not using an assumed role.
Role Session Name
v3.4+
  • Vault entity: vaults.config.role_session_name
  • kong.conf parameter: vault_aws_role_session_name
  • Environment variable: KONG_VAULT_AWS_ROLE_SESSION_NAME
The session name used when assuming a role. Defaults to KongVault.
AWS STS Endpoint URL
v3.8+
  • Vault entity: vaults.config.sts_endpoint_url
  • kong.conf parameter: vault_aws_sts_endpoint_url
  • Environment variable: KONG_VAULT_AWS_STS_ENDPOINT_URL
A custom STS endpoint URL used for IAM role assumption. Overrides the default https://sts.amazonaws.com or regional variant https://sts.<region>.amazonaws.com. Include the full http/https scheme. Only specify this if using a private VPC endpoint for STS.
TTL
  • Vault entity: vaults.config.ttl
  • kong.conf parameter: vault_aws_ttl
  • Environment variable: KONG_VAULT_AWS_TTL
The time-to-live (in seconds) for cached secrets. A value of 0 (default) disables rotation. If non-zero, use at least 60 seconds.
Negative TTL
  • Vault entity: vaults.config.neg_ttl
  • kong.conf parameter: vault_aws_neg_ttl
  • Environment variable: KONG_VAULT_AWS_NEG_TTL
The TTL (in seconds) for caching failed secret lookups. A value of 0 (default) disables negative caching. When the TTL expires, Kong will retry fetching the secret.
Resurrect TTL
  • Vault entity: vaults.config.resurrect_ttl
  • kong.conf parameter: vault_aws_resurrect_ttl
  • Environment variable: KONG_VAULT_AWS_RESURRECT_TTL
The duration (in seconds) for which expired secrets will continue to be used if the vault is unreachable or the secret is deleted. After this time, Kong stops retrying. The default is 1e8 seconds (~3 years) to ensure resilience during unexpected issues.
Base64 Decode
v3.11+
  • Vault entity: vaults.config.base64_decode
  • kong.conf parameter: vault_aws_decode_base64
  • Environment variable: KONG_VAULT_AWS_DECODE_BASE64
Decode all secrets in this vault as base64. Useful for binary data. If some of the secrets in the vault are not base64-encoded, an error will occur when using them. We recommend creating a separate vault for base64 secrets.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!