OpsCanary
Back to daily brief
securitysecretsPractitioner

Mastering AWS Secrets Manager: Secrets Management in Production

5 min read External Secrets DocsApr 27, 2026
Share
PractitionerHands-on experience recommended

AWS Secrets Manager exists to solve the problem of securely storing and managing sensitive information, such as API keys and database credentials. It allows you to create, manage, and retrieve secrets with fine-grained access control, ensuring that only the right entities can access critical information.

At its core, AWS Secrets Manager operates by creating a 'SecretStore' that points to your secrets within a specific AWS account and region. Each time you update a secret, a new version is created, allowing you to roll back if necessary. You can define an IAM Policy to restrict access to secrets, such as those matching a specific naming pattern like 'dev-*'. For advanced access control, you can attach a resource-based policy to the secret, enabling cross-account access. When fetching secrets, using BatchGetSecretValue with a defined path prefix or tags filter can help you avoid excessive API calls, which is crucial in a production setting.

In practice, you need to be aware of certain gotchas. For instance, if you're using a ClusterSecretStore, ensure that you provide the correct namespaces for your access keys. Also, remember that the resource policy is synchronized with every reconciliation, meaning any changes to tags or policies will be reflected immediately. This can lead to unintended deletions if you're not careful. Lastly, the resource policy permissions are only necessary if you're managing resource-based policies on secrets, so tailor your IAM policies accordingly.

Key takeaways

  • Create a SecretStore to manage secrets within a specific AWS account and region.
  • Use IAM Policies to restrict access to secrets based on naming patterns like 'dev-*'.
  • Implement resource-based policies for advanced access control and cross-account access.
  • Be cautious with tag synchronization in PushSecret; it can lead to unintended deletions.
  • Utilize BatchGetSecretValue with path prefixes to minimize API calls in production.

Why it matters

In production, securely managing secrets is critical to prevent unauthorized access to sensitive data. AWS Secrets Manager streamlines this process, reducing the risk of exposure and ensuring compliance with security best practices.

Code examples

YAML
apiVersion:external-secrets.io/v1kind:SecretStoremetadata:name:aws-secretsmanagerspec:provider:aws:service:SecretsManager# define a specific role to limit access# to certain secrets.# role is a optional field that# can be omitted for test purposesrole:arn:aws:iam::123456789012:role/external-secretsregion:eu-central-1auth:secretRef:accessKeyIDSecretRef:name:awssm-secretkey:access-keysecretAccessKeySecretRef:name:awssm-secretkey:secret-access-key
JSON
{"Version":"2012-10-17","Statement":[{"Action":["secretsmanager:ListSecrets","secretsmanager:BatchGetSecretValue"],"Effect":"Allow","Resource":"*"},{"Effect":"Allow","Action":["secretsmanager:GetResourcePolicy","secretsmanager:GetSecretValue","secretsmanager:DescribeSecret","secretsmanager:ListSecretVersionIds"],"Resource":["arn:aws:secretsmanager:us-west-2:111122223333:secret:dev-*"]}]}
YAML
apiVersion:external-secrets.io/v1alpha1kind:PushSecretmetadata:name:pushsecret-example# Customisablenamespace:teamb# Same of the SecretStoresspec:deletionPolicy:DeleterefreshInterval:1h0m0s# Refresh interval for which push secret will reconcilesecretStoreRefs:# A list of secret stores to push secrets to-name:teamb-secret-storekind:SecretStoreselector:secret:name:my-secret# Source Kubernetes secret to be pusheddata:-match:secretKey:key1# Source Kubernetes secret key to be pushedremoteRef:remoteKey:teamb-my-first-parameter-3# Remote reference (where the secret is going to be pushed)metadata:apiVersion:kubernetes.external-secrets.io/v1alpha1kind:PushSecretMetadataspec:kmsKeyID:bb123123-b2b0-4f60-ac3a-44a13f0e6b6c# When not set, default to alias/aws/secretsmanagersecretPushFormat:string# When not set, default to binarydescription:"secret'managed-by:secret-manager'from'secret-store:teamb-secret-store'"tags:secret-store:teamb-secret-storerefresh-interval:1h

When NOT to use this

The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.

Want the complete reference?

Read official docs

Test what you just learned

Quiz questions written from this article

Take the quiz →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.