This Terraform module is designed to efficiently manage secrets within an Elastic Kubernetes Service (EKS) cluster through the use of External Secrets Operator (ESO). The module ensures secrets in your EKS cluster are continuously synced with AWS Secrets Manager, providing a centralized access point for your secret backend.
Key features:
SecretStoreOnce you have a Corewide Solutions Portal account, this one-time action will use your browser session to retrieve credentials:
shellterraform login solutions.corewide.com
Initialize mandatory providers:
Copy and paste into your Terraform configuration and insert the variables:
hclmodule "tf_k8s_eso_aws" {
source = "solutions.corewide.com/kubernetes/tf-k8s-eso-aws/aws"
version = "~> 3.0.0"
# specify module inputs here or try one of the examples below
...
}
Initialize the setup:
shellterraform init
Corewide DevOps team strictly follows Semantic Versioning
Specification
to
provide our clients with products that have predictable upgrades between versions. We
recommend
pinning
patch versions of our modules using pessimistic
constraint operator (~>) to prevent breaking changes during upgrades.
To get new features during the upgrades (without breaking compatibility), use
~> 3.0 and run
terraform init -upgrade
For the safest setup, use strict pinning with version = "3.0.0"
|
Module
85% off
|
$45
|
| TOTAL | $338 |
| tf-aws-iam-role | $45 |
| tf-k8s-crd | $45 |
| tf-k8s-eso | $202 |
This Terraform module is designed to efficiently manage secrets within an Elastic Kubernetes Service (EKS) cluster through the use of External Secrets Operator (ESO). The module ensures secrets in your EKS cluster are continuously synced with AWS Secrets Manager, providing a centralized access point for your secret backend.
Key features:
SecretStoreAll notable changes to this project are documented here.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
ClusterSecretStore resource API version with a secret_store_api_version input (v1 by default)3.0tf-k8s-crd module dependency from 2.0 to 3.0tf-k8s-eso module dependency from 2.0 to 3.0(Last version compatible with Kubernetes Terraform provider version 2.0)
6.0tf-aws-iam-role module dependency from 1.2 to 2.0 to align with the latest provider updatestf-k8s-eso module dependency from 1.0 to 2.0(Last version compatible with Terraform AWS provider version 5.0)
~> 1.21.9 or higherv1.2secret_names variable to prevent Terraform from failing due to handling values unknown before applysecret_names requires a list of strings nownullable field definition to all variablesFirst stable version
v1.x to v2.xModule from v2.0 has several management changes that requires attention:
~> 6.0: hclterraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.0"
}
}
}
Upgrade project dependencies:
bashterraform init --upgrade
tf-k8s-eso module dependency from 1.0 to 2.0. The module dependency from v2.0 utilizes a fundamentally new concept of inputs management and processing.eso and reloader parameters might require update, for reference refer to the changelog and upgrade notes of the tf-k8s-eso module.Update the declaration of the module according to the requirements and examples to match the designed configuration, then the configuration can be applied.
v2.x to v3.xModule from v3.0 has several management changes that requires attention:
~> 3.0: hclterraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 3.0"
}
}
}
Upgrade project dependencies:
bashterraform init --upgrade
tf-k8s-eso module dependency from 2.0 to 3.0. The module dependency from v3.0 utilizes updated ESO and Reloader versions by default.eso and reloader parameters might require update, for reference refer to the changelog and upgrade notes of the tf-k8s-eso module.Update the declaration of the module according to the requirements and examples to match the designed configuration, then the configuration can be applied.
Apply the changes to make sure the state of the resources is up-to-date with the new provider version:
bashterraform apply
Minimal Configuration:
yamlapiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
name: app-secret
namespace: secrets-operator
spec:
target:
template:
metadata:
labels:
# resource_selector from reloader
app-secret: "yes"
secretStoreRef:
name: aws-secrets-manager
kind: ClusterSecretStore
# Data defines the connection between the Kubernetes Secret keys and the Provider data
data:
- remoteRef:
# Secrets Manager's secret name
key: test
# JSON path. E.g. if ASM secret contains {'foo': 'bar'}, the result will be 'bar'
property: foo
# Key of Kubernetes secret to append value to
secretKey: foo
# Used to fetch all properties from the Provider key
dataFrom:
- extract:
# Secrets Manager's secret name
key: test
Full configuration:
yamlapiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
name: app-secret
namespace: secrets-operator
spec:
refreshInterval: 1m
secretStoreRef:
name: aws-secrets-manager
kind: ClusterSecretStore
target:
# Name of future K8S secret
name: app-secret
# DeletionPolicy defines how/when to delete the Secret in Kubernetes
# if the provider secret gets deleted.
deletionPolicy: Retain
# Secret creation policy
creationPolicy: Owner
template:
metadata:
labels:
app-secret: "yes"
# Data defines the connection between the Kubernetes Secret keys and the Provider data
data:
- remoteRef:
# Secrets Manager's secret name
key: test
# JSON path. E.g. if ASM secret contains {'foo': 'bar'}, the result will be 'bar'
property: foo
# Key of Kubernetes secret to append value to
secretKey: foo
# Used to fetch all properties from the Provider key
dataFrom:
- extract:
# Secrets Manager's secret name
key: test
Deploy module with the default parameters:
hclmodule "eso_aws" {
source = "solutions.corewide.com/kubernetes/tf-k8s-eso-aws/aws"
version = "~> 3.0"
name_prefix = "foo"
oidc_provider_url = aws_iam_openid_connect_provider.example.url
secret_names = ["frontend", "backend"]
}
Deploy module with custom Reloader parameters - set resource and namespace selectors:
hclmodule "eso_aws" {
source = "solutions.corewide.com/kubernetes/tf-k8s-eso-aws/aws"
version = "~> 3.0"
name_prefix = "foo"
namespace = "secrets-store"
secret_names = ["frontend"]
oidc_provider_url = aws_iam_openid_connect_provider.example.url
reloader = {
resource_selector = {
app-secret = "yes"
}
}
}
Deploy module with full custom configuration:
hclmodule "eso_aws" {
source = "solutions.corewide.com/kubernetes/tf-k8s-eso-aws/aws"
version = "~> 3.0"
name_prefix = "foo"
region = "us-east-1"
namespace = "secrets-store"
secret_names = ["frontend"]
oidc_provider_url = aws_iam_openid_connect_provider.example.url
service_account_name = "super-secrets-store"
node_selector = {
"eks.amazonaws.com/nodegroup" = "maintenance"
}
eso = {
chart_version = "yyyy"
app_version = "xxxx"
custom_values = {
foo = "bar"
}
}
reloader = {
chart_version = "yyyy"
app_version = "xxxx"
resource_selector = {
app-secret = "yes"
}
}
}
| Variable | Description | Type | Default | Required | Sensitive |
|---|---|---|---|---|---|
name_prefix |
Name prefix for the created resources | string |
yes | no | |
oidc_provider_url |
URL of AWS OIDC provider to authorize Kubernetes service account | string |
yes | no | |
secret_names |
AWS Secrets Manager secret names that should be synchronized with EKS | list(string) |
yes | no | |
create_namespace |
Indicates creation of dedicated namespace for the stack deployment | bool |
true |
no | no |
eso |
External Secrets Operator parameters. This parameter is passed to tf-k8s-eso module's eso parameter. eso.service_account parameter is ignored as it is managed by tf-k8s-eso-aws module itself |
any |
{} |
no | no |
namespace |
The namespace to install the stack into | string |
external-secrets-operator |
no | no |
node_selector |
Node selector for the stack components | map(string) |
{} |
no | no |
region |
AWS Secrets Manager region to be used for the provider configuration of ClusterSecretStore resource. If not set, takes AWS provider-level region as default |
string |
no | no | |
reloader |
Reloader parameters. This parameter is passed to tf-k8s-eso module's reloader parameter |
any |
{} |
no | no |
secret_store_api_version |
ClusterSecretStore resource API version. Possible values are: v1 and v1beta1 |
string |
v1 |
no | no |
service_account_name |
Kubernetes ServiceAccount name |
string |
external-secrets-operator |
no | no |
| Output | Description | Type | Sensitive |
|---|---|---|---|
cluster_secret_store_name |
Name of Kubernetes ClusterSecretStore resource to be used in creation of ExternalSecret resources |
attribute |
no |
namespace |
The namespace name where External Secrets Operator and Reloader were installed | resource |
no |
| Dependency | Version | Kind |
|---|---|---|
terraform |
>= 1.9 |
CLI |
hashicorp/aws |
~> 6.0 |
provider |
hashicorp/kubernetes |
~> 3.0 |
provider |
tf-aws-iam-role |
~> 2.0 |
module |
tf-k8s-crd |
~> 3.0 |
module |
tf-k8s-eso |
~> 3.0 |
module |
These components are included as is under the terms of their corresponding licenses.
| Component | License |
|---|---|
| External Secrets | Apache-2.0 |
| Reloader | Apache-2.0 |