# KubectlProviderOptions

Options for creating the kubectl provider - a lambda function that executes `kubectl` and `helm` against the cluster.

- Source: [`aws-eks-v2/lib/kubectl-provider.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-eks-v2/lib/kubectl-provider.ts#L19)
- Type last changed: v2.250.0 · 14 Apr 2026

## Example

```ts
import { KubectlV36Layer } from '@aws-cdk/lambda-layer-kubectl-v36';

const cluster = new eks.Cluster(this, 'hello-eks', {
  version: eks.KubernetesVersion.V1_36,
  kubectlProviderOptions: {
    kubectlLayer: new KubectlV36Layer(this, 'kubectl'),
    environment: {
        'http_proxy': 'http://proxy.myproxy.com',
    },
  }
});
```

## Properties

- `awscliLayer`: [ILayerVersion](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.ILayerVersion.html) — An AWS Lambda layer that contains the `aws` CLI.

  **Default:** If not defined, a default layer will be used containing the AWS CLI 2.x.

- `environment`: { [key: string]: string } — Custom environment variables when running `kubectl` against this cluster.

  **Default:** No custom environment variables

- `kubectlLayer`: [ILayerVersion](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.ILayerVersion.html) (required) — An AWS Lambda layer that includes `kubectl` and `helm`.

- `memory`: [Size](/cdk/api/v2/docs/aws-cdk-lib.Size.html) = 1024 — The amount of memory allocated to the kubectl provider's lambda function.

- `privateSubnets`: [ISubnet](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISubnet.html)[] — Subnets to host the `kubectl` compute resources.

  **Default:** the k8s is accessible publicly

  If not specified, the k8s
  endpoint is expected to be accessible publicly.

- `removalPolicy`: [RemovalPolicy](/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.DESTROY — The removal policy applied to the custom resource that provides kubectl.

  The removal policy controls what happens to the resource if it stops 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

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — An IAM role that can perform kubectl operations against this cluster.

  **Default:** if not specified, the default role created by a lambda function will be used.

  The role should be mapped to the `system:masters` Kubernetes RBAC role.

  This role is directly passed to the lambda handler that sends Kube Ctl commands to the cluster.

- `securityGroup`: [ISecurityGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html) — Use `securityGroups` instead.

  **Default:** If not specified, the k8s endpoint is expected to be accessible publicly.

- `securityGroups`: [ISecurityGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html)[] — Security groups to use for `kubectl` execution.

  **Default:** If not specified, the k8s endpoint is expected to be accessible publicly.
