Complete the code to prevent Terraform from deleting the resource.
resource "aws_s3_bucket" "example" { bucket = "my-bucket" lifecycle { prevent_destroy = [1] } }
Setting prevent_destroy = true tells Terraform to block deletion of the resource.
Complete the code to ignore changes to the 'tags' attribute.
resource "aws_instance" "web" { ami = "ami-123456" instance_type = "t2.micro" lifecycle { ignore_changes = [[1]] } }
Ignoring changes to tags means Terraform won't update the resource if tags change outside Terraform.
Fix the error in the lifecycle block to properly ignore changes to multiple attributes.
resource "aws_db_instance" "db" { allocated_storage = 20 engine = "mysql" lifecycle { ignore_changes = [1] } }
The ignore_changes attribute expects a list of strings. Option C correctly provides a list of attribute names as strings.
Fill both blanks to create a lifecycle rule that ignores changes to 'tags' and prevents resource replacement.
resource "aws_lambda_function" "func" { function_name = "my-function" runtime = "python3.8" lifecycle { ignore_changes = [[1]] [2] = true } }
Ignoring changes to tags avoids updates on tag changes. Setting prevent_destroy = true blocks resource deletion.
Fill all three blanks to create a lifecycle block that ignores changes to 'environment', prevents destroy, and enables create before destroy.
resource "aws_ecs_service" "service" { name = "my-service" desired_count = 2 lifecycle { ignore_changes = [[1]] [2] = true [3] = true } }
This lifecycle block ignores changes to the environment attribute, prevents resource deletion, and ensures the new resource is created before the old one is destroyed.