

 **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 Istio in Amazon EKS

This walkthrough shows how to use AWS-issued SPIFFE identities as the mesh identities in an Istio service mesh, so that your workloads complete mutual TLS with the same verifiable identity they carry everywhere else.

**Note**  
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
<a name="pod-id-wi-istio-overview"></a>

Istio secures service-to-service traffic with mutual TLS, where each workload presents a verifiable identity. By default Istio issues those identities from its own certificate authority. With IAM for agents, the mesh’s Envoy sidecars instead obtain an AWS-issued X.509-SVID from the EKS Pod Identity agent, so a workload in the mesh proves itself with the same SPIFFE identity it uses with AWS and with systems outside the cluster.

This example uses Istio in *sidecar mode*, where each workload runs an Envoy sidecar. Istio ambient mode is not currently supported. For more information, see [Considerations and limitations](pod-identity-workload-identity.md#pod-id-wi-considerations). In this model the Istio control plane (istiod) is not the certificate authority for your workloads. Each sidecar reads its identity from the node-local socket that the Pod Identity agent serves.

The example chains three services, `frontend` to `orders` to `payments`, each under its own service account, and has them authenticate to one another over mutual TLS with their AWS-issued identities.

## Prerequisites
<a name="pod-id-wi-istio-prereqs"></a>
+ An EKS cluster with the EKS Pod Identity agent available. For more information, including supported AMIs and the Pod Identity agent version, see [Prerequisites](pod-identity-workload-identity.md#pod-id-wi-prereqs). The Pod Identity agent projects the SPIFFE workload-identity socket into pods through the `spiffe.csi.eks.amazonaws.com` CSI driver.
+ A workload identity provider and a mesh (Kubernetes-style) template, so that identities render as `spiffe://<trust domain>/ns/<namespace>/sa/<service account>`. For more information, see [Trust domains, providers, and templates](pod-identity-workload-identity.md#pod-id-wi-templates).
+ A Pod Identity association for each service account that will receive an identity, with `workloadIdentityConfig` enabled and referencing the provider and template.
+ Istio installed in sidecar mode. Use an Istio version that writes the configured workload-identity socket filename into the Envoy bootstrap, and validate against your Istio release before you rely on it.

**Note**  
The trust domain that you configure in Istio must match the trust domain of your provider. This example uses `cluster.local`, a common mesh trust domain. Set it to the trust domain that your provider issues under. This can be the AWS-generated default or a domain that you chose. For more information, see [Trust domains, providers, and templates](pod-identity-workload-identity.md#pod-id-wi-templates).

## Step 1: Set the mesh trust domain to your provider’s trust domain
<a name="pod-id-wi-istio-step1"></a>

Install or configure Istio so that its mesh trust domain matches the trust domain that your provider issues identities under. This makes the identities that Istio works with the same ones that AWS issues, so the names line up on both sides.

```yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
  namespace: istio-system
spec:
  profile: default        # sidecar mode
  meshConfig:
    trustDomain: cluster.local
```

```bash
istioctl install -f istio-operator.yaml -y
```

**Note**  
The `IstioOperator` resource is a configuration file that you pass to `istioctl install -f`. You don’t apply it to your cluster with `kubectl`, and it doesn’t require the in-cluster Istio operator, which was removed in Istio 1.24.

Confirm that it took effect:

```bash
kubectl get configmap istio -n istio-system -o jsonpath='{.data.mesh}' | grep trustDomain
```

## Step 2: Enable Istio injection on the namespace
<a name="pod-id-wi-istio-step2"></a>

```bash
kubectl create namespace payments
kubectl label namespace payments istio-injection=enabled
```

## Step 3: Point each workload’s sidecar at the Pod Identity agent socket
<a name="pod-id-wi-istio-step3"></a>

For each workload, three things connect the Istio sidecar to IAM for agents:

1. Opt the pod into sidecar injection with the label `sidecar.istio.io/inject: "true"`.

1. Mount the workload-identity socket into the pod with a CSI volume named `workload-socket`, backed by the `spiffe.csi.eks.amazonaws.com` driver.

1. Tell the Envoy sidecar to read its identity from that socket by setting `WORKLOAD_IDENTITY_SOCKET_FILE: agent.sock` through the `proxy.istio.io/config` annotation.

The following is a Deployment for the `payments` service:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata: { name: payments, namespace: payments }
spec:
  replicas: 1
  selector: { matchLabels: { app: payments } }
  template:
    metadata:
      labels:
        app: payments
        sidecar.istio.io/inject: "true"
      annotations:
        proxy.istio.io/config: |
          proxyMetadata:
            WORKLOAD_IDENTITY_SOCKET_FILE: agent.sock
    spec:
      serviceAccountName: payments-sa
      containers:
      - name: payments
        image: <your-image>
        ports: [ { containerPort: 8080 } ]
      volumes:
      - name: workload-socket
        csi:
          driver: spiffe.csi.eks.amazonaws.com
          readOnly: true
---
apiVersion: v1
kind: Service
metadata: { name: payments, namespace: payments }
spec:
  selector: { app: payments }
  ports: [ { port: 8080, targetPort: 8080 } ]
```

Repeat the same shape for `orders` and `frontend`, each with its own service account (`orders-sa` and `frontend-sa`). Your application containers speak ordinary HTTP, and the Istio sidecar establishes mutual TLS between them using the AWS-issued identity.

## Step 4: Require mutual TLS
<a name="pod-id-wi-istio-step4"></a>

Set a `PeerAuthentication` for the namespace to `STRICT`, so that the mesh accepts only mutual TLS connections and not plaintext. This is what makes the workloads' AWS-issued identities a requirement rather than opportunistic.

```yaml
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata: { name: default, namespace: payments }
spec:
  mtls: { mode: STRICT }
```

## Step 5: Control which workloads may call a service
<a name="pod-id-wi-istio-step5"></a>

Requiring mutual TLS proves *who* each workload is. To also control *what* each identity is allowed to do, add an Istio `AuthorizationPolicy` that allows or denies by SPIFFE ID. This is where identity-based access control lives. The policy names the caller identities that may reach a service, and Istio enforces it using the AWS-issued SPIFFE identity that the caller presents.

Specify the caller identity under `source.principals`. The principal is the workload’s SPIFFE ID with the `spiffe://` scheme removed, which is how Istio matches it against the certificate’s SAN.

This example allows only the `orders` workload to call `payments`, and denies everything else to that service:

```yaml
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
metadata:
  name: payments-allow-orders
  namespace: payments
spec:
  selector:
    matchLabels:
      app: payments
  action: ALLOW
  rules:
  - from:
    - source:
        principals:
        - "cluster.local/ns/payments/sa/orders-sa"
```

With this policy in place, a request to `payments` succeeds only when the caller presents the `orders` identity. A workload with any other identity is denied, even though it holds a valid AWS-issued identity of its own, because authentication proves who it is and this policy decides who is allowed.

**Important**  
Write the rule on `source.principals`, not on `source.namespaces`. The `principals` field matches the full SPIFFE ID and is the supported way to authorize these identities in sidecar mode. A `namespaces` rule might or might not match, depending on how Istio compiles it, and a DENY that silently fails to match would let traffic through. When you need namespace-level semantics, use a `principals` prefix (for example, `cluster.local/ns/payments/*`) or run an external authorizer through the Istio CUSTOM action.

**Note**  
These identifiers and the `principals` match apply to Istio sidecar mode, which this page covers. Ambient mode is not supported.

## Step 6: Configure the Istio ingress gateway (if you use one)
<a name="pod-id-wi-istio-step6"></a>

An Istio ingress gateway is a separate, standalone deployment rather than an injected workload, so it does not receive the sidecar injection that your workloads get. Not every deployment runs an ingress gateway. This step applies only if yours does.

If you run an ingress gateway, it must have a mesh identity of its own. The gateway is an Envoy that terminates inbound traffic and then proxies it to mesh workloads over mutual TLS. To do that, it has to present its own X.509-SVID to those workloads and validate their SVIDs against the trust bundle. With `PeerAuthentication` set to `STRICT`, a gateway that has no identity and no trust bundle cannot complete mutual TLS with the workloads it fronts. The workloads reject its connections because it presents no client certificate, and the gateway cannot verify the workloads in return. Configuring the gateway’s identity is therefore required whenever a gateway is present.

Configure the gateway in the same `IstioOperator` resource, under `spec.components.ingressGateways`. Use a `k8s.overlays` patch to mount the EKS Pod Identity agent socket into the gateway’s `istio-proxy` container, and add an init container that waits for the socket to appear before the gateway starts. The gateway then fetches its X.509-SVID and the trust bundle from the Pod Identity agent, the same way the sidecars do.

```yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
  namespace: istio-system
spec:
  profile: default
  meshConfig:
    trustDomain: cluster.local
  components:
    ingressGateways:
    - name: istio-ingressgateway
      enabled: true
      label:
        istio: ingressgateway
      k8s:
        overlays:
        - apiVersion: apps/v1
          kind: Deployment
          name: istio-ingressgateway
          patches:
          - path: spec.template.spec.volumes.[name:workload-socket]
            value:
              name: workload-socket
              csi:
                driver: spiffe.csi.eks.amazonaws.com
                readOnly: true
          - path: spec.template.spec.containers.[name:istio-proxy].volumeMounts.[name:workload-socket]
            value:
              name: workload-socket
              mountPath: /var/run/secrets/workload-spiffe-uds
              readOnly: true
          - path: spec.template.spec.containers.[name:istio-proxy].env.[name:WORKLOAD_IDENTITY_SOCKET_FILE]
            value:
              name: WORKLOAD_IDENTITY_SOCKET_FILE
              value: agent.sock
          # wait for the agent socket before the gateway starts
          - path: spec.template.spec.initContainers
            value:
            - name: wait-for-workload-socket
              image: docker.io/library/busybox:1.28
              volumeMounts:
              - name: workload-socket
                mountPath: /var/run/secrets/workload-spiffe-uds
                readOnly: true
              env:
              - name: CHECK_FILE
                value: /var/run/secrets/workload-spiffe-uds/agent.sock
              command:
              - sh
              - "-c"
              - |-
                while [ ! -e "${CHECK_FILE}" ]; do
                  echo "waiting for ${CHECK_FILE}"
                  sleep 5
                done
```

Apply it with `istioctl install -f <file>.yaml`. After the gateway rolls out, it holds an AWS-issued identity under your provider’s trust domain and can complete mutual TLS with the workloads behind it.

## Verify
<a name="pod-id-wi-istio-verify"></a>

Confirm that each workload received its AWS-issued identity and that mutual TLS is in effect.

 **Pods are running with the sidecar.** 

```bash
kubectl get pods -n payments            # each pod shows 2/2 (app + istio-proxy)
```

 **The sidecar holds an AWS-issued SPIFFE identity.** Inspect the leaf certificate that a workload presents, from a neighboring sidecar:

```bash
kubectl exec -n payments <orders-pod> -c istio-proxy -- \
  sh -c 'echo | openssl s_client -connect payments.payments.svc:8080 2>/dev/null \
  | openssl x509 -noout -ext subjectAltName -issuer -dates'
```

You should see 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. The identity is short-lived, and the Pod Identity agent renews it automatically.

 **Traffic flows over mutual TLS.** A request through the chain (`frontend` to `orders` to `payments`) succeeds. Because `PeerAuthentication` is `STRICT`, it succeeds only because both ends present valid AWS-issued identities. A plaintext request to a workload’s mesh port is refused.

## How it works
<a name="pod-id-wi-istio-how"></a>
+ Istio runs in sidecar mode, and istiod is not the CA for your workloads.
+ Each Envoy sidecar reads its identity from the node-local socket that the EKS Pod Identity agent serves. The `spiffe.csi.eks.amazonaws.com` CSI driver projects the socket into the pod, and the `workload-socket` volume and `WORKLOAD_IDENTITY_SOCKET_FILE: agent.sock` select it.
+ The identities are AWS-issued X.509-SVIDs under your provider’s trust domain, rendered by the mesh template as `spiffe://<trust domain>/ns/<namespace>/sa/<service account>`.
+ Because that is the same identity the workload uses with AWS and with external systems, a workload in the mesh does not hold a separate mesh-only identity.

For the self-managed Envoy equivalent, which runs Envoy sidecars yourself without Istio, see [Use IAM for agents with self-managed Envoy sidecars in Amazon EKS](pod-id-wi-envoy.md). To consume the identity directly from application code, see [Use IAM for agents in Amazon EKS from application code with a SPIFFE library](pod-id-wi-library.md).