Skip to content
v2.278.0

CommonClusterOptions Struct ​

Options for configuring an EKS cluster.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_eks as eks } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';

declare const kubernetesVersion: eks.KubernetesVersion;
declare const role: iam.Role;
declare const securityGroup: ec2.SecurityGroup;
declare const subnet: ec2.Subnet;
declare const subnetFilter: ec2.SubnetFilter;
declare const vpc: ec2.Vpc;
const commonClusterOptions: eks.CommonClusterOptions = {
  version: kubernetesVersion,

  // the properties below are optional
  clusterName: 'clusterName',
  outputClusterName: false,
  outputConfigCommand: false,
  role: role,
  securityGroup: securityGroup,
  vpc: vpc,
  vpcSubnets: [{
    availabilityZones: ['availabilityZones'],
    onePerAz: false,
    subnetFilters: [subnetFilter],
    subnetGroupName: 'subnetGroupName',
    subnets: [subnet],
    subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
  }],
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ec2 as ec2
from aws_cdk import aws_eks as eks
from aws_cdk import aws_iam as iam

# kubernetes_version: eks.KubernetesVersion
# role: iam.Role
# security_group: ec2.SecurityGroup
# subnet: ec2.Subnet
# subnet_filter: ec2.SubnetFilter
# vpc: ec2.Vpc

common_cluster_options = eks.CommonClusterOptions(
    version=kubernetes_version,

    # the properties below are optional
    cluster_name="clusterName",
    output_cluster_name=False,
    output_config_command=False,
    role=role,
    security_group=security_group,
    vpc=vpc,
    vpc_subnets=[ec2.SubnetSelection(
        availability_zones=["availabilityZones"],
        one_per_az=False,
        subnet_filters=[subnet_filter],
        subnet_group_name="subnetGroupName",
        subnets=[subnet],
        subnet_type=ec2.SubnetType.PRIVATE_ISOLATED
    )]
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ec2.*;
import software.amazon.awscdk.services.eks.*;
import software.amazon.awscdk.services.iam.*;

KubernetesVersion kubernetesVersion;
Role role;
SecurityGroup securityGroup;
Subnet subnet;
SubnetFilter subnetFilter;
Vpc vpc;

CommonClusterOptions commonClusterOptions = CommonClusterOptions.builder()
        .version(kubernetesVersion)

        // the properties below are optional
        .clusterName("clusterName")
        .outputClusterName(false)
        .outputConfigCommand(false)
        .role(role)
        .securityGroup(securityGroup)
        .vpc(vpc)
        .vpcSubnets(List.of(SubnetSelection.builder()
                .availabilityZones(List.of("availabilityZones"))
                .onePerAz(false)
                .subnetFilters(List.of(subnetFilter))
                .subnetGroupName("subnetGroupName")
                .subnets(List.of(subnet))
                .subnetType(SubnetType.PRIVATE_ISOLATED)
                .build()))
        .build();
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.AWS.EC2;
using Amazon.CDK.AWS.EKS;
using Amazon.CDK.AWS.IAM;

KubernetesVersion kubernetesVersion;
Role role;
SecurityGroup securityGroup;
Subnet subnet;
SubnetFilter subnetFilter;
Vpc vpc;

var commonClusterOptions = new CommonClusterOptions {
    Version = kubernetesVersion,

    // the properties below are optional
    ClusterName = "clusterName",
    OutputClusterName = false,
    OutputConfigCommand = false,
    Role = role,
    SecurityGroup = securityGroup,
    Vpc = vpc,
    VpcSubnets = new [] { new SubnetSelection {
        AvailabilityZones = new [] { "availabilityZones" },
        OnePerAz = false,
        SubnetFilters = new [] { subnetFilter },
        SubnetGroupName = "subnetGroupName",
        Subnets = new [] { subnet },
        SubnetType = SubnetType.PRIVATE_ISOLATED
    } }
};
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 "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var kubernetesVersion KubernetesVersion
var role Role
var securityGroup SecurityGroup
var subnet Subnet
var subnetFilter SubnetFilter
var vpc Vpc

commonClusterOptions := &CommonClusterOptions{
	Version: kubernetesVersion,

	// the properties below are optional
	ClusterName: jsii.String("clusterName"),
	OutputClusterName: jsii.Boolean(false),
	OutputConfigCommand: jsii.Boolean(false),
	Role: role,
	SecurityGroup: securityGroup,
	Vpc: vpc,
	VpcSubnets: []SubnetSelection{
		&SubnetSelection{
			AvailabilityZones: []*string{
				jsii.String("availabilityZones"),
			},
			OnePerAz: jsii.Boolean(false),
			SubnetFilters: []SubnetFilter{
				subnetFilter,
			},
			SubnetGroupName: jsii.String("subnetGroupName"),
			Subnets: []ISubnet{
				subnet,
			},
			SubnetType: awscdk.Aws_ec2.SubnetType_PRIVATE_ISOLATED,
		},
	},
}

Properties ​

clusterNameoptionalstringcluster_nameoptionalstrclusterNameoptionalStringClusterNameoptionalstringClusterNameoptional*string #
Name for the cluster.

Default: Automatically generated name

outputClusterNameoptionalbooleanoutput_cluster_nameoptionalbooloutputClusterNameoptionalBooleanOutputClusterNameoptionalboolOutputClusterNameoptional*bool = false #
Determines whether a CloudFormation output with the name of the cluster will be synthesized.
outputConfigCommandoptionalbooleanoutput_config_commandoptionalbooloutputConfigCommandoptionalBooleanOutputConfigCommandoptionalboolOutputConfigCommandoptional*bool = true #
Determines whether a CloudFormation output with the `aws eks update-kubeconfig` command will be synthesized.

This command will include the cluster name and the ARN of the masters IAM role.

Note: If mastersRole is not specified, this property will be ignored and no config command will be emitted.

roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole #
Role that provides permissions for the Kubernetes control plane to make calls to AWS API operations on your behalf.

Default: A role is automatically created for you

securityGroupoptionalISecurityGroupsecurity_groupoptionalISecurityGroupsecurityGroupoptionalISecurityGroupSecurityGroupoptionalISecurityGroupSecurityGroupoptionalISecurityGroup #
Security Group to use for Control Plane ENIs.

Default: A security group is automatically created

The Kubernetes version to run in the cluster.
vpcoptionalIVpcvpcoptionalIVpcvpcoptionalIVpcVpcoptionalIVpcVpcoptionalIVpc #
The VPC in which to create the Cluster.

Default: a VPC with default configuration will be created and can be accessed through cluster.vpc.

vpcSubnetsoptionalSubnetSelection[]vpc_subnetsoptionaltyping.List[SubnetSelection]vpcSubnetsoptionalList<SubnetSelection>VpcSubnetsoptionalSubnetSelection[]VpcSubnetsoptional*[]SubnetSelection #
Where to place EKS Control Plane ENIs.

Default: All public and private subnets

For example, to only select private subnets, supply the following:

vpcSubnets: [{ subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS }]