How to deploy API Gateway with template_file stored in s3 bucket?

psowa001

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)?

Update: 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.

Kaustubh Khavnekar

Edit:

From terraform docs for aws_s3_bucket_object: The content of an object (body field) is available only for objects which have a human-readable Content-Type (text/* and application/json). The Content-Type header for YAML files seems to be unclear, but in this case using an application/* Content-Type for YAML would result in terraform ignoring the file's contents.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to upload audio file to s3 via api gateway?

How to check if aws s3 bucket available before uploading file using outbound gateway

How to configure `Terraform` to upload zip file to `s3` bucket and then deploy them to lambda

How to Write/read S3 bucket file From RDS Mysql Stored Procedure

How to combine/concatenate videos stored in AWS S3 bucket based on title of the file name

How to display images of products stored on aws s3 bucket

Deploy angular js (front end) on s3 and Api's(Backend) on API Gateway

How to upload file into Wasabi bucket with s3 api with node.js?

Run a Python Script Stored in an AWS S3 Bucket on EC2 and Save Resulting File Back into S3 Bucket

deploy lambda to s3 bucket folder?

AWS API Gateway Method to Serve static content from S3 Bucket

Upload Image into S3 bucket using Api Gateway, Lambda funnction

Can I create AWS API Gateway and S3 bucket only public to VPN

How to Upload a csv file lager than 10MB on S3 using Lambda /API Gateway

Is there a way to point cloudformation template in S3 Bucket while deploying using aws cloudformatiohn deploy

How to integrate API Gateway with s3 in CDK

AWS S3 Listing API - How to list everything inside S3 Bucket with specific prefix

How should I set up my bucket policy so I can deploy to S3?

How to overwrite the folder in s3 bucket when using sam deploy for lamda deployment

How can I SAM deploy an AWS::S3::Bucket with initial files from the project directory

How to deploy to a specific object key inside an S3 Bucket with the Serverless framework?

Deploy api gateway with terraform based on a swagger file

C# Lambda annotations in AWS Gateway fail to upload a binary PDF file to S3 bucket

How can I tell how many objects I've stored in an S3 bucket?

S3 Form File Upload via AWS Api Gateway

How to open a model tarfile stored in S3 bucket in sagemaker notebook?

How to use pdfminer to extract text from PDF files stored in S3 bucket without downloading it locally?

How to pass a parameter from CloudFormation to an AWS Lambda function stored in an S3 bucket

ARN User for AWS S3 Bucket how to manage Bucket via API NodeJS

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive