# ServiceAccountProps

Properties for defining service accounts.

Extends: [ServiceAccountOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks_v2.ServiceAccountOptions.html)
Used as props by: [ServiceAccount](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks_v2.ServiceAccount.html)

- Source: [`aws-eks-v2/lib/service-account.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-eks-v2/lib/service-account.ts#L114)
- Type last changed: v2.240.0 · 23 Feb 2026

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_eks_v2 as eks_v2 } from 'aws-cdk-lib';

declare const cluster: eks_v2.Cluster;
const serviceAccountProps: eks_v2.ServiceAccountProps = {
  cluster: cluster,

  // the properties below are optional
  annotations: {
    annotationsKey: 'annotations',
  },
  identityType: eks_v2.IdentityType.IRSA,
  labels: {
    labelsKey: 'labels',
  },
  name: 'name',
  namespace: 'namespace',
  overwriteServiceAccount: false,
  removalPolicy: cdk.RemovalPolicy.DESTROY,
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_eks_v2 as eks_v2

# cluster: eks_v2.Cluster

service_account_props = eks_v2.ServiceAccountProps(
    cluster=cluster,

    # the properties below are optional
    annotations={
        "annotations_key": "annotations"
    },
    identity_type=eks_v2.IdentityType.IRSA,
    labels={
        "labels_key": "labels"
    },
    name="name",
    namespace="namespace",
    overwrite_service_account=False,
    removal_policy=cdk.RemovalPolicy.DESTROY
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.eks_v2.*;

Cluster cluster;

ServiceAccountProps serviceAccountProps = ServiceAccountProps.builder()
        .cluster(cluster)

        // the properties below are optional
        .annotations(Map.of(
                "annotationsKey", "annotations"))
        .identityType(IdentityType.IRSA)
        .labels(Map.of(
                "labelsKey", "labels"))
        .name("name")
        .namespace("namespace")
        .overwriteServiceAccount(false)
        .removalPolicy(RemovalPolicy.DESTROY)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.EKSv2;

Cluster cluster;

var serviceAccountProps = new ServiceAccountProps {
    Cluster = cluster,

    // the properties below are optional
    Annotations = new Dictionary<string, string> {
        { "annotationsKey", "annotations" }
    },
    IdentityType = IdentityType.IRSA,
    Labels = new Dictionary<string, string> {
        { "labelsKey", "labels" }
    },
    Name = "name",
    Namespace = "namespace",
    OverwriteServiceAccount = false,
    RemovalPolicy = RemovalPolicy.DESTROY
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var cluster Cluster

serviceAccountProps := &ServiceAccountProps{
	Cluster: cluster,

	// the properties below are optional
	Annotations: map[string]*string{
		"annotationsKey": jsii.String("annotations"),
	},
	IdentityType: awscdk.Aws_eks_v2.IdentityType_IRSA,
	Labels: map[string]*string{
		"labelsKey": jsii.String("labels"),
	},
	Name: jsii.String("name"),
	Namespace: jsii.String("namespace"),
	OverwriteServiceAccount: jsii.Boolean(false),
	RemovalPolicy: cdk.RemovalPolicy_DESTROY,
}
```

## Properties

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

  **Default:** no additional annotations

- `cluster`: [ICluster](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks_v2.ICluster.html) (required) — The cluster to apply the patch to.

- `identityType`: [IdentityType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks_v2.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](https://docs.aws.amazon.com/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
