0
0
AWScloud~10 mins

Listener rules and routing in AWS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the protocol for the listener.

AWS
listener = elbv2.Listener(self, "Listener",
    load_balancer=alb,
    port=80,
    protocol=[1],
    default_target_groups=[target_group])
Drag options to blanks, or click blank then click option'
AHTTPS
BTCP
CHTTP
DUDP
Attempts:
3 left
💡 Hint
Common Mistakes
Using HTTPS on port 80 causes connection errors.
Using TCP or UDP protocols for HTTP listeners.
2fill in blank
medium

Complete the code to add a listener rule that forwards requests with path '/images/*' to the image target group.

AWS
listener.add_action("ImageRule",
    priority=10,
    conditions=[elbv2.ListenerCondition.path_patterns([[1]])],
    action=elbv2.ListenerAction.forward([image_target_group]))
Drag options to blanks, or click blank then click option'
A"/images/*"
B"/docs/*"
C"/videos/*"
D"/api/*"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong path pattern like '/videos/*' for images.
Forgetting the wildcard '*' to match all subpaths.
3fill in blank
hard

Fix the error in the listener rule condition to correctly match host header 'example.com'.

AWS
listener.add_action("HostRule",
    priority=5,
    conditions=[elbv2.ListenerCondition.host_headers([[1]])],
    action=elbv2.ListenerAction.forward([host_target_group]))
Drag options to blanks, or click blank then click option'
A"example"
B"example.com"
C"*.example.com"
Dexample.com
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the host string.
Using incomplete or incorrect host patterns.
4fill in blank
hard

Fill both blanks to create a listener rule that forwards requests with method POST and path '/submit' to the submit target group.

AWS
listener.add_action("SubmitRule",
    priority=15,
    conditions=[elbv2.ListenerCondition.http_request_methods([[1]]), elbv2.ListenerCondition.path_patterns([[2]])],
    action=elbv2.ListenerAction.forward([submit_target_group]))
Drag options to blanks, or click blank then click option'
A"POST"
B"GET"
C"/submit"
D"/home"
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of POST for form submissions.
Incorrect path pattern like '/home' instead of '/submit'.
5fill in blank
hard

Fill all three blanks to define a listener rule that forwards requests with host 'api.example.com', path '/v1/*', and method GET to the api target group.

AWS
listener.add_action("ApiRule",
    priority=20,
    conditions=[elbv2.ListenerCondition.host_headers([[1]]), elbv2.ListenerCondition.path_patterns([[2]]), elbv2.ListenerCondition.http_request_methods([[3]])],
    action=elbv2.ListenerAction.forward([api_target_group]))
Drag options to blanks, or click blank then click option'
A"api.example.com"
B"/v1/*"
C"GET"
D"POST"
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up HTTP methods or using wrong host names.
Forgetting to include wildcards in path patterns.