AWS Certified Developer Associate · Free Practice Question Medium

Question 53

A developer is configuring the redirect actions for an Application Load Balancer. The developer stumbled upon the following snippet of code.

Which of the following is an example of a query string condition that the developer can use on AWS CLI?

  • A
    [
      {
          "Field": "query-string",
          "PathPatternConfig": {
              "Values": ["/img/*"]
          }
      }
    ]
    
  • B
    [
      {
          "Field": "query-string",
          "QueryStringConfig": {
              "Values": [
                {
                    "Key": "version",
                    "Value": "v1"
                },
                {
                    "Value": "*example*"
                }
              ]
          }
      }
    ]
    
    
  • C
    [
      {
          "Field": "query-string",
          "StringHeaderConfig": {
              "Values": ["*.example.com"]
          }
      }
    ]
    
  • D
    [
      {
          "Type": "redirect",
          "RedirectConfig": {
              "Protocol": "HTTPS",
              "Port": "443",
              "Host": "#{host}",
              "Path": "/#{path}",
              "Query": "#{query}",
              "StatusCode": "HTTP_301"
          }
      }
    ]
    
    
Reveal correct answer

Correct answer: B

Explanation

Correct option:

**

[
  {
      "Field": "query-string",
      "QueryStringConfig": {
          "Values": [
            {
                "Key": "version",
                "Value": "v1"
            },
            {
                "Value": "*example*"
            }
          ]
      }
  }
]

**

You can use query string conditions to configure rules that route requests based on key/value pairs or values in the query string. The match evaluation is not case-sensitive. The following wildcard characters are supported: * (matches 0 or more characters) and ? (matches exactly 1 character). You can specify conditions when you create or modify a rule.

Query parameters are often used along with the path component of the URL for applying a special logic to the resource being fetched.

The query string component starts after the first "?" in a URI. Typically query strings contain key-value pairs separated by a delimiter "&". Example: http://example.com/path/to/page?version=A&gender=female

The example condition given in the question is satisfied by requests with a query string that includes either a key/value pair of "version=v1" or any key set to "example".

Incorrect options:

**

[
  {
      "Field": "query-string",
      "PathPatternConfig": {
          "Values": ["/img/*"]
      }
  }
]

**

**

[
  {
      "Field": "query-string",
      "StringHeaderConfig": {
          "Values": ["*.example.com"]
      }
  }
]

**

These two options are malformed and are incorrect.

**

[
  {
      "Type": "redirect",
      "RedirectConfig": {
          "Protocol": "HTTPS",
          "Port": "443",
          "Host": "#{host}",
          "Path": "/#{path}",
          "Query": "#{query}",
          "StatusCode": "HTTP_301"
      }
  }
]

** - This action redirects an HTTP request to an HTTPS request on port 443, with the same hostname, path, and query string as the HTTP request.

Reference:

https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#query-string-conditions

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need