Bird
Raised Fist0
AWScloud~10 mins

Resources and methods in AWS - Interactive Code Practice

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

Complete the code to create an AWS S3 bucket resource.

AWS
resource "aws_s3_bucket" "my_bucket" {
  bucket = [1]
}
Drag options to blanks, or click blank then click option'
A"bucket_name"
Bmy_bucket
C"my-unique-bucket-name"
Dbucket
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the bucket name.
Using an invalid bucket name.
2fill in blank
medium

Complete the code to define an HTTP GET method for an API Gateway resource.

AWS
resource "aws_api_gateway_method" "get_method" {
  rest_api_id   = aws_api_gateway_rest_api.my_api.id
  resource_id   = aws_api_gateway_resource.my_resource.id
  http_method   = [1]
  authorization = "NONE"
}
Drag options to blanks, or click blank then click option'
A"GET"
B"PUT"
C"DELETE"
D"POST"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong HTTP method string.
Not using quotes around the HTTP method.
3fill in blank
hard

Fix the error in the API Gateway integration resource by completing the integration HTTP method.

AWS
resource "aws_api_gateway_integration" "integration" {
  rest_api_id             = aws_api_gateway_rest_api.my_api.id
  resource_id             = aws_api_gateway_resource.my_resource.id
  http_method             = aws_api_gateway_method.get_method.http_method
  integration_http_method = [1]
  type                    = "AWS_PROXY"
  uri                     = aws_lambda_function.my_lambda.invoke_arn
}
Drag options to blanks, or click blank then click option'
A"DELETE"
B"POST"
C"PUT"
D"GET"
Attempts:
3 left
💡 Hint
Common Mistakes
Setting integration_http_method to GET instead of POST.
Not using quotes around the method.
4fill in blank
hard

Fill both blanks to define an API Gateway resource path and its parent resource ID.

AWS
resource "aws_api_gateway_resource" "my_resource" {
  rest_api_id = aws_api_gateway_rest_api.my_api.id
  parent_id   = [1]
  path_part   = [2]
}
Drag options to blanks, or click blank then click option'
Aaws_api_gateway_rest_api.my_api.root_resource_id
Baws_api_gateway_rest_api.my_api.id
C"items"
D"/items"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the API ID as parent_id.
Including a slash in path_part.
5fill in blank
hard

Fill all three blanks to define an API Gateway deployment with stage name and description.

AWS
resource "aws_api_gateway_deployment" "deployment" {
  rest_api_id = aws_api_gateway_rest_api.my_api.id
  stage_name  = [1]
  description = [2]
  triggers    = {
    redeploy = [3]
  }
}
Drag options to blanks, or click blank then click option'
A"prod"
B"Production stage deployment"
Ctimestamp()
D"dev"
Attempts:
3 left
💡 Hint
Common Mistakes
Using an invalid stage name.
Not using a string for description.
Not using timestamp() for redeploy trigger.

Practice

(1/5)
1. What does a resource represent in AWS API Gateway?
easy
A. A URL path that clients can access
B. A backend database connection
C. A security policy for API access
D. A method to deploy the API

Solution

  1. Step 1: Understand the role of resources in API Gateway

    Resources define the URL paths that clients use to reach your API endpoints.
  2. Step 2: Differentiate resources from other components

    Resources are not backend connections, security policies, or deployment methods; they are URL paths.
  3. Final Answer:

    A URL path that clients can access -> Option A
  4. Quick Check:

    Resource = URL path [OK]
Hint: Resources are the API's URL paths clients call [OK]
Common Mistakes:
  • Confusing resources with backend services
  • Thinking resources are security settings
  • Mixing resources with deployment steps
2. Which HTTP method is correctly defined in AWS API Gateway to retrieve data?
easy
A. GET
B. POST
C. DELETE
D. PUT

Solution

  1. Step 1: Identify the HTTP method for data retrieval

    GET is the standard HTTP method used to retrieve or read data from a resource.
  2. Step 2: Confirm other methods' purposes

    POST creates data, DELETE removes data, and PUT updates data, so they are not for retrieval.
  3. Final Answer:

    GET -> Option A
  4. Quick Check:

    GET = retrieve data [OK]
Hint: GET method is for reading data from resources [OK]
Common Mistakes:
  • Using POST instead of GET to fetch data
  • Confusing DELETE with data retrieval
  • Mixing PUT with GET for reading data
3. Given this API Gateway setup: a resource /items with a POST method integrated to a Lambda function. What happens when a client sends a POST request to /items?
medium
A. The API Gateway returns a static mock response
B. The API Gateway returns a 404 Not Found error
C. The Lambda function is triggered to process the request
D. The request is ignored because POST is not allowed

Solution

  1. Step 1: Understand the integration of POST method with Lambda

    The POST method on the /items resource is connected to a Lambda function, so requests trigger that function.
  2. Step 2: Analyze the client request effect

    When a client sends a POST request to /items, API Gateway forwards it to Lambda for processing.
  3. Final Answer:

    The Lambda function is triggered to process the request -> Option C
  4. Quick Check:

    POST + Lambda integration = Lambda triggered [OK]
Hint: POST method triggers Lambda if integrated [OK]
Common Mistakes:
  • Assuming POST is not allowed without checking method setup
  • Thinking API Gateway returns 404 if resource exists
  • Confusing mock responses with Lambda integration
4. You created a resource /users and added a GET method, but clients get a 403 Forbidden error when calling it. What is the most likely cause?
medium
A. The client is using POST instead of GET
B. The resource path is misspelled
C. The API Gateway is not deployed
D. The method does not have an integration configured

Solution

  1. Step 1: Check method integration setup

    A 403 Forbidden often means the method exists but lacks proper integration or permissions.
  2. Step 2: Rule out other causes

    If the resource path was misspelled, the error would be 404. If API Gateway was not deployed, the error would differ. Using POST instead of GET would cause a 405 Method Not Allowed.
  3. Final Answer:

    The method does not have an integration configured -> Option D
  4. Quick Check:

    403 Forbidden = missing integration or permissions [OK]
Hint: 403 often means method lacks integration or permissions [OK]
Common Mistakes:
  • Confusing 403 with 404 or 405 errors
  • Ignoring deployment status
  • Assuming client method is always correct
5. You want to create an API with a resource /orders that supports both GET and POST methods. The GET method returns a mock response, and the POST method triggers a Lambda function. Which configuration correctly sets this up?
hard
A. Create /orders resource; add GET and POST methods both with MOCK integration
B. Create /orders resource; add GET method with MOCK integration; add POST method with Lambda integration
C. Create /orders resource; add GET method with Lambda integration; add POST method with MOCK integration
D. Create /orders resource; add GET and POST methods both with Lambda integration

Solution

  1. Step 1: Match method to integration type

    The GET method should use MOCK integration to return a static response without backend calls.
  2. Step 2: Configure POST method to trigger Lambda

    The POST method must be integrated with Lambda to process incoming data.
  3. Step 3: Verify the correct combination

    Create /orders resource; add GET method with MOCK integration; add POST method with Lambda integration correctly assigns MOCK to GET and Lambda to POST on the /orders resource.
  4. Final Answer:

    Create /orders resource; add GET method with MOCK integration; add POST method with Lambda integration -> Option B
  5. Quick Check:

    GET=MOCK, POST=Lambda [OK]
Hint: GET with MOCK, POST with Lambda for mixed behavior [OK]
Common Mistakes:
  • Swapping MOCK and Lambda integrations between methods
  • Using same integration for both methods incorrectly
  • Forgetting to create the resource before methods
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard