@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
218 lines • 9.44 kB
JavaScript
// *** 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.NodeGroup = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages an EKS Node Group, which can provision and optionally update an Auto Scaling Group of Kubernetes worker nodes compatible with EKS. Additional documentation about this functionality can be found in the [EKS User Guide](https://docs.aws.amazon.com/eks/latest/userguide/managed-node-groups.html).
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.eks.NodeGroup("example", {
* clusterName: exampleAwsEksCluster.name,
* nodeGroupName: "example",
* nodeRoleArn: exampleAwsIamRole.arn,
* subnetIds: exampleAwsSubnet.map(__item => __item.id),
* scalingConfig: {
* desiredSize: 1,
* maxSize: 2,
* minSize: 1,
* },
* updateConfig: {
* maxUnavailable: 1,
* },
* }, {
* dependsOn: [
* example_AmazonEKSWorkerNodePolicy,
* example_AmazonEKSCNIPolicy,
* example_AmazonEC2ContainerRegistryReadOnly,
* ],
* });
* ```
*
* ### Ignoring Changes to Desired Size
*
* You can utilize [ignoreChanges](https://www.pulumi.com/docs/intro/concepts/programming-model/#ignorechanges) create an EKS Node Group with an initial size of running instances, then ignore any changes to that count caused externally (e.g. Application Autoscaling).
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.eks.NodeGroup("example", {scalingConfig: {
* desiredSize: 2,
* }});
* ```
*
* ### Example IAM Role for EKS Node Group
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.iam.Role("example", {
* name: "eks-node-group-example",
* assumeRolePolicy: JSON.stringify({
* Statement: [{
* Action: "sts:AssumeRole",
* Effect: "Allow",
* Principal: {
* Service: "ec2.amazonaws.com",
* },
* }],
* Version: "2012-10-17",
* }),
* });
* const example_AmazonEKSWorkerNodePolicy = new aws.iam.RolePolicyAttachment("example-AmazonEKSWorkerNodePolicy", {
* policyArn: "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy",
* role: example.name,
* });
* const example_AmazonEKSCNIPolicy = new aws.iam.RolePolicyAttachment("example-AmazonEKS_CNI_Policy", {
* policyArn: "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy",
* role: example.name,
* });
* const example_AmazonEC2ContainerRegistryReadOnly = new aws.iam.RolePolicyAttachment("example-AmazonEC2ContainerRegistryReadOnly", {
* policyArn: "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly",
* role: example.name,
* });
* ```
*
* ### Example Subnets for EKS Node Group
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* const available = aws.getAvailabilityZones({
* state: "available",
* });
* const example: aws.ec2.Subnet[] = [];
* for (const range = {value: 0}; range.value < 2; range.value++) {
* example.push(new aws.ec2.Subnet(`example-${range.value}`, {
* availabilityZone: available.then(available => available.names[range.value]),
* cidrBlock: std.cidrsubnet({
* input: exampleAwsVpc.cidrBlock,
* newbits: 8,
* netnum: range.value,
* }).then(invoke => invoke.result),
* vpcId: exampleAwsVpc.id,
* }));
* }
* ```
*
* ## Import
*
* Using `pulumi import`, import EKS Node Groups using the `cluster_name` and `node_group_name` separated by a colon (`:`). For example:
*
* ```sh
* $ pulumi import aws:eks/nodeGroup:NodeGroup my_node_group my_cluster:my_node_group
* ```
*/
class NodeGroup extends pulumi.CustomResource {
/**
* Get an existing NodeGroup 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 NodeGroup(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of NodeGroup. 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'] === NodeGroup.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["amiType"] = state?.amiType;
resourceInputs["arn"] = state?.arn;
resourceInputs["capacityType"] = state?.capacityType;
resourceInputs["clusterName"] = state?.clusterName;
resourceInputs["diskSize"] = state?.diskSize;
resourceInputs["forceUpdateVersion"] = state?.forceUpdateVersion;
resourceInputs["instanceTypes"] = state?.instanceTypes;
resourceInputs["labels"] = state?.labels;
resourceInputs["launchTemplate"] = state?.launchTemplate;
resourceInputs["nodeGroupName"] = state?.nodeGroupName;
resourceInputs["nodeGroupNamePrefix"] = state?.nodeGroupNamePrefix;
resourceInputs["nodeRepairConfig"] = state?.nodeRepairConfig;
resourceInputs["nodeRoleArn"] = state?.nodeRoleArn;
resourceInputs["region"] = state?.region;
resourceInputs["releaseVersion"] = state?.releaseVersion;
resourceInputs["remoteAccess"] = state?.remoteAccess;
resourceInputs["resources"] = state?.resources;
resourceInputs["scalingConfig"] = state?.scalingConfig;
resourceInputs["status"] = state?.status;
resourceInputs["subnetIds"] = state?.subnetIds;
resourceInputs["tags"] = state?.tags;
resourceInputs["tagsAll"] = state?.tagsAll;
resourceInputs["taints"] = state?.taints;
resourceInputs["updateConfig"] = state?.updateConfig;
resourceInputs["version"] = state?.version;
}
else {
const args = argsOrState;
if (args?.clusterName === undefined && !opts.urn) {
throw new Error("Missing required property 'clusterName'");
}
if (args?.nodeRoleArn === undefined && !opts.urn) {
throw new Error("Missing required property 'nodeRoleArn'");
}
if (args?.scalingConfig === undefined && !opts.urn) {
throw new Error("Missing required property 'scalingConfig'");
}
if (args?.subnetIds === undefined && !opts.urn) {
throw new Error("Missing required property 'subnetIds'");
}
resourceInputs["amiType"] = args?.amiType;
resourceInputs["capacityType"] = args?.capacityType;
resourceInputs["clusterName"] = args?.clusterName;
resourceInputs["diskSize"] = args?.diskSize;
resourceInputs["forceUpdateVersion"] = args?.forceUpdateVersion;
resourceInputs["instanceTypes"] = args?.instanceTypes;
resourceInputs["labels"] = args?.labels;
resourceInputs["launchTemplate"] = args?.launchTemplate;
resourceInputs["nodeGroupName"] = args?.nodeGroupName;
resourceInputs["nodeGroupNamePrefix"] = args?.nodeGroupNamePrefix;
resourceInputs["nodeRepairConfig"] = args?.nodeRepairConfig;
resourceInputs["nodeRoleArn"] = args?.nodeRoleArn;
resourceInputs["region"] = args?.region;
resourceInputs["releaseVersion"] = args?.releaseVersion;
resourceInputs["remoteAccess"] = args?.remoteAccess;
resourceInputs["scalingConfig"] = args?.scalingConfig;
resourceInputs["subnetIds"] = args?.subnetIds;
resourceInputs["tags"] = args?.tags;
resourceInputs["taints"] = args?.taints;
resourceInputs["updateConfig"] = args?.updateConfig;
resourceInputs["version"] = args?.version;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["resources"] = undefined /*out*/;
resourceInputs["status"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(NodeGroup.__pulumiType, name, resourceInputs, opts);
}
}
exports.NodeGroup = NodeGroup;
/** @internal */
NodeGroup.__pulumiType = 'aws:eks/nodeGroup:NodeGroup';
//# sourceMappingURL=nodeGroup.js.map
;