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

bitter-zebra-93800

06/14/2020, 10:29 PM
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

billowy-army-68599

06/14/2020, 10:57 PM
yes, it would. Are you using a launchTemplate or directly on an ec2 instance?
b

bitter-zebra-93800

06/14/2020, 10:58 PM
Using it in a call to new aws.ec2.Instance
b

billowy-army-68599

06/14/2020, 11:01 PM
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

bitter-zebra-93800

06/14/2020, 11:10 PM
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

gentle-diamond-70147

06/15/2020, 3:57 PM
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

bitter-zebra-93800

06/15/2020, 5:50 PM
Awesome, thank you Cameron!
4 Views