https://pulumi.com logo
#aws
Title
# aws
b

best-receptionist-98400

05/22/2020, 1:19 PM
Hoping to get some guidance on this issue we're running in to on the best way to solve it end to end. We're trying to use Spot Instances for a dev environments. It seems like SpotFleetRequests (With LaunchConfigurations) get us most of the way there, but lack some additional properties only exposed by SpotInstanceRequests and vice versa. Here's a list of different values so far: • NetworkInterfaces - Only on SpotInstanceRequest • PrivateIp - Only on SpotInstanceRequest • LoanBalancers - Only on SpotFleetRequest.LaunchConfig • Tags - Only on SpotFleetRequest.LaunchConfig. I know you can set tags on the SpotInstanceRequest but those apply only to the request, not the resulting Ec2 Instance but appears to be a limitation of AWS for some reason. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html I am curious why you can't set these on either the SpotFleetRequest.LaunchConfigurations or the SpotInstanceRequest (minus Tags, that one seems like an AWS limitation). I'm just looking on guidance for the best way to get an spot EC2 instance created with all of those values set. Do I have to do something like: • Use SpotInstanceRequest to be able to set the NetworkInterfaceId, and PrivateIP • Another step that
dependsOn
the step above to
waitForFulfillment
that imports the resulting Ec2 instance in to the stack so I can modify it • Update the Ec2 Instance I just imported to add the necessary tags • another step that
dependsOn
the tags being added that then goes to attach this instance to the load balancer? Or alternatively: • Use the SpotFleetRequest to be able to set the Tags and Load Balancer • Another step that
dependsOn
the step above to
waitForFulfillment
that imports the resulting Ec2 instance in to the stack so I can modify it • Update the Ec2 Instance I just imported to have a different NetworkInterfaceId and specific PrivateIP I'm just wondering if I'm missing anything here, or if that is the way I would need to go about this. Thanks.
w

white-balloon-205

05/22/2020, 9:43 PM
Tags - Only on SpotFleetRequest.LaunchConfig. I know you can set tags on the SpotInstanceRequest but those apply only to the request, not the resulting Ec2 Instance but appears to be a limitation of AWS for some reason.
Yeah - this appears to be an (unfortunate) AWS limitation.
LoanBalancers, NetworkInterfaces, PrivateIP
I think these differences are really about single instance vs. multiple instances. Which scenario are you trying to accomplish? I think your high-order-bit would likely to be to align to which of those matches what you want.
imports the resulting Ec2 instance in to the stack so I can modify it
That could work. Alternatively, if tagging is the thing you want to update, you could just wait for availability and then call
create-tags
yourself using the AWS SDK. Along the lines of https://gist.github.com/lukehoban/fd0355ed5b82386bd89c0ffe2a3c916a#file-waitforjob-ts-L20.
b

best-receptionist-98400

05/26/2020, 2:18 PM
@white-balloon-205 Thanks for reply!! I think you're idea of using the AWS SDK is pretty interesting. So I could use that from within the
MyStack
class after it's done running? Do you know of any C# examples that show something like that? I was looking around on how to invoke the
isDryRun
in C# but couldn't find anything.
@white-balloon-205 I was able to figure out how to get access to
IsDryRun
, but I'm still having trouble with the "waiting" part. I haven't been able to get the SpotInstanceId from the SpotInstanceRequest yet.