Complete the code to ignore changes to the 'tags' attribute in the resource lifecycle.
resource "aws_instance" "example" { ami = "ami-123456" instance_type = "t2.micro" lifecycle { ignore_changes = [[1]] } }
The ignore_changes lifecycle rule is used to tell Terraform to ignore changes to specific attributes. Here, we want to ignore changes to the tags attribute.
Complete the code to ignore changes to both 'user_data' and 'tags' attributes in the lifecycle block.
resource "aws_instance" "example" { ami = "ami-123456" instance_type = "t2.micro" user_data = "#!/bin/bash" lifecycle { ignore_changes = [[1]] } }
To ignore changes to multiple attributes, list them inside square brackets as strings. Here, both user_data and tags are ignored.
Fix the error in the lifecycle block to properly ignore changes to the 'security_groups' attribute.
resource "aws_instance" "example" { ami = "ami-123456" instance_type = "t2.micro" security_groups = ["sg-12345"] lifecycle { ignore_changes = [1] } }
The ignore_changes attribute expects a list of attribute names as strings. So, it should be a list with the attribute name in quotes.
Fill both blanks to ignore changes to 'tags' and 'user_data' attributes in the lifecycle block.
resource "aws_instance" "example" { ami = "ami-123456" instance_type = "t2.micro" user_data = "#!/bin/bash" lifecycle { ignore_changes = [[1], [2]] } }
To ignore multiple attributes, list each attribute name as a string inside the list. Here, 'tags' and 'user_data' are ignored.
Fill all three blanks to ignore changes to 'tags', 'user_data', and 'security_groups' attributes in the lifecycle block.
resource "aws_instance" "example" { ami = "ami-123456" instance_type = "t2.micro" user_data = "#!/bin/bash" security_groups = ["sg-12345"] lifecycle { ignore_changes = [[1], [2], [3]] } }
List all attribute names as strings inside the ignore_changes list to ignore their changes. Here, 'tags', 'user_data', and 'security_groups' are ignored.