CompTIA Linux+ XK0-006 (V8) Practice Question

During an OpenTofu deployment you need to replace an existing web-server EC2 instance without interrupting service. The current configuration contains:

resource "aws_security_group" "web_sg" {
  # … rules omitted …
}

resource "aws_instance" "web" {
  ami                    = "ami-0c55b159cbfafe1f0"
  instance_type          = "t3.micro"
  vpc_security_group_ids = [aws_security_group.web_sg.id]

  lifecycle {
    create_before_destroy = true
  }
}

Later, the AMI ID is updated in version control. When the next tofu apply runs, which statement accurately describes what will happen to the aws_instance.web resource?

  • OpenTofu will prompt for user confirmation and then perform the default destroy-then-create sequence, effectively ignoring the lifecycle block.

  • OpenTofu will create a new EC2 instance first, and only after it is in service will it destroy the old one, minimizing downtime.

  • OpenTofu will destroy the existing EC2 instance before creating a new one because the create_before_destroy argument is ignored for EC2 resources.

  • The create_before_destroy setting is overridden by the dependency on the security group, so both resources are destroyed and recreated in order.

CompTIA Linux+ XK0-006 (V8)
Automation, Orchestration, and Scripting
Your Score:
Settings & Objectives
Random Mixed
Questions are selected randomly from all chosen topics, with a preference for those you haven’t seen before. You may see several questions from the same objective or domain in a row.
Rotate by Objective
Questions cycle through each objective or domain in turn, helping you avoid long streaks of questions from the same area. You may see some repeat questions, but the distribution will be more balanced across topics.

Check or uncheck an objective to set which questions you will receive.

Bash, the Crucial Exams Chat Bot
AI Bot