Skip to content

Instantly share code, notes, and snippets.

@clstokes
Last active April 6, 2021 23:34
Show Gist options
  • Save clstokes/44d3ba64cfc6c997b032d3c56812ee29 to your computer and use it in GitHub Desktop.
Save clstokes/44d3ba64cfc6c997b032d3c56812ee29 to your computer and use it in GitHub Desktop.
Pulumi - Transformation examples for AWS EKS Cluster
import * as awsx from "@pulumi/awsx";
import * as eks from "@pulumi/eks";
import * as pulumi from "@pulumi/pulumi";
const vpc = new awsx.ec2.Vpc("vpc", {});
const cluster = new eks.Cluster("cluster", {
vpcId: vpc.vpc.id,
subnetIds: vpc.publicSubnetIds,
instanceType: "t2.medium",
desiredCapacity: 2,
minSize: 1,
maxSize: 2,
storageClasses: "gp2",
deployDashboard: true,
}, {
transformations: [
args => {
if (args.type === "aws:eks/cluster:Cluster") {
return {
props: {
...args.props,
vpcConfig: {
...args.props.vpcConfig,
publicAccessCidrs: ["0.0.0.0/0"],
},
},
opts: args.opts,
};
}
return undefined;
},
(args) => {
if (args.type === "aws:ec2/launchConfiguration:LaunchConfiguration"
// && args.name === "example-ng-simple-ondemand-nodeLaunchConfiguration" // if needed
) {
console.log(`Transforming [${args.name}] to ignore changes to [imageId].`);
return {
props: args.props,
opts: pulumi.mergeOptions(args.opts, { ignoreChanges: ["imageId"] })
};
}
return undefined;
},
],
});
cluster.createNodeGroup("example-ng-simple-ondemand", {
instanceType: "t2.medium",
desiredCapacity: 1,
minSize: 1,
maxSize: 2,
labels: { "ondemand": "true" },
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment