I have a lambda deployed to AWS, integration is lambda-proxy, now I have an API Gateway which gives me an endpoint for calling the lambda. I need to get this endpoint URL in a terraform configuration, how can I do this?
Data sources don't expose any URL
data "aws_lambda_function" "myfunction" {
function_name = "my-function-name"
}
data "aws_api_gateway_rest_api" "my_rest_api" {
name = "my-rest-api"
}
api_gateway_deployment does expose an invoke_url, but infortunately it can't be imported, otherwise I could have declared the resources and then use terraform import ...
resource "aws_api_gateway_rest_api" "my_rest_api" {
name = "my-rest-api"
tags = {
STAGE = "prod"
}
}
resource "aws_api_gateway_deployment" "my_rest_api" {
rest_api_id = aws_api_gateway_rest_api.my_rest_api.id
stage_name = "prod"
}
EDIT: to clarify, the lambda is not deployed or managed by terraform.
invoke_urlexported attribute for what you need. I am unsure why you would need to use it withimportunless you are doing something very unusual. Please share the code for where you need the endpoint and we can show you how to do it.