Bird
0
0

What will Terraform do when you execute terraform apply with this code?

medium📝 Predict Output Q5 of 15
AWS - CloudFormation
What will Terraform do when you execute terraform apply with this code?
resource "aws_instance" "web" {
  ami           = "ami-0abcdef1234567890"
  instance_type = "t2.micro"
}
ATerraform will only plan the changes but not create any resources.
BTerraform will create an EC2 instance with the specified AMI and instance type.
CTerraform will throw an error because the resource name is invalid.
DTerraform will create a security group instead of an EC2 instance.
Step-by-Step Solution
Solution:
  1. Step 1: Identify the resource type

    The resource type is aws_instance, which corresponds to an EC2 instance in AWS.
  2. Step 2: Check the resource properties

    The AMI and instance type are specified correctly, so Terraform has all necessary info to create the instance.
  3. Final Answer:

    Terraform will create an EC2 instance with the specified AMI and instance type. -> Option B
  4. Quick Check:

    Resource type and properties valid [OK]
Quick Trick: Resource type defines what is created [OK]
Common Mistakes:
  • Confusing resource name with resource type
  • Assuming terraform apply only plans changes
  • Expecting errors without syntax issues

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes