UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

389 lines • 15.6 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Cluster = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages an EKS Cluster. * * ## Example Usage * * ### EKS Cluster * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const cluster = new aws.iam.Role("cluster", { * name: "eks-cluster-example", * assumeRolePolicy: JSON.stringify({ * Version: "2012-10-17", * Statement: [{ * Action: [ * "sts:AssumeRole", * "sts:TagSession", * ], * Effect: "Allow", * Principal: { * Service: "eks.amazonaws.com", * }, * }], * }), * }); * const clusterAmazonEKSClusterPolicy = new aws.iam.RolePolicyAttachment("cluster_AmazonEKSClusterPolicy", { * policyArn: "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy", * role: cluster.name, * }); * const example = new aws.eks.Cluster("example", { * name: "example", * accessConfig: { * authenticationMode: "API", * }, * roleArn: cluster.arn, * version: "1.31", * vpcConfig: { * subnetIds: [ * az1.id, * az2.id, * az3.id, * ], * }, * }, { * dependsOn: [clusterAmazonEKSClusterPolicy], * }); * ``` * * ### EKS Cluster with EKS Auto Mode * * > **NOTE:** When using EKS Auto Mode `compute_config.enabled`, `kubernetes_network_config.elastic_load_balancing.enabled`, and `storage_config.block_storage.enabled` must *ALL be set to `true`. Likewise for disabling EKS Auto Mode, all three arguments must be set to `false`. Enabling EKS Auto Mode also requires that `bootstrapSelfManagedAddons` is set to `false`. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const node = new aws.iam.Role("node", { * name: "eks-auto-node-example", * assumeRolePolicy: JSON.stringify({ * Version: "2012-10-17", * Statement: [{ * Action: ["sts:AssumeRole"], * Effect: "Allow", * Principal: { * Service: "ec2.amazonaws.com", * }, * }], * }), * }); * const cluster = new aws.iam.Role("cluster", { * name: "eks-cluster-example", * assumeRolePolicy: JSON.stringify({ * Version: "2012-10-17", * Statement: [{ * Action: [ * "sts:AssumeRole", * "sts:TagSession", * ], * Effect: "Allow", * Principal: { * Service: "eks.amazonaws.com", * }, * }], * }), * }); * const clusterAmazonEKSClusterPolicy = new aws.iam.RolePolicyAttachment("cluster_AmazonEKSClusterPolicy", { * policyArn: "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy", * role: cluster.name, * }); * const clusterAmazonEKSComputePolicy = new aws.iam.RolePolicyAttachment("cluster_AmazonEKSComputePolicy", { * policyArn: "arn:aws:iam::aws:policy/AmazonEKSComputePolicy", * role: cluster.name, * }); * const clusterAmazonEKSBlockStoragePolicy = new aws.iam.RolePolicyAttachment("cluster_AmazonEKSBlockStoragePolicy", { * policyArn: "arn:aws:iam::aws:policy/AmazonEKSBlockStoragePolicy", * role: cluster.name, * }); * const clusterAmazonEKSLoadBalancingPolicy = new aws.iam.RolePolicyAttachment("cluster_AmazonEKSLoadBalancingPolicy", { * policyArn: "arn:aws:iam::aws:policy/AmazonEKSLoadBalancingPolicy", * role: cluster.name, * }); * const clusterAmazonEKSNetworkingPolicy = new aws.iam.RolePolicyAttachment("cluster_AmazonEKSNetworkingPolicy", { * policyArn: "arn:aws:iam::aws:policy/AmazonEKSNetworkingPolicy", * role: cluster.name, * }); * const example = new aws.eks.Cluster("example", { * name: "example", * accessConfig: { * authenticationMode: "API", * }, * roleArn: cluster.arn, * version: "1.31", * bootstrapSelfManagedAddons: false, * computeConfig: { * enabled: true, * nodePools: ["general-purpose"], * nodeRoleArn: node.arn, * }, * kubernetesNetworkConfig: { * elasticLoadBalancing: { * enabled: true, * }, * }, * storageConfig: { * blockStorage: { * enabled: true, * }, * }, * vpcConfig: { * endpointPrivateAccess: true, * endpointPublicAccess: true, * subnetIds: [ * az1.id, * az2.id, * az3.id, * ], * }, * }, { * dependsOn: [ * clusterAmazonEKSClusterPolicy, * clusterAmazonEKSComputePolicy, * clusterAmazonEKSBlockStoragePolicy, * clusterAmazonEKSLoadBalancingPolicy, * clusterAmazonEKSNetworkingPolicy, * ], * }); * const nodeAmazonEKSWorkerNodeMinimalPolicy = new aws.iam.RolePolicyAttachment("node_AmazonEKSWorkerNodeMinimalPolicy", { * policyArn: "arn:aws:iam::aws:policy/AmazonEKSWorkerNodeMinimalPolicy", * role: node.name, * }); * const nodeAmazonEC2ContainerRegistryPullOnly = new aws.iam.RolePolicyAttachment("node_AmazonEC2ContainerRegistryPullOnly", { * policyArn: "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPullOnly", * role: node.name, * }); * ``` * * ### EKS Cluster with EKS Hybrid Nodes * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const cluster = new aws.iam.Role("cluster", { * name: "eks-cluster-example", * assumeRolePolicy: JSON.stringify({ * Version: "2012-10-17", * Statement: [{ * Action: [ * "sts:AssumeRole", * "sts:TagSession", * ], * Effect: "Allow", * Principal: { * Service: "eks.amazonaws.com", * }, * }], * }), * }); * const clusterAmazonEKSClusterPolicy = new aws.iam.RolePolicyAttachment("cluster_AmazonEKSClusterPolicy", { * policyArn: "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy", * role: cluster.name, * }); * const example = new aws.eks.Cluster("example", { * name: "example", * accessConfig: { * authenticationMode: "API", * }, * roleArn: cluster.arn, * version: "1.31", * remoteNetworkConfig: { * remoteNodeNetworks: { * cidrs: ["172.16.0.0/18"], * }, * remotePodNetworks: { * cidrs: ["172.16.64.0/18"], * }, * }, * vpcConfig: { * endpointPrivateAccess: true, * endpointPublicAccess: true, * subnetIds: [ * az1.id, * az2.id, * az3.id, * ], * }, * }, { * dependsOn: [clusterAmazonEKSClusterPolicy], * }); * ``` * * ### Local EKS Cluster on AWS Outpost * * [Creating a local Amazon EKS cluster on an AWS Outpost](https://docs.aws.amazon.com/eks/latest/userguide/create-cluster-outpost.html) * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.outposts.getOutpost({ * name: "example", * }); * const cluster = new aws.iam.Role("cluster", { * name: "eks-cluster-example", * assumeRolePolicy: JSON.stringify({ * Version: "2012-10-17", * Statement: [{ * Action: [ * "sts:AssumeRole", * "sts:TagSession", * ], * Effect: "Allow", * Principal: { * Service: [ * "eks.amazonaws.com", * "ec2.amazonaws.com", * ], * }, * }], * }), * }); * const clusterAmazonEKSLocalOutpostClusterPolicy = new aws.iam.RolePolicyAttachment("cluster_AmazonEKSLocalOutpostClusterPolicy", { * policyArn: "arn:aws:iam::aws:policy/AmazonEKSLocalOutpostClusterPolicy", * role: cluster.name, * }); * const exampleCluster = new aws.eks.Cluster("example", { * name: "example", * accessConfig: { * authenticationMode: "CONFIG_MAP", * }, * roleArn: cluster.arn, * version: "1.31", * vpcConfig: { * endpointPrivateAccess: true, * endpointPublicAccess: false, * subnetIds: [ * az1.id, * az2.id, * az3.id, * ], * }, * outpostConfig: { * controlPlaneInstanceType: "m5.large", * outpostArns: [example.then(example => example.arn)], * }, * }, { * dependsOn: [clusterAmazonEKSLocalOutpostClusterPolicy], * }); * ``` * * ## Import * * Using `pulumi import`, import EKS Clusters using the `name`. For example: * * ```sh * $ pulumi import aws:eks/cluster:Cluster my_cluster my_cluster * ``` */ class Cluster extends pulumi.CustomResource { /** * Get an existing Cluster resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new Cluster(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Cluster. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Cluster.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["accessConfig"] = state ? state.accessConfig : undefined; resourceInputs["arn"] = state ? state.arn : undefined; resourceInputs["bootstrapSelfManagedAddons"] = state ? state.bootstrapSelfManagedAddons : undefined; resourceInputs["certificateAuthority"] = state ? state.certificateAuthority : undefined; resourceInputs["clusterId"] = state ? state.clusterId : undefined; resourceInputs["computeConfig"] = state ? state.computeConfig : undefined; resourceInputs["createdAt"] = state ? state.createdAt : undefined; resourceInputs["defaultAddonsToRemoves"] = state ? state.defaultAddonsToRemoves : undefined; resourceInputs["enabledClusterLogTypes"] = state ? state.enabledClusterLogTypes : undefined; resourceInputs["encryptionConfig"] = state ? state.encryptionConfig : undefined; resourceInputs["endpoint"] = state ? state.endpoint : undefined; resourceInputs["forceUpdateVersion"] = state ? state.forceUpdateVersion : undefined; resourceInputs["identities"] = state ? state.identities : undefined; resourceInputs["kubernetesNetworkConfig"] = state ? state.kubernetesNetworkConfig : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["outpostConfig"] = state ? state.outpostConfig : undefined; resourceInputs["platformVersion"] = state ? state.platformVersion : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["remoteNetworkConfig"] = state ? state.remoteNetworkConfig : undefined; resourceInputs["roleArn"] = state ? state.roleArn : undefined; resourceInputs["status"] = state ? state.status : undefined; resourceInputs["storageConfig"] = state ? state.storageConfig : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["tagsAll"] = state ? state.tagsAll : undefined; resourceInputs["upgradePolicy"] = state ? state.upgradePolicy : undefined; resourceInputs["version"] = state ? state.version : undefined; resourceInputs["vpcConfig"] = state ? state.vpcConfig : undefined; resourceInputs["zonalShiftConfig"] = state ? state.zonalShiftConfig : undefined; } else { const args = argsOrState; if ((!args || args.roleArn === undefined) && !opts.urn) { throw new Error("Missing required property 'roleArn'"); } if ((!args || args.vpcConfig === undefined) && !opts.urn) { throw new Error("Missing required property 'vpcConfig'"); } resourceInputs["accessConfig"] = args ? args.accessConfig : undefined; resourceInputs["bootstrapSelfManagedAddons"] = args ? args.bootstrapSelfManagedAddons : undefined; resourceInputs["computeConfig"] = args ? args.computeConfig : undefined; resourceInputs["defaultAddonsToRemoves"] = args ? args.defaultAddonsToRemoves : undefined; resourceInputs["enabledClusterLogTypes"] = args ? args.enabledClusterLogTypes : undefined; resourceInputs["encryptionConfig"] = args ? args.encryptionConfig : undefined; resourceInputs["forceUpdateVersion"] = args ? args.forceUpdateVersion : undefined; resourceInputs["kubernetesNetworkConfig"] = args ? args.kubernetesNetworkConfig : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["outpostConfig"] = args ? args.outpostConfig : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["remoteNetworkConfig"] = args ? args.remoteNetworkConfig : undefined; resourceInputs["roleArn"] = args ? args.roleArn : undefined; resourceInputs["storageConfig"] = args ? args.storageConfig : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["upgradePolicy"] = args ? args.upgradePolicy : undefined; resourceInputs["version"] = args ? args.version : undefined; resourceInputs["vpcConfig"] = args ? args.vpcConfig : undefined; resourceInputs["zonalShiftConfig"] = args ? args.zonalShiftConfig : undefined; resourceInputs["arn"] = undefined /*out*/; resourceInputs["certificateAuthority"] = undefined /*out*/; resourceInputs["clusterId"] = undefined /*out*/; resourceInputs["createdAt"] = undefined /*out*/; resourceInputs["endpoint"] = undefined /*out*/; resourceInputs["identities"] = undefined /*out*/; resourceInputs["platformVersion"] = undefined /*out*/; resourceInputs["status"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Cluster.__pulumiType, name, resourceInputs, opts); } } exports.Cluster = Cluster; /** @internal */ Cluster.__pulumiType = 'aws:eks/cluster:Cluster'; //# sourceMappingURL=cluster.js.map