1. Answers
  2. Using 'ignore_changes' in Cloud Configurations

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:

  1. We define an AWS provider with a specific region.
  2. We create an aws_instance resource with an AMI ID and instance type.
  3. We add a tags block to the instance, which includes a Name tag.
  4. The lifecycle block includes an ignore_changes argument, specifying that any changes to tags 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 up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up