so, it appears that there is some type of issue wi...
# aws
s
so, it appears that there is some type of issue with
aws.ec2.SpotInstanceRequest
where as if you utilize a launchTemplate, it is failing to actually bring in the launchTemplate and execute it. Instead, I end up getting errors. However, from the console I can actually create the SpotInstance from the template without issue. Anyone else face something similar? Will likely be opening up an issue on github but wanted to check here first before I do that. Example:
Copy code
const launchTemplate = new aws.ec2.LaunchTemplate("spot-launch-template", {
  namePrefix: "xxxxxxx-",
  ebsOptimized: "true",
  monitoring: {
    enabled: true,
  },
  networkInterfaces: [{
    networkInterfaceId: eni.id,
    deviceIndex: 0,
    networkCardIndex: 0,
  }],
  maintenanceOptions: {
    autoRecovery: "default",
  },
  tagSpecifications: [{
    resourceType: "instance",
    tags: {
      Name: "xxxxxx-instance",
    },
  }],
  imageId,
  userData: userData.apply(ud => Buffer.from(ud).toString("base64")),
  instanceType: "t4g.nano",
  updateDefaultVersion: true,
}, { dependsOn: [eipAssociation] });

const spotInstance = new aws.ec2.SpotInstanceRequest("spot-instance", {
  launchTemplate: {
    id: launchTemplate.id.apply(id => id),
    version: "$Latest",
  },
  spotType: "persistent",
}, { dependsOn: [launchTemplate] });
Results in:
Copy code
error:   sdk-v2/provider2.go:472: sdk.helper_schema: requesting EC2 Spot Instance: operation error EC2: RequestSpotInstances, https response error StatusCode: 400, RequestID: xxxxxxxxxx, api error MissingParameter: The request must contain the parameter instanceType: provider=aws@6.52.0
Ok, so maybe
instanceType
could be required, so after adding that:
Copy code
error:   sdk-v2/provider2.go:472: sdk.helper_schema: requesting EC2 Spot Instance: operation error EC2: RequestSpotInstances, https response error StatusCode: 400, RequestID: xxxxxxxxx, api error MissingParameter: The request must contain the parameter imageId: provider=aws@6.52.0
Alright, so if anyone hits this in the future... The solve for this is to use
new aws.ec2.Instance
instead of the specific
SpotInstanceRequest
which you can use the
Instance
to still request the
spot
instance.