Hi, I have some ec2 instances running on productio...
# aws
c
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
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
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
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
alright, thank you!
s
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.