Complete the code to add an explicit dependency on the resource 'aws_vpc.main'.
resource "aws_subnet" "example" { vpc_id = aws_vpc.main.id cidr_block = "10.0.1.0/24" [1] = [aws_vpc.main] }
The depends_on argument explicitly declares a dependency on another resource, ensuring Terraform creates the dependent resource first.
Complete the code to explicitly depend on both 'aws_vpc.main' and 'aws_internet_gateway.gw'.
resource "aws_route_table" "rt" { vpc_id = aws_vpc.main.id [1] = [aws_vpc.main, aws_internet_gateway.gw] }
The depends_on argument can list multiple resources to ensure they are created before this resource.
Fix the error in the code by correctly specifying the explicit dependency on 'aws_security_group.sg'.
resource "aws_instance" "web" { ami = "ami-123456" instance_type = "t2.micro" [1] = [aws_security_group.sg] }
The correct meta-argument is depends_on. Other variants are invalid and cause errors.
Fill both blanks to explicitly depend on 'aws_lb.main' and 'aws_lb_target_group.main'.
resource "aws_lb_listener" "front_end" { load_balancer_arn = aws_lb.main.arn port = 80 protocol = "HTTP" [1] = [aws_lb.main, [2]] }
The depends_on argument is used to declare explicit dependencies. The list includes both resources.
Fill all three blanks to explicitly depend on 'aws_db_instance.main' and 'aws_security_group.db_sg'.
resource "aws_db_parameter_group" "db_pg" { name = "my-db-pg" family = "mysql5.7" description = "Custom parameter group" [1] = [[2], [3]] }
The depends_on argument lists resources to explicitly depend on. Here, it includes the DB instance and security group. The subnet is not included in this example.