AWS Variables and Secret and fetch with EKS ConficMap and Secret
When externalizing your application configuration from Kubernetes into AWS, you have to decide on two components: where to store the data in AWS and how to synchronize that data into your Kubernetes cluster as a ConfigMap or Secret.
Here is a breakdown of the architectural options available for both sides of this equation.
Where to Store Variables in AWS
Depending on the nature of your variables (plaintext, sensitive, or dynamically changing), AWS offers three main services:
- AWS Systems Manager (SSM) Parameter Store:
- Best for: Plaintext configuration data, environment variables, and simple encrypted strings (using KMS).
- Why use it: It is cost-effective (often free for standard parameters) and hierarchically structured (e.g.,
/production/frontend/API_URL), making it very easy to map directly to Kubernetes ConfigMaps.
- AWS Secrets Manager:
- Best for: Sensitive data like database credentials, API keys, and tokens.
- Why use it: It includes built-in secret rotation capabilities. While this is technically mapped to Kubernetes
Secretsrather thanConfigMaps, it is almost always deployed alongside SSM in these architectures.
- AWS AppConfig:
- Best for: Dynamic configuration and feature flags.
- Why use it: If your application variables need to change at runtime without restarting your Kubernetes pods, AppConfig allows you to validate and roll out configuration changes dynamically.
How to Link AWS to Kubernetes
Once your data is in AWS, you need a mechanism to pull it into your cluster. Here are the standard options:
1. External Secrets Operator (ESO)
This is widely considered the industry standard for bridging external cloud providers with Kubernetes native resources.
- How it works: You install the ESO controller in your cluster. You define a
SecretStore(pointing to AWS SSM or Secrets Manager) and anExternalSecretcustom resource. The operator automatically fetches the values from AWS and natively generates a KubernetesConfigMaporSecret. - Pros: Native Kubernetes resources are created, meaning your standard Pod manifests don’t need to change at all. It handles automatic synchronization and updates.
- Cons: Requires installing and managing a third-party operator in your cluster.
2. Secrets Store CSI Driver (with AWS Provider)
This is a Kubernetes-native method that relies on the Container Storage Interface (CSI) to mount configurations as data volumes.
- How it works: Instead of creating a
ConfigMapobject, the AWS parameters are fetched at pod startup and mounted directly as files inside the pod’s filesystem. - Pros: Highly secure because the data is tied to the pod lifecycle (stored in memory,
tmpfs). - Cons: The variables exist as files on a mounted volume, not as standard environment variables. (Note: The CSI driver does have an optional
Sync as Kubernetes Secretfeature, but mounting as volumes is its primary design).
3. Custom Init Containers
You can bypass K8s native syncing tools entirely by pulling the variables right before the application starts.
- How it works: You add an
initContainerto your deployment that uses the AWS CLI or an AWS SDK to query the SSM Parameter Store. It writes these variables to a shared local volume or sources them into the environment, and then the main container starts. - Pros: No need to install cluster-wide operators or CSI drivers.
- Cons: Slower pod startup times, harder to manage configuration updates (requires restarting the pod), and you have to write custom scripting.
Quick Comparison: ESO vs. CSI Driver
| Feature | External Secrets Operator (ESO) | Secrets Store CSI Driver |
| Primary Output | Native ConfigMap or Secret | File mounted in Pod volume |
| App Modification | None (apps consume K8s native resources) | App must read config from file path |
| Auto-Sync/Updates | Yes (updates the ConfigMap automatically) | Yes (updates the mounted file) |
| Use Case | Standard 12-factor apps needing Env Vars | High-security apps needing temp-file configs |
How Pods Consume Configuration Your application can “read” these settings in two main ways:
- Environment Variables: Great for simple strings (e.g.,
DB_URL). - Volume Mounts: Kubernetes takes the ConfigMap/Secret and turns it into a real file inside your container (e.g.,
/etc/config/settings.conf). This is better for large configuration files.