How do I use 'ignore_changes' in cloud configurations?
In your cloud configurations, there might be certain attributes or properties of resources that you would prefer to manage manually or that change frequently but don’t need to trigger updates. The ignore_changes
argument allows you to specify which resource parameters Pulumi should ignore when updates are made.
Here’s an example of how to use ignore_changes
:
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.ec2.Instance("example", {
ami: "ami-12345678",
instanceType: aws.ec2.InstanceType.T2_Micro,
tags: {
Name: "example-instance",
},
});
export const instanceId = example.id;
export const instancePublicIp = example.publicIp;
In this example:
- We define an AWS provider with a specific region.
- We create an
aws_instance
resource with an AMI ID and instance type. - We add a
tags
block to the instance, which includes aName
tag. - The
lifecycle
block includes anignore_changes
argument, specifying that any changes totags
should be ignored.
The ignore_changes
argument helps in scenarios where certain resource aspects are managed outside of Pulumi, allowing you to avoid unnecessary updates or disruptions.
With this setup, even if the tags
of the EC2 instance are modified manually in the AWS console, they won’t trigger any updates from Pulumi when you run your program.
Concluding Summary:
In this example, we learned how to use the ignore_changes
argument in Pulumi to manage certain resource parameters that you don’t want to trigger updates, such as tags on an AWS instance. We also included stack exports to expose the instance ID and public IP.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.