Is it possible to setup template_file with yaml file stored on s3 bucket?
Is there any other solution to attatch external file to API Gateway (like in case of lambda function which can be build based on file stored on s3)?
I tried to combine api_gateway resource with s3_bucket_object as datasource but terraform probably do not see it. There is an information that there are no changes.
data "aws_s3_bucket_object" "open_api" {
bucket = aws_s3_bucket.lambda_functions_bucket.bucket
key = "openapi-${var.current_api_version}.yaml"
}
resource "aws_api_gateway_rest_api" "default" {
name = "main-gateway"
body = data.aws_s3_bucket_object.open_api.body
endpoint_configuration {
types = ["REGIONAL"]
}
}
I tried also achieve it by using template_file
data "aws_s3_bucket_object" "open_api" {
bucket = aws_s3_bucket.lambda_functions_bucket.bucket
key = "openapi-${var.current_api_version}.yaml"
}
data "template_file" "open_api" {
template = data.aws_s3_bucket_object.open_api.body
vars = {
lambda_invocation_arn_user_post = aws_lambda_function.user_post.invoke_arn
lambda_invocation_arn_webhook_post = aws_lambda_function.webhook_post.invoke_arn
}
}
resource "aws_api_gateway_rest_api" "default" {
name = "main-gateway"
body = data.template_file.open_api.rendered
endpoint_configuration {
types = ["REGIONAL"]
}
}
but result is the same.