Use Direct Service Integrations

Eliminate unnecessary Lambda proxy functions by using direct API Gateway and Step Functions integrations to call AWS services without extra invocations.

Overview

Remove unnecessary Lambda proxy functions - API Gateway and Step Functions can integrate directly with AWS services.

API Gateway Direct Integration

Before (Lambda Proxy)

# Unnecessary Lambda
def lambda_handler(event, context):
    dynamodb = boto3.resource('dynamodb')
    table = dynamodb.Table('MyTable')
    
    item_id = event['pathParameters']['id']
    response = table.get_item(Key={'id': item_id})
    
    return {
        'statusCode': 200,
        'body': json.dumps(response['Item'])
    }

Cost: Lambda invocation + duration charges

After (Direct Integration)

API Gateway → DynamoDB (no Lambda):

{
  "type": "aws",
  "httpMethod": "POST",
  "uri": "arn:aws:apigateway:region:dynamodb:action/GetItem",
  "credentials": "arn:aws:iam::account:role/APIGatewayDynamoDBRole",
  "requestTemplates": {
    "application/json": "{\"TableName\": \"MyTable\", \"Key\": {\"id\": {\"S\": \"$input.params('id')\"}}}"
  }
}

Cost: $0 Lambda charges

Supported Services

API Gateway can integrate directly with:

  • DynamoDB
  • S3
  • SQS
  • SNS
  • Kinesis
  • EventBridge

Step Functions supports 200+ services natively.

Response Transformations

Use API Gateway mapping templates:

#set($inputRoot = $input.path('$'))
{
  "id": "$inputRoot.Item.id.S",
  "name": "$inputRoot.Item.name.S"
}

Savings

Scenario: 1M API calls to read from DynamoDB

With Lambda proxy:

  • Lambda: $2.50/month
  • API Gateway: $3.50/month
  • Total: $6.00/month

Direct integration:

  • API Gateway: $3.50/month
  • Savings: $2.50/month (42%)