UNPKG

@pulumi/aws

Version:

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

391 lines • 14.9 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, { ...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?.accessConfig; resourceInputs["arn"] = state?.arn; resourceInputs["bootstrapSelfManagedAddons"] = state?.bootstrapSelfManagedAddons; resourceInputs["certificateAuthority"] = state?.certificateAuthority; resourceInputs["clusterId"] = state?.clusterId; resourceInputs["computeConfig"] = state?.computeConfig; resourceInputs["createdAt"] = state?.createdAt; resourceInputs["defaultAddonsToRemoves"] = state?.defaultAddonsToRemoves; resourceInputs["deletionProtection"] = state?.deletionProtection; resourceInputs["enabledClusterLogTypes"] = state?.enabledClusterLogTypes; resourceInputs["encryptionConfig"] = state?.encryptionConfig; resourceInputs["endpoint"] = state?.endpoint; resourceInputs["forceUpdateVersion"] = state?.forceUpdateVersion; resourceInputs["identities"] = state?.identities; resourceInputs["kubernetesNetworkConfig"] = state?.kubernetesNetworkConfig; resourceInputs["name"] = state?.name; resourceInputs["outpostConfig"] = state?.outpostConfig; resourceInputs["platformVersion"] = state?.platformVersion; resourceInputs["region"] = state?.region; resourceInputs["remoteNetworkConfig"] = state?.remoteNetworkConfig; resourceInputs["roleArn"] = state?.roleArn; resourceInputs["status"] = state?.status; resourceInputs["storageConfig"] = state?.storageConfig; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; resourceInputs["upgradePolicy"] = state?.upgradePolicy; resourceInputs["version"] = state?.version; resourceInputs["vpcConfig"] = state?.vpcConfig; resourceInputs["zonalShiftConfig"] = state?.zonalShiftConfig; } else { const args = argsOrState; if (args?.roleArn === undefined && !opts.urn) { throw new Error("Missing required property 'roleArn'"); } if (args?.vpcConfig === undefined && !opts.urn) { throw new Error("Missing required property 'vpcConfig'"); } resourceInputs["accessConfig"] = args?.accessConfig; resourceInputs["bootstrapSelfManagedAddons"] = args?.bootstrapSelfManagedAddons; resourceInputs["computeConfig"] = args?.computeConfig; resourceInputs["defaultAddonsToRemoves"] = args?.defaultAddonsToRemoves; resourceInputs["deletionProtection"] = args?.deletionProtection; resourceInputs["enabledClusterLogTypes"] = args?.enabledClusterLogTypes; resourceInputs["encryptionConfig"] = args?.encryptionConfig; resourceInputs["forceUpdateVersion"] = args?.forceUpdateVersion; resourceInputs["kubernetesNetworkConfig"] = args?.kubernetesNetworkConfig; resourceInputs["name"] = args?.name; resourceInputs["outpostConfig"] = args?.outpostConfig; resourceInputs["region"] = args?.region; resourceInputs["remoteNetworkConfig"] = args?.remoteNetworkConfig; resourceInputs["roleArn"] = args?.roleArn; resourceInputs["storageConfig"] = args?.storageConfig; resourceInputs["tags"] = args?.tags; resourceInputs["upgradePolicy"] = args?.upgradePolicy; resourceInputs["version"] = args?.version; resourceInputs["vpcConfig"] = args?.vpcConfig; resourceInputs["zonalShiftConfig"] = args?.zonalShiftConfig; 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