Using space instead of '=' causes different errors
5. You want to replace two resources, aws_instance.web and aws_security_group.sg, in a single apply command. Which is the correct way to do this?
hard
A. terraform apply -replace=aws_instance.web,aws_security_group.sg
B. terraform apply -replace=aws_instance.web -replace=aws_security_group.sg
C. terraform apply -replace=aws_instance.web aws_security_group.sg
D. terraform apply -replace aws_instance.web -replace aws_security_group.sg
Solution
Step 1: Understand multiple -replace usage
Terraform allows multiple -replace flags, each specifying one resource to replace.
Step 2: Evaluate each option
terraform apply -replace=aws_instance.web -replace=aws_security_group.sg uses two separate -replace flags correctly. terraform apply -replace=aws_instance.web,aws_security_group.sg uses a comma which is invalid. Options C and D use incorrect syntax without '=' or with spaces.
Final Answer:
terraform apply -replace=aws_instance.web -replace=aws_security_group.sg -> Option B
Quick Check:
Use multiple -replace flags for multiple resources [OK]
Hint: Use one -replace= per resource to replace multiple [OK]