Skip to main content
< All Topics

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 Secrets rather than ConfigMaps, 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 an ExternalSecret custom resource. The operator automatically fetches the values from AWS and natively generates a Kubernetes ConfigMap or Secret.
  • 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 ConfigMap object, 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 Secret feature, 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 initContainer to 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

FeatureExternal Secrets Operator (ESO)Secrets Store CSI Driver
Primary OutputNative ConfigMap or SecretFile mounted in Pod volume
App ModificationNone (apps consume K8s native resources)App must read config from file path
Auto-Sync/UpdatesYes (updates the ConfigMap automatically)Yes (updates the mounted file)
Use CaseStandard 12-factor apps needing Env VarsHigh-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.

Contents
Scroll to Top