Bird
0
0

You want to configure CORS on an S3 bucket to allow any origin to send GET requests but restrict POST requests to only https://admin.example.com. How should you write the CORS rules?

hard📝 Application Q9 of 15
AWS - API Gateway
You want to configure CORS on an S3 bucket to allow any origin to send GET requests but restrict POST requests to only https://admin.example.com. How should you write the CORS rules?
A[{"AllowedOrigins": ["https://admin.example.com"], "AllowedMethods": ["GET", "POST"]}]
B[{"AllowedOrigins": ["*"], "AllowedMethods": ["GET"]}, {"AllowedOrigins": ["https://admin.example.com"], "AllowedMethods": ["POST"]}]
C[{"AllowedOrigins": ["*"], "AllowedMethods": ["GET", "POST"]}]
D[{"AllowedOrigins": ["*"], "AllowedMethods": ["POST"]}, {"AllowedOrigins": ["https://admin.example.com"], "AllowedMethods": ["GET"]}]
Step-by-Step Solution
Solution:
  1. Step 1: Separate rules for GET and POST

    GET requests allowed from any origin, so one rule with AllowedOrigins '*' and AllowedMethods GET.
  2. Step 2: Restrict POST to admin domain

    Second rule allows POST only from https://admin.example.com.
  3. Final Answer:

    Two rules: one for GET from '*', one for POST from admin domain -> Option B
  4. Quick Check:

    Multiple CORSRules for different origins and methods [OK]
Quick Trick: Use multiple CORSRules to handle different origins and methods [OK]
Common Mistakes:
  • Combining all methods under '*' origin
  • Restricting GET to admin domain incorrectly
  • Using wrong JSON array structure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes