If one were to follow the example code to provisio...
# general
c
If one were to follow the example code to provision an ec2 instance here: https://www.pulumi.com/docs/clouds/aws/aws-guides/ec2/. Where it uses the following code to get and AMI id and then uses that id to create the ec2 instance:
Copy code
// Find the latest Amazon Linux 2 AMI.
const ami = pulumi.output(aws.ec2.getAmi({
    owners: [ "amazon" ],
    mostRecent: true,
    filters: [
        { name: "description", values: [ "Amazon Linux 2 *" ] },
    ],
}));
Would that instance be be destroyed and recreated every time
pulumi up
was run after a new AMI with a description matching
Amazon Linux 2 *
is released?
d
Based on the docs, yes. https://www.pulumi.com/registry/packages/aws/api-docs/ec2/instance/#ami_nodejs Note the symbol next to "ami", which signifies recreate on change
c
Is there any way to get that AMI id to be "sticky". Like the first time the code it run, it gets the latest and greatest AMI, but on subsequent runs, if the ec2 instance is already running, it leaves it alone?
d
I think you want a Launch Template, however it's been many years since I've worked with ec2 instances
c
If the search criteria for the AMI changed, I'd want the ec2 instance to get updated. But as long as the AMI currently being used by the instance matches the filters that found the AMI, it would be nice if there would be some way to keep it.
s
You might be able to use
ignoreChanges
on the AMI property of the EC2 instance (just an idea, I haven’t tested it).