Easily Consume AWS Secrets Manager Secrets From Your Amazon EKS Workloads
Leverage secret stores without complex code modifications.
Step 1: Set Environment Variables
Step 2: Create Secret in AWS Secrets Manager
Step 3: Create IAM Policy for Accessing the Secret in AWS Secrets Manager
Step 4: Create IAM Role and Associate With Kubernetes Service Account
Step 5: Install AWS Secrets and Configuration Provider and Secrets Store CSI Driver
Step 6: Create ASCP SecretProviderClass Resource
About | |
---|---|
✅ AWS experience | 200 - Intermediate |
⏱ Time to complete | 30 minutes |
🧩 Prerequisites | - AWS Account |
📢 Feedback | Any feedback, issues, or just a 👍 / 👎 ? |
⏰ Last Updated | 2023-10-30 |
- Install the latest version of kubectl. To check your version, run:
kubectl version --short
- Install the latest version of eksctl. To check your version, run:
eksctl info
- Install the latest version of Helm. To check your version, run:
helm version
- Install the latest version of the AWS CLI (v2). To check your version, run:
aws --version
- Get IAM OIDC provider configured on an existing EKS cluster.
- Secret Creation — Creation of an application secret in AWS Secrets Manager to be consumed by the sample pod.
- Authentication — Necessary IAM Role for Service Account (IRSA) mappings to enable communication between Kubernetes pods and AWS. This includes the Pod service account that will be used to access the AWS Secrets Manager secret via the AWS Secrets and Configuration Provider (ASCP).
- ASCP Setup — Deployment of the AWS Secrets and Configuration Provider (ASCP) and the Kubernetes Secrets Store CSI Driver.
- Sample Application Deployment — Deploy a sample pod to mount the secret from AWS Secrets Manager and execute a command in the pod to validate the secret is accessible.
Note that AWS Secrets Manager includes a 30-day free trial period that starts when you store your first secret. If you have already stored a secret and are past the 30-day mark, additional charges based on usage will apply.
- First, confirm that you are operating within the correct cluster context. This ensures that any subsequent commands are sent to the intended Kubernetes cluster. You can verify the current context by executing the following command:
- Define the
CLUSTER_NAME
environment variable for your EKS cluster. Replace the sample value for clusterregion
. If you are using your own existing EKS cluster, replace the sample value forname
.
- Define the
CLUSTER_REGION
environment variable for your EKS cluster. Replace the sample value for clusterregion
.
$SECRET_ARN
variable from the previous step, you'll specify which secret the IAM policy should apply to. This approach ensures that only the specified secret can be accessed by authorized entities within your Kubernetes cluster. We will associate this IAM Policy to a Kubernetes service account in the next step.STATUS
are Running
:SecretProviderClass
Kubernetes object, which sets the stage for seamless secrets management within your Kubernetes workloads. This resource acts as a set of instructions for the AWS Secrets and Configuration Provider (ASCP), specifying which secrets to fetch from AWS Secrets Manager and how to mount them into your pods. Note that the SecretProviderClass must be deployed in the same namespace as the workload that references it. To learn more, see SecretProviderClass documentation.eksdemo-spc.yaml
and paste the following contents into it:/mnt/secrets-store
location.eksdemo-app.yaml
and paste the following contents into it:STATUS
is Running
:Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.