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

creamy-sugar-83202

01/30/2024, 12:01 PM
Hi, I have some ec2 instances running on production with ubuntu 18.04. Now that I check the resource statuses by
pulumi preview
, it’s unable to find the AMI underlying those ec2 with the error
invoke of aws:ec2/getAmi:getAmi failed: invocation of aws:ec2/getAmi:getAmi returned an error
. In fact, I could not find that AMI using AWS CLI, if I update to another AMI, pulumi shows that I need to replace those associated with the running instances, I’m skeptical to carry out the replacement because the instances are serving production. Any idea how to go on with it?
a

adorable-house-61348

01/30/2024, 12:05 PM
you can specify the ami in the ec2 resource instead of looking for it using
getAmi
- that should work
https://www.pulumi.com/registry/packages/aws/api-docs/ec2/instance/#ami_yaml hard-code the ami you need here - as long as you use the one you've used previously that shouldn't cause replacements
c

creamy-sugar-83202

01/30/2024, 12:15 PM
oh right that seems to work! what’s the best practice here? Now I have to fetch the ami id by myself and replace it to the
get_ami()
, seems a bit manual..
a

adorable-house-61348

01/30/2024, 12:16 PM
If you want a fixed AMI, then you should hard-code it. getAMI is useful if you want the AMI to stay up to date - note that that will cause a replacement.
c

creamy-sugar-83202

01/30/2024, 1:02 PM
alright, thank you!
s

salmon-account-74572

01/30/2024, 8:28 PM
You could also use an
ignoreChanges
on the AMI property for the instance, but in general I agree with Venelin---if you want a fixed AMI, then supply it as a manually-entered configuration value.