Reputation: 1569
I have dissected the Terraform AWS Api Gateway Resources documentation and I don't find a clear documentation around how I can create and attach an API Key as a Token Barer autorization to an API Gateway POST method with terraform
My CURL command would look something like this:
curl --location --request POST 'https://foobar123.execute-api.us-east-1.amazonaws.com/test' \
--header 'Authorization: Bearer AAABBBsKen4vcVDQVkZyu7lpEWGcs1o64bz7TCb1' \
--header 'Content-Type: text/plain' \
--data-raw '{"foo": "bar"}'
How do I achieve this with terraform?
Upvotes: 2
Views: 1551
Reputation: 3130
It's an option on the gateway method (the last option):
resource "aws_api_gateway_method" "task_method" {
rest_api_id = aws_api_gateway_rest_api.api.id
resource_id = aws_api_gateway_resource.api_task.id
http_method = "POST"
authorization = "NONE"
api_key_required = true
}
The documentation isn't very explicit, but this example does work.
Upvotes: 1