@pulumi/eks 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +16 -11
  2. package/cert-thumprint.d.ts +11 -11
  3. package/cert-thumprint.js +25 -21
  4. package/cert-thumprint.js.map +1 -1
  5. package/cluster.js +113 -89
  6. package/cluster.js.map +1 -1
  7. package/cmd/provider/cluster.js.map +1 -1
  8. package/cmd/provider/cni.js +99 -36
  9. package/cmd/provider/cni.js.map +1 -1
  10. package/cmd/provider/index.js +6 -10
  11. package/cmd/provider/index.js.map +1 -1
  12. package/cmd/provider/nodegroup.js.map +1 -1
  13. package/cmd/provider/randomSuffix.js +3 -1
  14. package/cmd/provider/randomSuffix.js.map +1 -1
  15. package/cmd/provider/schema.json +85 -85
  16. package/cmd/provider/securitygroup.js.map +1 -1
  17. package/cni/aws-k8s-cni.yaml +195 -196
  18. package/cni.js +3 -1
  19. package/cni.js.map +1 -1
  20. package/dashboard/heapster-rbac.yaml +7 -7
  21. package/dashboard/heapster.yaml +33 -33
  22. package/dashboard/influxdb.yaml +31 -31
  23. package/dashboard/kubernetes-dashboard.yaml +104 -104
  24. package/dashboard.js +5 -3
  25. package/dashboard.js.map +1 -1
  26. package/dependencies.js +16 -6
  27. package/dependencies.js.map +1 -1
  28. package/index.d.ts +2 -2
  29. package/index.js.map +1 -1
  30. package/nodegroup.d.ts +12 -0
  31. package/nodegroup.js +135 -91
  32. package/nodegroup.js.map +1 -1
  33. package/package.json +27 -16
  34. package/package.json.dev +27 -16
  35. package/randomSuffix.js +4 -2
  36. package/randomSuffix.js.map +1 -1
  37. package/securitygroup.js +1 -4
  38. package/securitygroup.js.map +1 -1
  39. package/servicerole.js +10 -8
  40. package/servicerole.js.map +1 -1
  41. package/storageclass.d.ts +16 -16
  42. package/storageclass.js +7 -6
  43. package/storageclass.js.map +1 -1
package/nodegroup.js CHANGED
@@ -73,8 +73,9 @@ class NodeGroupInternal extends pulumi.ComponentResource {
73
73
  return;
74
74
  }
75
75
  super(type, name, args, opts);
76
- const core = pulumi.output(args.cluster)
77
- .apply(c => c instanceof cluster_1.ClusterInternal ? c.core : c);
76
+ const core = pulumi
77
+ .output(args.cluster)
78
+ .apply((c) => (c instanceof cluster_1.ClusterInternal ? c.core : c));
78
79
  const group = createNodeGroupInternal(name, args, core, this, opts === null || opts === void 0 ? void 0 : opts.provider);
79
80
  this.autoScalingGroupName = group.autoScalingGroupName;
80
81
  this.cfnStack = pulumi.output(group.cfnStack);
@@ -128,8 +129,9 @@ class NodeGroupV2Internal extends pulumi.ComponentResource {
128
129
  return;
129
130
  }
130
131
  super(type, name, args, opts);
131
- const core = pulumi.output(args.cluster)
132
- .apply(c => c instanceof cluster_1.ClusterInternal ? c.core : c);
132
+ const core = pulumi
133
+ .output(args.cluster)
134
+ .apply((c) => (c instanceof cluster_1.ClusterInternal ? c.core : c));
133
135
  const group = createNodeGroupV2Internal(name, args, core, this, opts === null || opts === void 0 ? void 0 : opts.provider);
134
136
  this.autoScalingGroup = pulumi.output(group.autoScalingGroup);
135
137
  this.extraNodeSecurityGroups = pulumi.output((_a = group.extraNodeSecurityGroups) !== null && _a !== void 0 ? _a : []);
