# EndpointAccess

Endpoint access characteristics.

Obtainable from: EndpointAccess.PRIVATE, EndpointAccess.PUBLIC, EndpointAccess.PUBLIC_AND_PRIVATE
Returned by: EndpointAccess.onlyFrom

- Source: [`aws-eks/lib/cluster.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-eks/lib/cluster.ts#L801)

## Example

TypeScript:

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

const cluster = new eks.Cluster(this, 'hello-eks', {
  version: eks.KubernetesVersion.V1_37,
  endpointAccess: eks.EndpointAccess.PRIVATE, // No access outside of your VPC.
  kubectlLayer: new KubectlV37Layer(this, 'kubectl'),
});
```

Python:

```python
from aws_cdk.lambda_layer_kubectl_v37 import KubectlV37Layer

cluster = eks.Cluster(self, "hello-eks",
    version=eks.KubernetesVersion.V1_37,
    endpoint_access=eks.EndpointAccess.PRIVATE,  # No access outside of your VPC.
    kubectl_layer=KubectlV37Layer(self, "kubectl")
)
```

Java:

```java
import software.amazon.awscdk.cdk.lambdalayer.kubectl.v37.KubectlV37Layer;

Cluster cluster = Cluster.Builder.create(this, "hello-eks")
        .version(KubernetesVersion.V1_37)
        .endpointAccess(EndpointAccess.PRIVATE) // No access outside of your VPC.
        .kubectlLayer(new KubectlV37Layer(this, "kubectl"))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.LambdaLayer.KubectlV37;

var cluster = new Cluster(this, "hello-eks", new ClusterProps {
    Version = KubernetesVersion.V1_37,
    EndpointAccess = EndpointAccess.PRIVATE,  // No access outside of your VPC.
    KubectlLayer = new KubectlV37Layer(this, "kubectl")
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/cdklabs/awscdk-kubectl-go/kubectlv37"

cluster := eks.NewCluster(this, jsii.String("hello-eks"), &ClusterProps{
	Version: eks.KubernetesVersion_V1_37(),
	EndpointAccess: eks.EndpointAccess_PRIVATE(),
	 // No access outside of your VPC.
	KubectlLayer: kubectlv37.NewKubectlV37Layer(this, jsii.String("kubectl")),
})
```

## Properties

- `PRIVATE`: [EndpointAccess](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks.EndpointAccess.html) (static) — The cluster endpoint is only accessible through your VPC.

  Worker node traffic to the endpoint will stay within your VPC.

- `PUBLIC`: [EndpointAccess](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks.EndpointAccess.html) (static) — The cluster endpoint is accessible from outside of your VPC.

  Worker node traffic will leave your VPC to connect to the endpoint.

  By default, the endpoint is exposed to all addresses. You can optionally limit the CIDR blocks that can access the public endpoint using the `PUBLIC.onlyFrom` method.
  If you limit access to specific CIDR blocks, you must ensure that the CIDR blocks that you
  specify include the addresses that worker nodes and Fargate pods (if you use them)
  access the public endpoint from.

- `PUBLIC_AND_PRIVATE`: [EndpointAccess](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks.EndpointAccess.html) (static) — The cluster endpoint is accessible from outside of your VPC.

  Worker node traffic to the endpoint will stay within your VPC.

  By default, the endpoint is exposed to all addresses. You can optionally limit the CIDR blocks that can access the public endpoint using the `PUBLIC_AND_PRIVATE.onlyFrom` method.
  If you limit access to specific CIDR blocks, you must ensure that the CIDR blocks that you
  specify include the addresses that worker nodes and Fargate pods (if you use them)
  access the public endpoint from.

## Methods

- `onlyFrom(...cidr: string[]): EndpointAccess // chainable` — Restrict public access to specific CIDR blocks.

  If public access is disabled, this method will result in an error.

  **Parameters**

  - `cidr` — CIDR blocks.
