ClusterArgs

data class ClusterArgs(val defaultAddonsToRemoves: Output<List<String>>? = null, val enabledClusterLogTypes: Output<List<String>>? = null, val encryptionConfig: Output<ClusterEncryptionConfigArgs>? = null, val kubernetesNetworkConfig: Output<ClusterKubernetesNetworkConfigArgs>? = null, val name: Output<String>? = null, val outpostConfig: Output<ClusterOutpostConfigArgs>? = null, val roleArn: Output<String>? = null, val tags: Output<Map<String, String>>? = null, val version: Output<String>? = null, val vpcConfig: Output<ClusterVpcConfigArgs>? = null) : ConvertibleToJava<ClusterArgs>

Manages an EKS Cluster.

Example Usage

Basic Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.eks.Cluster;
import com.pulumi.aws.eks.ClusterArgs;
import com.pulumi.aws.eks.inputs.ClusterVpcConfigArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Cluster("example", ClusterArgs.builder()
.roleArn(aws_iam_role.example().arn())
.vpcConfig(ClusterVpcConfigArgs.builder()
.subnetIds(
aws_subnet.example1().id(),
aws_subnet.example2().id())
.build())
.build(), CustomResourceOptions.builder()
.dependsOn(
aws_iam_role_policy_attachment.example-AmazonEKSClusterPolicy(),
aws_iam_role_policy_attachment.example-AmazonEKSVPCResourceController())
.build());
ctx.export("endpoint", example.endpoint());
ctx.export("kubeconfig-certificate-authority-data", example.certificateAuthority().applyValue(certificateAuthority -> certificateAuthority.data()));
}
}

Example IAM Role for EKS Cluster

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.iam.RolePolicyAttachment;
import com.pulumi.aws.iam.RolePolicyAttachmentArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var assumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.effect("Allow")
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("Service")
.identifiers("eks.amazonaws.com")
.build())
.actions("sts:AssumeRole")
.build())
.build());
var example = new Role("example", RoleArgs.builder()
.assumeRolePolicy(assumeRole.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))
.build());
var example_AmazonEKSClusterPolicy = new RolePolicyAttachment("example-AmazonEKSClusterPolicy", RolePolicyAttachmentArgs.builder()
.policyArn("arn:aws:iam::aws:policy/AmazonEKSClusterPolicy")
.role(example.name())
.build());
var example_AmazonEKSVPCResourceController = new RolePolicyAttachment("example-AmazonEKSVPCResourceController", RolePolicyAttachmentArgs.builder()
.policyArn("arn:aws:iam::aws:policy/AmazonEKSVPCResourceController")
.role(example.name())
.build());
}
}

Enabling Control Plane Logging

EKS Control Plane Logging can be enabled via the enabled_cluster_log_types argument. To manage the CloudWatch Log Group retention period, the aws.cloudwatch.LogGroup resource can be used.

The below configuration uses dependsOn to prevent ordering issues with EKS automatically creating the log group first and a variable for naming consistency. Other ordering and naming methodologies may be more appropriate for your environment.

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cloudwatch.LogGroup;
import com.pulumi.aws.cloudwatch.LogGroupArgs;
import com.pulumi.aws.eks.Cluster;
import com.pulumi.aws.eks.ClusterArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var config = ctx.config();
final var clusterName = config.get("clusterName").orElse("example");
var exampleLogGroup = new LogGroup("exampleLogGroup", LogGroupArgs.builder()
.retentionInDays(7)
.build());
var exampleCluster = new Cluster("exampleCluster", ClusterArgs.builder()
.enabledClusterLogTypes(
"api",
"audit")
.build(), CustomResourceOptions.builder()
.dependsOn(exampleLogGroup)
.build());
}
}

EKS Cluster on AWS Outpost

