Bird
0
0

Which of the following is the correct JSON snippet to define a host rule in a GCP URL map?

easy📝 Syntax Q3 of 15
GCP - Cloud Load Balancing
Which of the following is the correct JSON snippet to define a host rule in a GCP URL map?
A{"pathMatchers": [{"hosts": ["example.com"], "pathMatcher": "pm1"}]}
B{"hostRules": [{"paths": ["/home"], "backendService": "bs1"}]}
C{"hostRules": [{"hosts": ["example.com"], "pathMatcher": "pm1"}]}
D{"backendServices": [{"hosts": ["example.com"], "pathMatcher": "pm1"}]}
Step-by-Step Solution
Solution:
  1. Step 1: Understand host rule structure

    Host rules map hosts to path matchers. The correct key is 'hostRules' with 'hosts' and 'pathMatcher' fields.
  2. Step 2: Check JSON keys and values

    {"hostRules": [{"hosts": ["example.com"], "pathMatcher": "pm1"}]} correctly uses 'hostRules' with 'hosts' array and 'pathMatcher' string. Others misuse keys or fields.
  3. Final Answer:

    Correct host rule JSON snippet -> Option C
  4. Quick Check:

    Host rule syntax = {"hostRules": [{"hosts": ["example.com"], "pathMatcher": "pm1"}]} [OK]
Quick Trick: Host rules use 'hosts' and 'pathMatcher' keys [OK]
Common Mistakes:
  • Using 'paths' instead of 'hosts'
  • Confusing 'backendService' with host rule
  • Misnaming keys like 'pathMatchers'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes