Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
metral committed Jan 30, 2020
1 parent 155f98f commit 2fa9c4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const cluster = new eks.Cluster(`${projectName}`, {
deployDashboard: false,
// Modify the roleMappings to update the aws-auth configMap.
// This will not remove the managed node group's role from aws-auth since
// it's role is set in instanceRoles. Not setting instanceRoles in the
// its role is set in instanceRoles. Not setting instanceRoles in the
// cluster first for the nodegroup will error eks.createManagedNodeGroup().
roleMappings: [roleMapping0, roleMapping1],
instanceRoles: [roles[2]],
Expand Down
18 changes: 9 additions & 9 deletions nodejs/eks/nodegroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ export type ManagedNodeGroupOptions = Omit<aws.eks.NodeGroupArgs, "clusterName"
* Make nodeRoleArn optional, since users may prefer to provide the
* nodegroup role directly using nodeRole.
*/
nodeRoleArn?: pulumi.Output<string>;
nodeRoleArn?: pulumi.Input<string>;

/**
* Make nodeRole an option in lieu of nodeGroupArn to create consistency
Expand Down Expand Up @@ -704,26 +704,26 @@ export function createManagedNodeGroup(name: string, args: ManagedNodeGroupOptio
}

if (args.nodeRole && args.nodeRoleArn) {
throw new Error("nodeRole and nodeRoleArn are mutually exclusive to create a managed node group. Choose a single approach");
throw new Error("nodeRole and nodeRoleArn are mutually exclusive to create a managed node group.");
}

// Compute the nodegroup role.
let roleArn: pulumi.Output<string> = pulumi.output("");
let roleArn: pulumi.Input<string> = pulumi.output("");
if (args.nodeRole !== undefined) {
roleArn = pulumi.output(args.nodeRole).apply(r => r.arn);
} else if (args.nodeRoleArn !== undefined) {
roleArn = args.nodeRoleArn;
roleArn = pulumi.output(args.nodeRoleArn);
}

// Check that the nodegroup role has been set on the cluster to
// ensure that the aws-auth configmap was properly formed.
const roleExistsInNodeAccess = pulumi.all([
const nodegroupRole = pulumi.all([
core.instanceRoles,
roleArn,
]).apply(([roles, rArn]) => {
// Map out the ARNs of all of the instanceRoles.
const roleArns = roles.map(role => {
return role.arn.apply(a => a);
return role.arn;
});
// Try finding the nodeRole in the ARNs array.
return pulumi.all([
Expand All @@ -734,9 +734,9 @@ export function createManagedNodeGroup(name: string, args: ManagedNodeGroupOptio
});
});

roleExistsInNodeAccess.apply(exist => {
if (!exist) {
throw new Error(`A managed node group cannot be created without first setting it's role in the cluster's instanceRoles`);
nodegroupRole.apply(role => {
if (!role) {
throw new Error(`A managed node group cannot be created without first setting its role in the cluster's instanceRoles`);
}
});

Expand Down

0 comments on commit 2fa9c4c

Please sign in to comment.