Hi All :wave: , I'm working on a problem where I a...
# typescript
r
Hi All 👋 , I'm working on a problem where I am trying to conditionally control the AMI ID that is used to create an EC2 instance in my Pulumi program (typescript). If the stack already contains an EC2 instance with a name, then I want to just use the AMI ID that is already used by that instance, but if this program is running for the fist time I want to lookup and use the latest AMI ID from AWS. I've been googling around and experimenting with StackReference, but I can't seem to figure out how this should work. Ultimately this approach is in order to prevent the EC2 instance from being recreated because a new AMI is available other than the one that was originally used. Are there concepts/approaches I should know more about to make this work? Thanks
l
I would look up the AMI ID by hand and put it in your config. It can of course be solved in code, but this lookup-once-deploy-many-times problem is easiest solved by hand.
Also, this way, you can decide (in the form of raising a PR and doing a code review) when you want to update the machine to the latest image.
c
In Terraform it is easily solved with:
Copy code
lifecycle {
    ignore_changes = [ ami ]
  }
I suppose, Pulumi does not have an equivalent? 🤔
r
I would look up the AMI ID by hand and put it in your config
This is what I ended up doing ultimately, but I'm still kind of interested how I could have accomplished what I was trying to do orginally
I suppose, Pulumi does not have an equivalent?
Yeah, unless I missed it from what I could tell there were flags/behaviors I could set to cause when a resource would be force deleted but not when a specific property change should be ignored.
b
@cuddly-magician-97620 it does have the equivalent
c
Great, then that's probably the right solution. 🙂
r
@billowy-army-68599 Do you have a reference on how that works?
r
Excellent, thanks!