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

gorgeous-keyboard-22299

02/19/2024, 5:01 AM
The AWS AMI I am runnig for the past 1/2 year isn't found via aws.ec2.Instance(...) during a pulumi preview. I know the ami string is absolutely valid, but is no longer present on the AWS marketplace. error: Error: invocation of awsec2/getAmigetAmi returned an error: invoking awsec2/getAmigetAmi: 1 error occurred: * Your query returned no results. Please change your search criteria and try again. Do I just try/catch this error so that
pulumi preview
succeeds? This seems very hacky
l

little-cartoon-10569

02/19/2024, 5:17 AM
If the AMI no longer exists, then do you really want to try/catch the error? Don't you want to update the AMI to something that does exist?
g

gorgeous-keyboard-22299

02/20/2024, 4:57 AM
@little-cartoon-10569 - updating the AMI would completely destroy my staging or production EC2s, so definitely NOT! The better solution can be found @ https://app.slack.com/client/T85C88L30/CRH5ENVDX Thanks for your response. -- L
l

little-cartoon-10569

02/20/2024, 7:38 PM
That link doesn't work for me.
s

salmon-account-74572

02/20/2024, 8:15 PM
You could do an
ignoreChanges
on the AMI property of the EC2 instance: https://www.pulumi.com/docs/concepts/options/ignorechanges/ This would let you get past the missing AMI error (for now), but it’s still something you’ll need to address at some point.
l

little-cartoon-10569

02/20/2024, 8:28 PM
And you could avoid getAmi, and just hard-code the AMI id.
s

salmon-account-74572

02/20/2024, 9:22 PM
Or provide the AMI ID as a configuration value to the stack. 🙂