Help improve this page
To contribute to this user guide, choose the Edit this page on GitHub link that is located in the right pane of every page.
Use IAM for agents with self-managed Envoy sidecars in Amazon EKS
This walkthrough secures service-to-service traffic with mutual TLS using Envoy sidecars that you run yourself, without a full service mesh product. Each Envoy obtains an AWS-issued X.509-SVID from the EKS Pod Identity agent and uses it for mutual TLS. Your workloads then authenticate to one another with the same verifiable identity they carry everywhere else.
IAM for agents is in preview release for Amazon EKS and is subject to change. It is available in all commercial AWS Regions except Middle East (Bahrain) (me-south-1) and Middle East (UAE) (me-central-1).
This walkthrough applies to any EKS cluster where the EKS Pod Identity agent is available, not only EKS Auto Mode. The configuration is the same on managed node groups, self-managed nodes, and Karpenter, when the prerequisites are met.
What this sets up
This is a mesh-like structure that you assemble yourself. Each workload runs an Envoy proxy as a sidecar, and the proxies authenticate to one another with mutual TLS. Envoy does not get its certificates from an in-cluster certificate authority. Instead, each Envoy fetches its X.509-SVID and trust bundle from the EKS Pod Identity agent over the Secret Discovery Service (SDS). SDS is the protocol Envoy uses to receive and refresh TLS material at runtime. The Pod Identity agent acts as the SDS provider and serves the material over the node-local workload-identity socket that the workload already has.
The example chains three services, frontend to orders to payments. Each runs under its own service account and authenticates over mutual TLS with its AWS-issued identity.
Prerequisites
-
An EKS cluster with the EKS Pod Identity agent available. For more information, see Prerequisites. The Pod Identity agent projects the workload-identity socket into pods through the
spiffe.csi.eks.amazonaws.comCSI driver, and the socket is injected when you enable workload identity on the pod. -
A workload identity provider and a template. Any template works here, the default template or a custom one, because Envoy authenticates on the SPIFFE ID that the identity carries rather than on any particular path shape. Whatever SPIFFE IDs your template renders are the values that you put in Envoy’s peer-match configuration (
match_typed_subject_alt_names). This walkthrough uses the mesh (Kubernetes-style) template so that identities render asspiffe://<trust domain>/ns/<namespace>/sa/<service account>, which keeps the example short and the SPIFFE IDs easy to read. If you use the default template or a custom one, substitute the SPIFFE IDs that your template produces. -
A Pod Identity association for each service account, with
workloadIdentityConfigenabled and referencing the provider and template. -
Envoy running as a sidecar in each workload pod.
The trust domain and the SPIFFE IDs in your Envoy configuration must match what your provider and template issue. This walkthrough uses the trust domain cluster.local and the mesh path shape. Set both to match your own setup. The trust domain can be the AWS-generated default or a domain that you choose. For more information, see Trust domains, providers, and templates.
Envoy configuration
Each Envoy needs three things. It needs a cluster that points at the Pod Identity agent socket. It needs an inbound mutual TLS listener that presents the workload’s X.509-SVID and requires a client certificate. And for a service that calls another, it needs an outbound path that originates mutual TLS to the upstream.
1. A cluster for the Pod Identity agent socket
Envoy makes all of its SDS requests to this cluster. The pipe path is the node-local workload-identity socket.
clusters: - name: pod_identity_agent connect_timeout: 0.25s http2_protocol_options: {} load_assignment: cluster_name: pod_identity_agent endpoints: - lb_endpoints: - endpoint: address: pipe: path: /var/run/secrets/pods.eks.amazonaws.com/workloadidentity/agent.sock
2. Inbound mutual TLS listener
On the inbound listener, require a client certificate and fetch the workload’s own X.509-SVID over SDS. Name the certificate secret default and the trust bundle (validation context) ROOTCA. These are the SDS resource names that the Pod Identity agent serves. You can also restrict which peer SPIFFE IDs are accepted.
transport_socket: name: envoy.transport_sockets.tls typed_config: "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext require_client_certificate: true common_tls_context: # the workload's own X.509-SVID tls_certificate_sds_secret_configs: - name: "default" sds_config: resource_api_version: V3 api_config_source: api_type: GRPC transport_api_version: V3 grpc_services: - envoy_grpc: { cluster_name: pod_identity_agent } combined_validation_context: # accept connections only from these workload identities (optional) default_validation_context: match_typed_subject_alt_names: - san_type: URI matcher: exact: "spiffe://cluster.local/ns/payments/sa/orders-sa" # the trust bundle, over SDS validation_context_sds_secret_config: name: "ROOTCA" sds_config: resource_api_version: V3 api_config_source: api_type: GRPC transport_api_version: V3 grpc_services: - envoy_grpc: { cluster_name: pod_identity_agent }
3. Outbound mutual TLS to an upstream
Take a service that calls another, such as orders calling payments. The application makes a plain HTTP request to a local Envoy listener. Envoy then originates mutual TLS to the upstream. It presents the same default SVID and validates the upstream’s SPIFFE ID with the ROOTCA bundle.
transport_socket: name: envoy.transport_sockets.tls typed_config: "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext common_tls_context: tls_certificate_sds_secret_configs: - name: "default" sds_config: resource_api_version: V3 api_config_source: api_type: GRPC transport_api_version: V3 grpc_services: - envoy_grpc: { cluster_name: pod_identity_agent } combined_validation_context: default_validation_context: match_typed_subject_alt_names: - san_type: URI matcher: exact: "spiffe://cluster.local/ns/payments/sa/payments-sa" validation_context_sds_secret_config: name: "ROOTCA" sds_config: resource_api_version: V3 api_config_source: api_type: GRPC transport_api_version: V3 grpc_services: - envoy_grpc: { cluster_name: pod_identity_agent }
The Pod Identity agent streams rotated material as it renews. Envoy applies new certificates to live connections without interruption. The private keys are never written to disk.
Pod configuration
Deploy each workload with its Envoy sidecar and its own service account. Enable the workload-identity socket on the pod with the pod-identity opt-in label, which projects the socket so that the Envoy pod_identity_agent cluster can reach it.
-
Each application container speaks plain HTTP. For a service that calls an upstream, point it at the local Envoy outbound listener. Use
127.0.0.1rather thanlocalhostso that the connection uses IPv4 and matches Envoy’s listener. -
The Envoy container mounts the per-service configuration, for example from a ConfigMap, and shares the pod with the application.
Address the local Envoy listener as 127.0.0.1:<port>. The name localhost can resolve to IPv6 (::1), which the Envoy IPv4 listener does not accept, so the call is refused.
Verify
Envoy loaded its identity. The Envoy logs show no StreamSecrets errors after startup. Envoy fetched the default certificate and the ROOTCA bundle from the Pod Identity agent.
The presented certificate is the AWS-issued SVID.
kubectl exec -n payments <orders-pod> -c envoy -- \ sh -c 'echo | openssl s_client -connect payments.payments.svc:8443 2>/dev/null \ | openssl x509 -noout -ext subjectAltName -issuer -dates'
The output shows the URI SAN spiffe://cluster.local/ns/payments/sa/payments-sa, an issuer that is your provider’s signer (your AWS Private CA), and a short validity window.
Mutual TLS is enforced. The service chain succeeds. A plaintext request to a workload’s mutual TLS port is refused because the inbound listener sets require_client_certificate: true.
For the managed-mesh equivalent, see Use IAM for agents with Istio in Amazon EKS. To consume the identity directly from application code with no sidecar, see Use IAM for agents in Amazon EKS from application code with a SPIFFE library.