Creating a local Amazon EKS cluster on an AWS Outpost

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.eks.Cluster;
import com.pulumi.aws.eks.ClusterArgs;
import com.pulumi.aws.eks.inputs.ClusterVpcConfigArgs;
import com.pulumi.aws.eks.inputs.ClusterOutpostConfigArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleRole = new Role("exampleRole", RoleArgs.builder()
.assumeRolePolicy(data.aws_iam_policy_document().example_assume_role_policy().json())
.build());
var exampleCluster = new Cluster("exampleCluster", ClusterArgs.builder()
.roleArn(exampleRole.arn())
.vpcConfig(ClusterVpcConfigArgs.builder()
.endpointPrivateAccess(true)
.endpointPublicAccess(false)
.build())
.outpostConfig(ClusterOutpostConfigArgs.builder()
.controlPlaneInstanceType("m5d.large")
.outpostArns(data.aws_outposts_outpost().example().arn())
.build())
.build());
}
}

Import

EKS Clusters can be imported using the name, e.g.,

$ pulumi import aws:eks/cluster:Cluster my_cluster my_cluster

Constructors

Link copied to clipboard
constructor(defaultAddonsToRemoves: Output<List<String>>? = null, enabledClusterLogTypes: Output<List<String>>? = null, encryptionConfig: Output<ClusterEncryptionConfigArgs>? = null, kubernetesNetworkConfig: Output<ClusterKubernetesNetworkConfigArgs>? = null, name: Output<String>? = null, outpostConfig: Output<ClusterOutpostConfigArgs>? = null, roleArn: Output<String>? = null, tags: Output<Map<String, String>>? = null, version: Output<String>? = null, vpcConfig: Output<ClusterVpcConfigArgs>? = null)

Properties

Link copied to clipboard
val defaultAddonsToRemoves: Output<List<String>>? = null
Link copied to clipboard
val enabledClusterLogTypes: Output<List<String>>? = null

List of the desired control plane logging to enable. For more information, see Amazon EKS Control Plane Logging.

Link copied to clipboard

Configuration block with encryption configuration for the cluster. Only available on Kubernetes 1.13 and above clusters created after March 6, 2020. Detailed below.

Link copied to clipboard

Configuration block with kubernetes network configuration for the cluster. Detailed below. If removed, this provider will only perform drift detection if a configuration value is provided.

Link copied to clipboard
val name: Output<String>? = null

Name of the cluster. Must be between 1-100 characters in length. Must begin with an alphanumeric character, and must only contain alphanumeric characters, dashes and underscores (^[0-9A-Za-z][A-Za-z0-9\-_]+$).

Link copied to clipboard

Configuration block representing the configuration of your local Amazon EKS cluster on an AWS Outpost. This block isn't available for creating Amazon EKS clusters on the AWS cloud.

Link copied to clipboard
val roleArn: Output<String>? = null

ARN of the IAM role that provides permissions for the Kubernetes control plane to make calls to AWS API operations on your behalf. Ensure the resource configuration includes explicit dependencies on the IAM Role permissions by adding depends_on if using the aws.iam.RolePolicy resource or aws.iam.RolePolicyAttachment resource, otherwise EKS cannot delete EKS managed EC2 infrastructure such as Security Groups on EKS Cluster deletion.

Link copied to clipboard
val tags: Output<Map<String, String>>? = null

Key-value map of resource tags. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Link copied to clipboard
val version: Output<String>? = null

Desired Kubernetes master version. If you do not specify a value, the latest available version at resource creation is used and no upgrades will occur except those automatically triggered by EKS. The value must be configured and increased to upgrade the version when desired. Downgrades are not supported by EKS.

Link copied to clipboard
val vpcConfig: Output<ClusterVpcConfigArgs>? = null

Configuration block for the VPC associated with your cluster. Amazon EKS VPC resources have specific requirements to work properly with Kubernetes. For more information, see Cluster VPC Considerations and Cluster Security Group Considerations in the Amazon EKS User Guide. Detailed below. Also contains attributes detailed in the Attributes section. The following arguments are optional:

Functions

Link copied to clipboard
open override fun toJava(): ClusterArgs