Create terraform module for API GW that push REST post to dynamoDB directly
- User
Create terraform module for API GW that push REST post to dynamoDB directly
Assistant
Sure! Here's an example Terraform module that creates an API Gateway REST API that pushes POST requests directly to DynamoDB:
module.tf
# Configure the AWS Provider provider "aws" { region = "your-region" } # Create an API Gateway REST API resource "aws_api_gateway_rest_api" "example" { name = "example-api" description = "An example API" # Set up a POST method method = "POST" # Define the integration type as "AWS_PROXY" integration { type = "AWS_PROXY" uri = "https://your-dynamodb-table.your-region.amazonaws.com" credentials = aws_iam_role.example.arn payload = jsonencode({ "request" : $input.json("$") }) } } # Create an IAM Role for the API Gateway resource "aws_iam_role" "example" { name = "example-role" assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [ { Action = "sts:AssumeRole" Effect = "Allow" Principal = { Service = "apigateway.amazonaws.com" } } ] }) } # Create a DynamoDB table resource "aws_dynamodb_table" "example" { name = "example-table" attribute { name = "id" type = "S" } attribute { name = "name" type = "S" } key_schema = [ { attribute_name = "id" key_type = "HASH" } ] provisioned_throughput { read_capacity_units = 5 write_capacity_units = 5 } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.