# AlbController

Construct for installing the AWS ALB Contoller on EKS clusters.

Use the factory functions `get` and `getOrCreate` to obtain/create instances of this controller.

Extends: [Construct](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Construct.html) › AlbController
Implements: [IConstruct](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.IConstruct.html), [IDependable](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.IDependable.html)
Obtainable from: AlbController.create

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

## 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 as eks } from 'aws-cdk-lib';

declare const albControllerVersion: eks.AlbControllerVersion;
declare const cluster: eks.Cluster;
declare const policy: any;
const albController = new eks.AlbController(this, 'MyAlbController', {
  cluster: cluster,
  version: albControllerVersion,

  // the properties below are optional
  additionalHelmChartValues: {
    enableWaf: false,
    enableWafv2: false,
  },
  overwriteServiceAccount: false,
  policy: policy,
  removalPolicy: cdk.RemovalPolicy.DESTROY,
  repository: 'repository',
});
```

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 as eks

# alb_controller_version: eks.AlbControllerVersion
# cluster: eks.Cluster
# policy: Any

alb_controller = eks.AlbController(self, "MyAlbController",
    cluster=cluster,
    version=alb_controller_version,

    # the properties below are optional
    additional_helm_chart_values=eks.AlbControllerHelmChartOptions(
        enable_waf=False,
        enable_wafv2=False
    ),
    overwrite_service_account=False,
    policy=policy,
    removal_policy=cdk.RemovalPolicy.DESTROY,
    repository="repository"
)
```

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.*;

AlbControllerVersion albControllerVersion;
Cluster cluster;
Object policy;

AlbController albController = AlbController.Builder.create(this, "MyAlbController")
        .cluster(cluster)
        .version(albControllerVersion)

        // the properties below are optional
        .additionalHelmChartValues(AlbControllerHelmChartOptions.builder()
                .enableWaf(false)
                .enableWafv2(false)
                .build())
        .overwriteServiceAccount(false)
        .policy(policy)
        .removalPolicy(RemovalPolicy.DESTROY)
        .repository("repository")
        .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.EKS;

AlbControllerVersion albControllerVersion;
Cluster cluster;
var policy;

var albController = new AlbController(this, "MyAlbController", new AlbControllerProps {
    Cluster = cluster,
    Version = albControllerVersion,

    // the properties below are optional
    AdditionalHelmChartValues = new AlbControllerHelmChartOptions {
        EnableWaf = false,
        EnableWafv2 = false
    },
    OverwriteServiceAccount = false,
    Policy = policy,
    RemovalPolicy = RemovalPolicy.DESTROY,
    Repository = "repository"
});
```

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 albControllerVersion AlbControllerVersion
var cluster Cluster
var policy interface{}

albController := awscdk.Aws_eks.NewAlbController(this, jsii.String("MyAlbController"), &AlbControllerProps{
	Cluster: cluster,
	Version: albControllerVersion,

	// the properties below are optional
	AdditionalHelmChartValues: &AlbControllerHelmChartOptions{
		EnableWaf: jsii.Boolean(false),
		EnableWafv2: jsii.Boolean(false),
	},
	OverwriteServiceAccount: jsii.Boolean(false),
	Policy: policy,
	RemovalPolicy: cdk.RemovalPolicy_DESTROY,
	Repository: jsii.String("repository"),
})
```

## Initializer

TypeScript:

```ts
new AlbController(scope: Construct, id: string, props: AlbControllerProps)
```

Python:

```python
AlbController(scope: Construct, id: str, props: AlbControllerProps)
```

Java:

```java
new AlbController(Construct scope, String id, AlbControllerProps props)
```

C# / .NET:

```csharp
new AlbController(Construct scope, string id, AlbControllerProps props)
```

Golang:

```go
NewAlbController(Scope Construct, Id *string, Props AlbControllerProps)
```

## Construct Props

- `additionalHelmChartValues`: [AlbControllerHelmChartOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks.AlbControllerHelmChartOptions.html) — Additional helm chart values for ALB controller.

  **Default:** no additional helm chart values

- `cluster`: [Cluster](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks.Cluster.html) (required) — [disable-awslint:ref-via-interface] Cluster to install the controller onto.

- `overwriteServiceAccount`: boolean = false — Overwrite any existing ALB controller service account.

  If this is set, we will use `kubectl apply` instead of `kubectl create`
  when the ALB controller service account is created. Otherwise, if there is already a service account
  named 'aws-load-balancer-controller' in the kube-system namespace, the operation will fail.

- `policy`: any — The IAM policy to apply to the service account.

  **Default:** Corresponds to the predefined version.

  If you're using one of the built-in versions, this is not required since
  CDK ships with the appropriate policies for those versions.

  However, if you are using a custom version, this is required (and validated).

- `removalPolicy`: [RemovalPolicy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.DESTROY — The removal policy applied to the ALB controller 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

- `repository`: string — The repository to pull the controller image from.

  **Default:** '602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-load-balancer-controller'

  Note that the default repository works for most regions, but not all.
  If the repository is not applicable to your region, use a custom repository
  according to the information here: https://github.com/kubernetes-sigs/aws-load-balancer-controller/releases.

- `version`: [AlbControllerVersion](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks.AlbControllerVersion.html) (required) — Version of the controller.

## Properties

- `node`: [Node](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Node.html) — The tree node.

## Methods

- `create(scope: Construct, props: AlbControllerProps): AlbController // chainable` (static) — Create the controller construct associated with this cluster and scope.

  Singleton per stack/cluster.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
