# ServiceAccountOptions

Options for `ServiceAccount`.

- Source: [`aws-eks/lib/service-account.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-eks/lib/service-account.ts#L45)
- Type last changed: v2.238.0 · 9 Feb 2026

## Example

```ts
declare const cluster: eks.Cluster;
// add service account with annotations and labels
const serviceAccount = cluster.addServiceAccount('MyServiceAccount', {
  annotations: {
    'eks.amazonaws.com/sts-regional-endpoints': 'false',
  },
  labels: {
    'some-label': 'with-some-value',
  },
});
```

## Properties

- `annotations`: { [key: string]: string } — Additional annotations of the service account.

  **Default:** no additional annotations

- `identityType`: [IdentityType](/cdk/api/v2/docs/aws-cdk-lib.aws_eks.IdentityType.html) = IdentityType.IRSA — The identity type to use for the service account.

- `labels`: { [key: string]: string } — Additional labels of the service account.

  **Default:** no additional labels

- `name`: string — The name of the service account.

  **Default:** If no name is given, it will use the id of the resource.

  The name of a ServiceAccount object must be a valid DNS subdomain name.
  https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/

- `namespace`: string = "default" — The namespace of the service account.

  All namespace names must be valid RFC 1123 DNS labels.
  https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/#namespaces-and-dns

- `overwriteServiceAccount`: boolean = false — Overwrite existing service account.

  If this is set, we will use `kubectl apply` instead of `kubectl create`
  when the service account is created. Otherwise, if there is already a service account
  in the cluster with the same name, the operation will fail.

- `removalPolicy`: [RemovalPolicy](/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.DESTROY — The removal policy applied to the service account resources.

  The removal policy controls what happens to the resources if they stop being managed by CloudFormation.
  This can happen in one of three situations:

  - The resource is removed from the template, so CloudFormation stops managing it
  - A change to the resource is made that requires it to be replaced, so CloudFormation stops managing it
  - The stack is deleted, so CloudFormation stops managing all resources in it
