Would the code below cause a “pulumi up” to replac...
# aws
b
Would the code below cause a “pulumi up” to replace servers every time debian updates the AMI? If so is it easy to pin it after the fact since that is not the behavior I want.
Copy code
// Get latest Debian Buster AMI
const busterId = aws.getAmi({
    owners: ["136693071363"],
    mostRecent: true,
    filters: [{
        name: "name",
        values: ["debian-10-amd64-*"],
    }],
}, { async: true }).then(ami => ami.id);
b
yes, it would. Are you using a launchTemplate or directly on an ec2 instance?
b
Using it in a call to new aws.ec2.Instance
b
yeah you don't want
mostRecent
in that case, launchTemplates would help here because it would mean the new ec2 instance would have the latest but it wouldn't replace the existing instances
b
Thanks, any way to correct it without importing the instance? If I just change the ami to the full name of the one used will Pulumi stop recommending the upgrade?
g
Yea, if you change your
debian-10-amd64-*
filter to
debian-10-amd64-YYYMMDD
or whatever the exact name is that will pin it.
You could also add
{ ignoreChanges: ["ami"] }
to your instance to ignore any changes that might come through the AMI lookup - https://www.pulumi.com/docs/intro/concepts/programming-model/#ignorechanges.
And lastly, you could
{ protect: true }
to ensure that no changes (AMI or otherwise) would result in the instance being destroyed or replaced - https://www.pulumi.com/docs/intro/concepts/programming-model/#protect.
b
Awesome, thank you Cameron!