@@ -155,14 +157,14 @@ function createNodeGroup(name, args, parent, provider) {
155
157
  exports.createNodeGroup = createNodeGroup;
156
158
  function createNodeGroupInternal(name, args, core, parent, provider) {
157
159
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
158
- const instanceProfile = core.apply(c => {
160
+ const instanceProfile = core.apply((c) => {
159
161
  var _a;
160
162
  if (!args.instanceProfile && !c.nodeGroupOptions.instanceProfile) {
161
163
  throw new Error(`an instanceProfile is required`);
162
164
  }
163
165
  return (_a = args.instanceProfile) !== null && _a !== void 0 ? _a : c.nodeGroupOptions.instanceProfile;
164
166
  });
165
- core.apply(c => {
167
+ core.apply((c) => {
166
168
  if (c.nodeGroupOptions.nodeSecurityGroup && args.nodeSecurityGroup) {
167
169
  if (c.nodeSecurityGroupTags &&
168
170
  c.nodeGroupOptions.nodeSecurityGroup.id !== args.nodeSecurityGroup.id) {
@@ -176,12 +178,17 @@ function createNodeGroupInternal(name, args, core, parent, provider) {
176
178
  if (args.amiId && args.gpu) {
177
179
  throw new Error("amiId and gpu are mutually exclusive.");
178
180
  }
179
- if (args.nodeUserDataOverride && (args.nodeUserData || args.labels || args.taints || args.kubeletExtraArgs || args.bootstrapExtraArgs)) {
181
+ if (args.nodeUserDataOverride &&
182
+ (args.nodeUserData ||
183
+ args.labels ||
184
+ args.taints ||
185
+ args.kubeletExtraArgs ||
186
+ args.bootstrapExtraArgs)) {
180
187
  throw new Error("nodeUserDataOverride and any combination of {nodeUserData, labels, taints, kubeletExtraArgs, or bootstrapExtraArgs} is mutually exclusive.");
181
188
  }
182
189
  let nodeSecurityGroup;
183
190
  const eksCluster = core.cluster;
184
- const cfnStackDeps = core.apply(c => {
191
+ const cfnStackDeps = core.apply((c) => {
185
192
  const result = [];
186
193
  if (c.vpcCni !== undefined) {
187
194
  result.push(c.vpcCni);
@@ -203,20 +210,20 @@ function createNodeGroupInternal(name, args, core, parent, provider) {
203
210
  vpcId: core.vpcId,
204
211
  clusterSecurityGroup: core.clusterSecurityGroup,
205
212
  eksCluster: eksCluster,
206
- tags: pulumi.all([
207
- core.tags,
208
- core.nodeSecurityGroupTags,
209
- ]).apply(([tags, nodeSecurityGroupTags]) => (Object.assign(Object.assign({}, nodeSecurityGroupTags), tags))),
213
+ tags: pulumi.all([core.tags, core.nodeSecurityGroupTags]).apply(([tags, nodeSecurityGroupTags]) => (Object.assign(Object.assign({}, nodeSecurityGroupTags), tags))),
210
214
  }, parent);
211
215
  }
212
216
  // This apply is necessary in s.t. the launchConfiguration picks up a
213
217
  // dependency on the eksClusterIngressRule. The nodes may fail to
214
218
  // connect to the cluster if we attempt to create them before the
215
219
  // ingress rule is applied.
216
- const nodeSecurityGroupId = pulumi.all([nodeSecurityGroup.id, eksClusterIngressRule.id])
220
+ const nodeSecurityGroupId = pulumi
221
+ .all([nodeSecurityGroup.id, eksClusterIngressRule.id])
217
222
  .apply(([id]) => id);
218
223
  // Collect the IDs of any extra, user-specific security groups.
219
- const extraNodeSecurityGroupIds = args.extraNodeSecurityGroups ? args.extraNodeSecurityGroups.map(sg => sg.id) : [];
224
+ const extraNodeSecurityGroupIds = args.extraNodeSecurityGroups
225
+ ? args.extraNodeSecurityGroups.map((sg) => sg.id)
226
+ : [];
220
227
  // If requested, add a new EC2 KeyPair for SSH access to the instances.
221
228
  let keyName = args.keyName;
222
229
  if (args.nodePublicKey) {
@@ -248,7 +255,7 @@ function createNodeGroupInternal(name, args, core, parent, provider) {
248
255
  kubeletExtraArgs.push("--register-with-taints=" + parts.join(","));
249
256
  }
250
257
  }
251
- let bootstrapExtraArgs = args.bootstrapExtraArgs ? (" " + args.bootstrapExtraArgs) : "";
258
+ let bootstrapExtraArgs = args.bootstrapExtraArgs ? " " + args.bootstrapExtraArgs : "";
252
259
  if (kubeletExtraArgs.length === 1) {
253
260
  // For backward compatibility with previous versions of this package, don't wrap a single argument with `''`.
254
261
  bootstrapExtraArgs += ` --kubelet-extra-args ${kubeletExtraArgs[0]}`;
@@ -256,7 +263,15 @@ function createNodeGroupInternal(name, args, core, parent, provider) {
256
263
  else if (kubeletExtraArgs.length > 1) {
257
264
  bootstrapExtraArgs += ` --kubelet-extra-args '${kubeletExtraArgs.join(" ")}'`;
258
265
  }
259
- const userdata = pulumi.all([awsRegion, eksCluster.name, eksCluster.endpoint, eksCluster.certificateAuthority, cfnStackName, userDataArg])
266
+ const userdata = pulumi
267
+ .all([
268
+ awsRegion,
269
+ eksCluster.name,
270
+ eksCluster.endpoint,
271
+ eksCluster.certificateAuthority,
272
+ cfnStackName,
273
+ userDataArg,
274
+ ])
260
275
  .apply(([region, clusterName, clusterEndpoint, clusterCa, stackName, customUserData]) => {
261
276
  if (customUserData !== "") {
262
277
  customUserData = `cat >/opt/user-data <<${stackName}-user-data
@@ -278,7 +293,7 @@ ${customUserData}
278
293
  let amiId = args.amiId;
279
294
  if (!amiId) {
280
295
  const amiType = ((_a = args.amiType) !== null && _a !== void 0 ? _a : args.gpu) ? "amazon-linux-2-gpu" : "amazon-linux-2";
281
- amiId = version.apply(v => {
296
+ amiId = version.apply((v) => {
282
297
  const parameterName = `/aws/service/eks/optimized-ami/${v}/${amiType}/recommended/image_id`;
283
298
  return pulumi.output(aws.ssm.getParameter({ name: parameterName }, { parent, async: true })).value;
284
299
  });
@@ -290,7 +305,7 @@ ${customUserData}
290
305
  if (args.nodeAssociatePublicIpAddress !== undefined) {
291
306
  nodeAssociatePublicIpAddress = args.nodeAssociatePublicIpAddress;
292
307
  }
293
- const numeric = new RegExp("^\d+$");
308
+ const numeric = new RegExp("^d+$");
294
309
  if (args.nodeRootVolumeIops && args.nodeRootVolumeType !== "io1") {
295
310
  throw new Error("Cannot create a cluster node root volume of non-io1 type with provisioned IOPS (nodeRootVolumeIops).");
296
311
  }
@@ -316,7 +331,7 @@ ${customUserData}
316
331
  securityGroups: [nodeSecurityGroupId, ...extraNodeSecurityGroupIds],
317
332
  spotPrice: args.spotPrice,
318
333
  rootBlockDevice: {
319
- encrypted: (_f = ((_e = ((_d = args.encryptRootBlockDevice) !== null && _d !== void 0 ? _d : args.encryptRootBockDevice)) !== null && _e !== void 0 ? _e : args.nodeRootVolumeEncrypted)) !== null && _f !== void 0 ? _f : false,
334
+ encrypted: (_f = (_e = (_d = args.encryptRootBlockDevice) !== null && _d !== void 0 ? _d : args.encryptRootBockDevice) !== null && _e !== void 0 ? _e : args.nodeRootVolumeEncrypted) !== null && _f !== void 0 ? _f : false,
320
335
  volumeSize: (_g = args.nodeRootVolumeSize) !== null && _g !== void 0 ? _g : 20,
321
336
  volumeType: (_h = args.nodeRootVolumeType) !== null && _h !== void 0 ? _h : "gp2",
322
337
  iops: args.nodeRootVolumeIops,
@@ -327,15 +342,18 @@ ${customUserData}
327
342
  }, { parent, provider });
328
343
  // Compute the worker node group subnets to use from the various approaches.
329
344
  let workerSubnetIds;
330
- if (args.nodeSubnetIds !== undefined) { // Use the specified override subnetIds.
345
+ if (args.nodeSubnetIds !== undefined) {
346
+ // Use the specified override subnetIds.
331
347
  workerSubnetIds = pulumi.output(args.nodeSubnetIds);
332
348
  }
333
349
  else {
334
- workerSubnetIds = core.apply(c => {
335
- if (c.privateSubnetIds !== undefined) { // Use the specified private subnetIds.
350
+ workerSubnetIds = core.apply((c) => {
351
+ if (c.privateSubnetIds !== undefined) {
352
+ // Use the specified private subnetIds.
336
353
  return Promise.resolve(c.privateSubnetIds);
337
354
  }
338
- else if (c.publicSubnetIds !== undefined) { // Use the specified public subnetIds.
355
+ else if (c.publicSubnetIds !== undefined) {
356
+ // Use the specified public subnetIds.
339
357
  return Promise.resolve(c.publicSubnetIds);
340
358
  }
341
359
  else {
@@ -358,18 +376,19 @@ ${customUserData}
358
376
  if (args.spotPrice) {
359
377
  minInstancesInService = 0;
360
378
  }
361
- const autoScalingGroupTags = pulumi.all([
362
- eksCluster.name,
363
- args.autoScalingGroupTags,
364
- ]).apply(([clusterName, asgTags]) => (Object.assign({ "Name": `${clusterName}-worker`, [`kubernetes.io/cluster/${clusterName}`]: "owned" }, asgTags)));
365
- const cfnTemplateBody = pulumi.all([
379
+ const autoScalingGroupTags = pulumi
380
+ .all([eksCluster.name, args.autoScalingGroupTags])
381
+ .apply(([clusterName, asgTags]) => (Object.assign({ Name: `${clusterName}-worker`, [`kubernetes.io/cluster/${clusterName}`]: "owned" }, asgTags)));
382
+ const cfnTemplateBody = pulumi
383
+ .all([
366
384
  nodeLaunchConfiguration.id,
367
385
  args.desiredCapacity,
368
386
  args.minSize,
369
387
  args.maxSize,
370
388
  tagsToAsgTags(autoScalingGroupTags),
371
389
  workerSubnetIds.apply(JSON.stringify),
372
- ]).apply(([launchConfig, desiredCapacity, minSize, maxSize, asgTags, vpcSubnetIds]) => `
390
+ ])
391
+ .apply(([launchConfig, desiredCapacity, minSize, maxSize, asgTags, vpcSubnetIds]) => `
373
392
  AWSTemplateFormatVersion: '2010-09-09'
374
393
  Outputs:
375
394
  NodeGroup:
@@ -393,12 +412,9 @@ ${customUserData}
393
412
  const cfnStack = new aws.cloudformation.Stack(`${name}-nodes`, {
394
413
  name: cfnStackName,
395
414
  templateBody: cfnTemplateBody,
396
- tags: pulumi.all([
397
- core.tags,
398
- args.cloudFormationTags,
399
- ]).apply(([tags, cloudFormationTags]) => (Object.assign(Object.assign({ "Name": `${name}-nodes` }, cloudFormationTags), tags))),
415
+ tags: pulumi.all([core.tags, args.cloudFormationTags]).apply(([tags, cloudFormationTags]) => (Object.assign(Object.assign({ Name: `${name}-nodes` }, cloudFormationTags), tags))),
400
416
  }, { parent, dependsOn: cfnStackDeps, provider });
401
- const autoScalingGroupName = cfnStack.outputs.apply(outputs => {
417
+ const autoScalingGroupName = cfnStack.outputs.apply((outputs) => {
402
418
  if (!("NodeGroup" in outputs)) {
403
419
  throw new Error("CloudFormation stack is not ready. Stack output key 'NodeGroup' does not exist.");
404
420
  }
@@ -424,14 +440,14 @@ function createNodeGroupV2(name, args, parent, provider) {
424
440
  exports.createNodeGroupV2 = createNodeGroupV2;
425
441
  function createNodeGroupV2Internal(name, args, core, parent, provider) {
426
442
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
427
- const instanceProfileArn = core.apply(c => {
443
+ const instanceProfileArn = core.apply((c) => {
428
444
  var _a, _b;
429
445
  if (!args.instanceProfile && !c.nodeGroupOptions.instanceProfile) {
430
446
  throw new Error(`an instanceProfile is required`);
431
447
  }
432
448
  return (_b = (_a = args.instanceProfile) === null || _a === void 0 ? void 0 : _a.arn) !== null && _b !== void 0 ? _b : c.nodeGroupOptions.instanceProfile.arn;
433
449
  });
434
- core.apply(c => {
450
+ core.apply((c) => {
435
451
  if (c.nodeGroupOptions.nodeSecurityGroup && args.nodeSecurityGroup) {
436
452
  if (c.nodeSecurityGroupTags &&
437
453
  c.nodeGroupOptions.nodeSecurityGroup.id !== args.nodeSecurityGroup.id) {
@@ -445,12 +461,17 @@ function createNodeGroupV2Internal(name, args, core, parent, provider) {
445
461
  if (args.amiId && args.gpu) {
446
462
  throw new Error("amiId and gpu are mutually exclusive.");
447
463
  }
448
- if (args.nodeUserDataOverride && (args.nodeUserData || args.labels || args.taints || args.kubeletExtraArgs || args.bootstrapExtraArgs)) {
464
+ if (args.nodeUserDataOverride &&
465
+ (args.nodeUserData ||
466
+ args.labels ||
467
+ args.taints ||
468
+ args.kubeletExtraArgs ||
469
+ args.bootstrapExtraArgs)) {
449
470
  throw new Error("nodeUserDataOverride and any combination of {nodeUserData, labels, taints, kubeletExtraArgs, or bootstrapExtraArgs} is mutually exclusive.");
450
471
  }
451
472
  let nodeSecurityGroup;
452
473
  const eksCluster = core.cluster;
453
- const nodeGroupDeps = core.apply(c => {
474
+ const nodeGroupDeps = core.apply((c) => {
454
475
  const result = [];
455
476
  if (c.vpcCni !== undefined) {
456
477
  result.push(c.vpcCni);
@@ -472,18 +493,23 @@ function createNodeGroupV2Internal(name, args, core, parent, provider) {
472
493
  vpcId: core.vpcId,
473
494
  clusterSecurityGroup: core.clusterSecurityGroup,
474
495
  eksCluster: eksCluster,
475
- tags: core.apply(c => (Object.assign(Object.assign({}, c.nodeSecurityGroupTags), c.tags))),
496
+ tags: core.apply((c) => (Object.assign(Object.assign({}, c.nodeSecurityGroupTags), c.tags))),
476
497
  }, parent);
477
498
  }
478
499
  // This apply is necessary in s.t. the launchConfiguration picks up a
479
500
  // dependency on the eksClusterIngressRule. The nodes may fail to
480
501
  // connect to the cluster if we attempt to create them before the
481
502
  // ingress rule is applied.
482
- const nodeSecurityGroupId = pulumi.all([nodeSecurityGroup.id, eksClusterIngressRule.id])
503
+ const nodeSecurityGroupId = pulumi
504
+ .all([nodeSecurityGroup.id, eksClusterIngressRule.id])
483
505
  .apply(([id]) => id);
484
506
  // Collect the IDs of any extra, user-specific security groups.
485
- const extraNodeSecurityGroupIds = args.extraNodeSecurityGroups ? args.extraNodeSecurityGroups.map(sg => sg.id) : [];
486
- const extraNodeSecurityGroupNames = args.extraNodeSecurityGroups ? args.extraNodeSecurityGroups.map(sg => sg.name) : [];
507
+ const extraNodeSecurityGroupIds = args.extraNodeSecurityGroups
508
+ ? args.extraNodeSecurityGroups.map((sg) => sg.id)
509
+ : [];
510
+ const extraNodeSecurityGroupNames = args.extraNodeSecurityGroups
511
+ ? args.extraNodeSecurityGroups.map((sg) => sg.name)
512
+ : [];
487
513
  // If requested, add a new EC2 KeyPair for SSH access to the instances.
488
514
  let keyName = args.keyName;
489
515
  if (args.nodePublicKey) {
@@ -514,7 +540,7 @@ function createNodeGroupV2Internal(name, args, core, parent, provider) {
514
540
  kubeletExtraArgs.push("--register-with-taints=" + parts.join(","));
515
541
  }
516
542
  }
517
- let bootstrapExtraArgs = args.bootstrapExtraArgs ? (" " + args.bootstrapExtraArgs) : "";
543
+ let bootstrapExtraArgs = args.bootstrapExtraArgs ? " " + args.bootstrapExtraArgs : "";
518
544
  if (kubeletExtraArgs.length === 1) {
519
545
  // For backward compatibility with previous versions of this package, don't wrap a single argument with `''`.
520
546
  bootstrapExtraArgs += ` --kubelet-extra-args ${kubeletExtraArgs[0]}`;
@@ -522,8 +548,17 @@ function createNodeGroupV2Internal(name, args, core, parent, provider) {
522
548
  else if (kubeletExtraArgs.length > 1) {
523
549
  bootstrapExtraArgs += ` --kubelet-extra-args '${kubeletExtraArgs.join(" ")}'`;
524
550
  }
525
- const userdata = pulumi.all([awsRegion, eksCluster.name, eksCluster.endpoint, eksCluster.certificateAuthority, name, userDataArg, args.nodeUserDataOverride])
526
- .apply(([region, clusterName, clusterEndpoint, clusterCa, stackName, customUserData, nodeUserDataOverride]) => {
551
+ const userdata = pulumi
552
+ .all([
553
+ awsRegion,
554
+ eksCluster.name,
555
+ eksCluster.endpoint,
556
+ eksCluster.certificateAuthority,
557
+ name,
558
+ userDataArg,
559
+ args.nodeUserDataOverride,
560
+ ])
561
+ .apply(([region, clusterName, clusterEndpoint, clusterCa, stackName, customUserData, nodeUserDataOverride,]) => {
527
562
  if (nodeUserDataOverride !== undefined && nodeUserDataOverride !== "") {
528
563
  return nodeUserDataOverride;
529
564
  }
@@ -540,13 +575,14 @@ chmod +x /opt/user-data
540
575
  /etc/eks/bootstrap.sh --apiserver-endpoint "${clusterEndpoint}" --b64-cluster-ca "${clusterCa.data}" "${clusterName}"${bootstrapExtraArgs}
541
576
  ${customUserData}
542
577
  `;
543
- }).apply(x => Buffer.from(x, "utf-8").toString("base64")); // Launch Templates require user data to be passed as base64.
578
+ })
579
+ .apply((x) => Buffer.from(x, "utf-8").toString("base64")); // Launch Templates require user data to be passed as base64.
544
580
  const version = pulumi.output(args.version || core.cluster.version);
545
581
  // https://docs.aws.amazon.com/eks/latest/userguide/retrieve-ami-id.html
546
582
  let amiId = args.amiId;
547
583
  if (!amiId) {
548
584
  const amiType = ((_a = args.amiType) !== null && _a !== void 0 ? _a : args.gpu) ? "amazon-linux-2-gpu" : "amazon-linux-2";
549
- amiId = version.apply(v => {
585
+ amiId = version.apply((v) => {
550
586
  const parameterName = `/aws/service/eks/optimized-ami/${v}/${amiType}/recommended/image_id`;
551
587
  return pulumi.output(aws.ssm.getParameter({ name: parameterName }, { parent, async: true })).value;
552
588
  });
@@ -558,7 +594,7 @@ ${customUserData}
558
594
  if (args.nodeAssociatePublicIpAddress !== undefined) {
559
595
  nodeAssociatePublicIpAddress = args.nodeAssociatePublicIpAddress;
560
596
  }
561
- const numeric = new RegExp("^\d+$");
597
+ const numeric = new RegExp("^d+$");
562
598
  if (args.nodeRootVolumeIops && args.nodeRootVolumeType !== "io1") {
563
599
  throw new Error("Cannot create a cluster node root volume of non-io1 type with provisioned IOPS (nodeRootVolumeIops).");
564
600
  }
@@ -575,13 +611,15 @@ ${customUserData}
575
611
  throw new Error("Cannot create a cluster node root volume of gp3 type without provisioned throughput (nodeRootVolumeThroughput) as integer value.");
576
612
  }
577
613
  }
578
- const marketOptions = args.spotPrice ? {
579
- marketType: "spot",
580
- spotOptions: {
581
- maxPrice: args.spotPrice,
582
- },
583
- } : {};
584
- const device = pulumi.output(amiId).apply(id => aws.ec2.getAmi({
614
+ const marketOptions = args.spotPrice
615
+ ? {
616
+ marketType: "spot",
617
+ spotOptions: {
618
+ maxPrice: args.spotPrice,
619
+ },
620
+ }
621
+ : {};
622
+ const device = pulumi.output(amiId).apply((id) => aws.ec2.getAmi({
585
623
  owners: ["self", "amazon"],
586
624
  filters: [
587
625
  {
@@ -589,14 +627,15 @@ ${customUserData}
589
627
  values: [id],
590
628
  },
591
629
  ],
592
- })).blockDeviceMappings[0].deviceName;
630
+ }, { parent })).blockDeviceMappings[0].deviceName;
593
631
  const nodeLaunchTemplate = new aws.ec2.LaunchTemplate(`${name}-launchTemplate`, {
594
632
  imageId: amiId,
595
633
  instanceType: args.instanceType || "t2.medium",
596
634
  iamInstanceProfile: { arn: instanceProfileArn },
597
635
  keyName: keyName,
598
636
  instanceMarketOptions: marketOptions,
599
- blockDeviceMappings: [{
637
+ blockDeviceMappings: [
638
+ {
600
639
  deviceName: device,
601
640
  ebs: {
602
641
  encrypted: ((_d = args.nodeRootVolumeEncrypted) !== null && _d !== void 0 ? _d : false) ? "true" : "false",
@@ -606,25 +645,32 @@ ${customUserData}
606
645
  throughput: args.nodeRootVolumeThroughput,
607
646
  deleteOnTermination: ((_g = args.nodeRootVolumeDeleteOnTermination) !== null && _g !== void 0 ? _g : true) ? "true" : "false",
608
647
  },
609
- }],
610
- networkInterfaces: [{
648
+ },
649
+ ],
650
+ networkInterfaces: [
651
+ {
611
652
  associatePublicIpAddress: String(nodeAssociatePublicIpAddress),
612
653
  securityGroups: [nodeSecurityGroupId, ...extraNodeSecurityGroupIds],
613
- }],
654
+ },
655
+ ],
656
+ metadataOptions: args.metadataOptions,
614
657
  userData: userdata,
615
658
  tagSpecifications: args.launchTemplateTagSpecifications,
616
659
  }, { parent, provider });
617
660
  // Compute the worker node group subnets to use from the various approaches.
618
661
  let workerSubnetIds;
619
- if (args.nodeSubnetIds !== undefined) { // Use the specified override subnetIds.
662
+ if (args.nodeSubnetIds !== undefined) {
663
+ // Use the specified override subnetIds.
620
664
  workerSubnetIds = pulumi.output(args.nodeSubnetIds);
621
665
  }
622
666
  else {
623
- workerSubnetIds = core.apply(c => {
624
- if (c.privateSubnetIds !== undefined) { // Use the specified private subnetIds.
667
+ workerSubnetIds = core.apply((c) => {
668
+ if (c.privateSubnetIds !== undefined) {
669
+ // Use the specified private subnetIds.
625
670
  return Promise.resolve(c.privateSubnetIds);
626
671
  }
627
- else if (c.publicSubnetIds !== undefined) { // Use the specified public subnetIds.
672
+ else if (c.publicSubnetIds !== undefined) {
673
+ // Use the specified public subnetIds.
628
674
  return Promise.resolve(c.publicSubnetIds);
629
675
  }
630
676
  else {
@@ -633,8 +679,10 @@ ${customUserData}
633
679
  }
634
680
  });
635
681
  }
636
- const asgTags = pulumi.all([eksCluster.name, args.autoScalingGroupTags]).apply(([clusterName, tags]) => inputTagsToASGTags(clusterName, tags));
637
- const launchTemplateVersion = nodeLaunchTemplate.latestVersion.apply(v => v.toString());
682
+ const asgTags = pulumi
683
+ .all([eksCluster.name, args.autoScalingGroupTags])
684
+ .apply(([clusterName, tags]) => inputTagsToASGTags(clusterName, tags));
685
+ const launchTemplateVersion = nodeLaunchTemplate.latestVersion.apply((v) => v.toString());
638
686
  const asGroup = new aws.autoscaling.Group(name, {
639
687
  name: name,
640
688
  minSize: (_h = args === null || args === void 0 ? void 0 : args.minSize) !== null && _h !== void 0 ? _h : 1,
@@ -652,6 +700,7 @@ ${customUserData}
652
700
  },
653
701
  },
654
702
  tags: asgTags,
703
+ defaultInstanceWarmup: args.defaultInstanceWarmup,
655
704
  }, { parent, dependsOn: nodeGroupDeps, provider });
656
705
  return {
657
706
  nodeSecurityGroup: nodeSecurityGroup,
@@ -695,8 +744,8 @@ function computeWorkerSubnets(parent, subnetIds) {
695
744
  // Fetch the route table for this subnet.
696
745
  const routeTable = yield getRouteTableAsync(parent, subnetId);
697
746
  // Once we have the route table, check its list of routes for a route to an internet gateway.
698
- const hasInternetGatewayRoute = routeTable.routes
699
- .find(r => !!r.gatewayId && !isPrivateCIDRBlock(r.cidrBlock)) !== undefined;
747
+ const hasInternetGatewayRoute = routeTable.routes.find((r) => !!r.gatewayId && !isPrivateCIDRBlock(r.cidrBlock)) !==
748
+ undefined;
700
749
  if (hasInternetGatewayRoute) {
701
750
  publicSubnets.push(subnetId);
702
751
  }
@@ -723,10 +772,12 @@ function getRouteTableAsync(parent, subnetId) {
723
772
  const subnet = yield aws.ec2.getSubnet({ id: subnetId }, invokeOpts);
724
773
  const mainRouteTableInfo = yield aws.ec2.getRouteTables({
725
774
  vpcId: subnet.vpcId,
726
- filters: [{
775
+ filters: [
776
+ {
727
777
  name: "association.main",
728
778
  values: ["true"],
729
- }],
779
+ },
780
+ ],
730
781
  }, invokeOpts);
731
782
  return yield aws.ec2.getRouteTable({ routeTableId: mainRouteTableInfo.ids[0] }, invokeOpts);
732
783
  }
@@ -740,13 +791,13 @@ function isPrivateCIDRBlock(cidrBlock) {
740
791
  const privateA = new netmask.Netmask("10.0.0.0/8");
741
792
  const privateB = new netmask.Netmask("172.16.0.0/12");
742
793
  const privateC = new netmask.Netmask("192.168.0.0/16");
743
- return privateA.contains(cidrBlock) || privateB.contains(cidrBlock) || privateC.contains(cidrBlock);
794
+ return (privateA.contains(cidrBlock) || privateB.contains(cidrBlock) || privateC.contains(cidrBlock));
744
795
  }
745
796
  /**
746
797
  * Iterates through the tags map creating AWS ASG-style tags
747
798
  */
748
799
  function tagsToAsgTags(tagsInput) {
749
- return pulumi.output(tagsInput).apply(tags => {
800
+ return pulumi.output(tagsInput).apply((tags) => {
750
801
  let output = "";
751
802
  for (const tag of Object.keys(tags)) {
752
803
  output += `
@@ -796,8 +847,9 @@ class ManagedNodeGroupInternal extends pulumi.ComponentResource {
796
847
  return;
797
848
  }
798
849
  super(type, name, args, opts);
799
- const core = pulumi.output(args.cluster)
800
- .apply(c => c instanceof cluster_1.ClusterInternal ? c.core : c);
850
+ const core = pulumi
851
+ .output(args.cluster)
852
+ .apply((c) => (c instanceof cluster_1.ClusterInternal ? c.core : c));
801
853
  const group = createManagedNodeGroupInternal(name, args, core, this, opts === null || opts === void 0 ? void 0 : opts.provider);
802
854
  this.nodeGroup = pulumi.output(group);
803
855
  this.registerOutputs({
@@ -830,30 +882,24 @@ function createManagedNodeGroupInternal(name, args, core, parent, provider) {
830
882
  roleArn = args.nodeRoleArn;
831
883
  }
832
884
  else if (args.nodeRole) {
833
- roleArn = pulumi.output(args.nodeRole).apply(r => r.arn);
885
+ roleArn = pulumi.output(args.nodeRole).apply((r) => r.arn);
834
886
  }
835
887
  else {
836
888
  throw new Error("The managed node group role provided is undefined");
837
889
  }
838
890
  // Check that the nodegroup role has been set on the cluster to
839
891
  // ensure that the aws-auth configmap was properly formed.
840
- const nodegroupRole = pulumi.all([
841
- core.instanceRoles,
842
- roleArn,
843
- ]).apply(([roles, rArn]) => {
892
+ const nodegroupRole = pulumi.all([core.instanceRoles, roleArn]).apply(([roles, rArn]) => {
844
893
  // Map out the ARNs of all of the instanceRoles.
845
- const roleArns = roles.map(role => {
894
+ const roleArns = roles.map((role) => {
846
895
  return role.arn;
847
896
  });
848
897
  // Try finding the nodeRole in the ARNs array.
849
- return pulumi.all([
850
- roleArns,
851
- rArn,
852
- ]).apply(([arns, arn]) => {
853
- return arns.find(a => a === arn);
898
+ return pulumi.all([roleArns, rArn]).apply(([arns, arn]) => {
899
+ return arns.find((a) => a === arn);
854
900
  });
855
901
  });
856
- nodegroupRole.apply(role => {
902
+ nodegroupRole.apply((role) => {
857
903
  if (!role) {
858
904
  throw new Error(`A managed node group cannot be created without first setting its role in the cluster's instanceRoles`);
859
905
  }
@@ -864,7 +910,7 @@ function createManagedNodeGroupInternal(name, args, core, parent, provider) {
864
910
  subnetIds = pulumi.output(args.subnetIds);
865
911
  }
866
912
  else {
867
- subnetIds = core.apply(c => {
913
+ subnetIds = core.apply((c) => {
868
914
  if (c.subnetIds !== undefined) {
869
915
  return c.subnetIds;
870
916
  }
@@ -885,11 +931,9 @@ function createManagedNodeGroupInternal(name, args, core, parent, provider) {
885
931
  delete nodeGroupArgs.cluster;
886
932
  }
887
933
  // Make the aws-auth configmap a dependency of the node group.
888
- const ngDeps = core.apply(c => c.eksNodeAccess !== undefined ? [c.eksNodeAccess] : []);
934
+ const ngDeps = core.apply((c) => (c.eksNodeAccess !== undefined ? [c.eksNodeAccess] : []));
889
935
  // Create the managed node group.
890
- const nodeGroup = new aws.eks.NodeGroup(name, Object.assign(Object.assign({}, nodeGroupArgs), { clusterName: args.clusterName || core.cluster.name, nodeRoleArn: roleArn, scalingConfig: pulumi.all([
891
- args.scalingConfig,
892
- ]).apply(([config]) => {
936
+ const nodeGroup = new aws.eks.NodeGroup(name, Object.assign(Object.assign({}, nodeGroupArgs), { clusterName: args.clusterName || core.cluster.name, nodeRoleArn: roleArn, scalingConfig: pulumi.all([args.scalingConfig]).apply(([config]) => {
893
937
  var _a, _b, _c;
894
938
  const desiredSize = (_a = config === null || config === void 0 ? void 0 : config.desiredSize) !== null && _a !== void 0 ? _a : 2;
895
939
  const minSize = (_b = config === null || config === void 0 ? void 0 : config.minSize) !== null && _b !== void 0 ? _b : 1;