# KubectlProviderProps

Properties for a KubectlProvider.

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

- Source: [`aws-eks-v2/lib/kubectl-provider.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-eks-v2/lib/kubectl-provider.ts#L101)
- 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_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_eks_v2 as eks_v2 } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';
import { aws_lambda as lambda } from 'aws-cdk-lib';

declare const cluster: eks_v2.Cluster;
declare const layerVersion: lambda.LayerVersion;
declare const role: iam.Role;
declare const securityGroup: ec2.SecurityGroup;
declare const size: cdk.Size;
declare const subnet: ec2.Subnet;
const kubectlProviderProps: eks_v2.KubectlProviderProps = {
  cluster: cluster,
  kubectlLayer: layerVersion,

  // the properties below are optional
  awscliLayer: layerVersion,
  environment: {
    environmentKey: 'environment',
  },
  memory: size,
  privateSubnets: [subnet],
  removalPolicy: cdk.RemovalPolicy.DESTROY,
  role: role,
  securityGroup: securityGroup,
  securityGroups: [securityGroup],
};
```

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_ec2 as ec2
from aws_cdk import aws_eks_v2 as eks_v2
from aws_cdk import aws_iam as iam
from aws_cdk import aws_lambda as lambda_

# cluster: eks_v2.Cluster
# layer_version: lambda.LayerVersion
# role: iam.Role
# security_group: ec2.SecurityGroup
# size: cdk.Size
# subnet: ec2.Subnet

kubectl_provider_props = eks_v2.KubectlProviderProps(
    cluster=cluster,
    kubectl_layer=layer_version,

    # the properties below are optional
    awscli_layer=layer_version,
    environment={
        "environment_key": "environment"
    },
    memory=size,
    private_subnets=[subnet],
    removal_policy=cdk.RemovalPolicy.DESTROY,
    role=role,
    security_group=security_group,
    security_groups=[security_group]
)
```

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.ec2.*;
import software.amazon.awscdk.services.eks_v2.*;
import software.amazon.awscdk.services.iam.*;
import software.amazon.awscdk.services.lambda.*;

Cluster cluster;
LayerVersion layerVersion;
Role role;
SecurityGroup securityGroup;
Size size;
Subnet subnet;

KubectlProviderProps kubectlProviderProps = KubectlProviderProps.builder()
        .cluster(cluster)
        .kubectlLayer(layerVersion)

        // the properties below are optional
        .awscliLayer(layerVersion)
        .environment(Map.of(
                "environmentKey", "environment"))
        .memory(size)
        .privateSubnets(List.of(subnet))
        .removalPolicy(RemovalPolicy.DESTROY)
        .role(role)
        .securityGroup(securityGroup)
        .securityGroups(List.of(securityGroup))
        .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.EC2;
using Amazon.CDK.AWS.EKSv2;
using Amazon.CDK.AWS.IAM;
using Amazon.CDK.AWS.Lambda;

Cluster cluster;
LayerVersion layerVersion;
Role role;
SecurityGroup securityGroup;
Size size;
Subnet subnet;

var kubectlProviderProps = new KubectlProviderProps {
    Cluster = cluster,
    KubectlLayer = layerVersion,

    // the properties below are optional
    AwscliLayer = layerVersion,
    Environment = new Dictionary<string, string> {
        { "environmentKey", "environment" }
    },
    Memory = size,
    PrivateSubnets = new [] { subnet },
    RemovalPolicy = RemovalPolicy.DESTROY,
    Role = role,
    SecurityGroup = securityGroup,
    SecurityGroups = new [] { securityGroup }
};
```

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"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var cluster Cluster
var layerVersion LayerVersion
var role Role
var securityGroup SecurityGroup
var size Size
var subnet Subnet

kubectlProviderProps := &KubectlProviderProps{
	Cluster: cluster,
	KubectlLayer: layerVersion,

	// the properties below are optional
	AwscliLayer: layerVersion,
	Environment: map[string]*string{
		"environmentKey": jsii.String("environment"),
	},
	Memory: size,
	PrivateSubnets: []ISubnet{
		subnet,
	},
	RemovalPolicy: cdk.RemovalPolicy_DESTROY,
	Role: role,
	SecurityGroup: securityGroup,
	SecurityGroups: []ISecurityGroup{
		securityGroup,
	},
}
```

## Properties

- `awscliLayer`: [ILayerVersion](https://docs.aws.amazon.com/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.

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

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

  **Default:** No custom environment variables

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

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

- `privateSubnets`: [ISubnet](https://docs.aws.amazon.com/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](https://docs.aws.amazon.com/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](https://docs.aws.amazon.com/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](https://docs.aws.amazon.com/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](https://docs.aws.amazon.com/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.
