# ClusterAttributes

Attributes for EKS clusters.

Used as argument in: [Cluster.fromClusterAttributes](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks_v2.Cluster.html#fromclusterattributes)

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

## Example

TypeScript:

```ts
const handlerRole = iam.Role.fromRoleArn(this, 'HandlerRole', 'arn:aws:iam::123456789012:role/lambda-role');
// get the serviceToken from the custom resource provider
const functionArn = lambda.Function.fromFunctionName(this, 'ProviderOnEventFunc', 'ProviderframeworkonEvent-XXX').functionArn;
const kubectlProvider = eks.KubectlProvider.fromKubectlProviderAttributes(this, 'KubectlProvider', {
  serviceToken: functionArn,
  role: handlerRole,
});

const cluster = eks.Cluster.fromClusterAttributes(this, 'Cluster', {
  clusterName: 'cluster',
  kubectlProvider,
});
```

Python:

```python
handler_role = iam.Role.from_role_arn(self, "HandlerRole", "arn:aws:iam::123456789012:role/lambda-role")
# get the serviceToken from the custom resource provider
function_arn = lambda_.Function.from_function_name(self, "ProviderOnEventFunc", "ProviderframeworkonEvent-XXX").function_arn
kubectl_provider = eks.KubectlProvider.from_kubectl_provider_attributes(self, "KubectlProvider",
    service_token=function_arn,
    role=handler_role
)

cluster = eks.Cluster.from_cluster_attributes(self, "Cluster",
    cluster_name="cluster",
    kubectl_provider=kubectl_provider
)
```

Java:

```java
IRole handlerRole = Role.fromRoleArn(this, "HandlerRole", "arn:aws:iam::123456789012:role/lambda-role");
// get the serviceToken from the custom resource provider
String functionArn = Function.fromFunctionName(this, "ProviderOnEventFunc", "ProviderframeworkonEvent-XXX").getFunctionArn();
IKubectlProvider kubectlProvider = KubectlProvider.fromKubectlProviderAttributes(this, "KubectlProvider", KubectlProviderAttributes.builder()
        .serviceToken(functionArn)
        .role(handlerRole)
        .build());

ICluster cluster = Cluster.fromClusterAttributes(this, "Cluster", ClusterAttributes.builder()
        .clusterName("cluster")
        .kubectlProvider(kubectlProvider)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var handlerRole = Role.FromRoleArn(this, "HandlerRole", "arn:aws:iam::123456789012:role/lambda-role");
// get the serviceToken from the custom resource provider
var functionArn = Function.FromFunctionName(this, "ProviderOnEventFunc", "ProviderframeworkonEvent-XXX").FunctionArn;
var kubectlProvider = KubectlProvider.FromKubectlProviderAttributes(this, "KubectlProvider", new KubectlProviderAttributes {
    ServiceToken = functionArn,
    Role = handlerRole
});

var cluster = Cluster.FromClusterAttributes(this, "Cluster", new ClusterAttributes {
    ClusterName = "cluster",
    KubectlProvider = kubectlProvider
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
handlerRole := iam.Role_FromRoleArn(this, jsii.String("HandlerRole"), jsii.String("arn:aws:iam::123456789012:role/lambda-role"))
// get the serviceToken from the custom resource provider
functionArn := lambda.Function_FromFunctionName(this, jsii.String("ProviderOnEventFunc"), jsii.String("ProviderframeworkonEvent-XXX")).FunctionArn
kubectlProvider := eks.KubectlProvider_FromKubectlProviderAttributes(this, jsii.String("KubectlProvider"), &KubectlProviderAttributes{
	ServiceToken: functionArn,
	Role: handlerRole,
})

cluster := eks.Cluster_FromClusterAttributes(this, jsii.String("Cluster"), &ClusterAttributes{
	ClusterName: jsii.String("cluster"),
	KubectlProvider: KubectlProvider,
})
```

## Properties

- `clusterCertificateAuthorityData`: string — The certificate-authority-data for your cluster.

  **Default:** if not specified `cluster.clusterCertificateAuthorityData` will throw an error

- `clusterEncryptionConfigKeyArn`: string — Amazon Resource Name (ARN) or alias of the customer master key (CMK).

  **Default:** if not specified `cluster.clusterEncryptionConfigKeyArn` will throw an error

- `clusterEndpoint`: string — The API Server endpoint URL.

  **Default:** if not specified `cluster.clusterEndpoint` will throw an error.

- `clusterName`: string (required) — The physical name of the Cluster.

- `clusterSecurityGroupId`: string — The cluster security group that was created by Amazon EKS for the cluster.

  **Default:** if not specified `cluster.clusterSecurityGroupId` will throw an error

- `ipFamily`: [IpFamily](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks_v2.IpFamily.html) = IpFamily.IP_V4 — Specify which IP family is used to assign Kubernetes pod and service IP addresses.

- `kubectlProvider`: [IKubectlProvider](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks_v2.IKubectlProvider.html) — KubectlProvider for issuing kubectl commands.

  **Default:** Default CDK provider

- `kubectlProviderOptions`: [KubectlProviderOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks_v2.KubectlProviderOptions.html) — Options for creating the kubectl provider - a lambda function that executes `kubectl` and `helm` against the cluster.

  **Default:** kubectl provider will not be created by default.

  If defined, `kubectlLayer` is a required property.

- `openIdConnectProvider`: [IOpenIdConnectProvider](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IOpenIdConnectProvider.html) — An Open ID Connect provider for this cluster that can be used to configure service accounts.

  **Default:** if not specified `cluster.openIdConnectProvider` and `cluster.addServiceAccount` will throw an error.

  You can either import an existing provider using `iam.OpenIdConnectProvider.fromProviderArn`,
  or create a new provider using `new eks.OpenIdConnectProvider`

- `prune`: boolean = true — Indicates whether Kubernetes resources added through `addManifest()` can be automatically pruned.

  When this is enabled (default), prune labels will be
  allocated and injected to each resource. These labels will then be used
  when issuing the `kubectl apply` operation with the `--prune` switch.

- `securityGroupIds`: string[] — Additional security groups associated with this cluster.

  **Default:** if not specified, no additional security groups will be considered in `cluster.connections`.

- `vpc`: [IVpc](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) — The VPC in which this Cluster was created.

  **Default:** if not specified `cluster.vpc` will throw an error
