我一直在尝试在API网关中创建一个方法,将传入请求的主体丢弃到S3存储桶中的文件/对象中。但我希望该方法每次都创建一个新文件(所以具有新名称的文件)而不是覆盖前一个文件。但我一直在努力寻找办法。任何人都有任何建议/想法?类似于时间戳或序列号(或两者)的东西,用作路径覆盖中的变量,以便它将成为s3文件的名称。我查看了使用X-Amzn-Trace-Id
的建议,但似乎无法在路径覆盖中使用。还有什么我可以尝试的吗?也许是Swagger的东西?我想使用API Gateway实现它(避免使用lambda作为额外步骤)以防止我们的架构过于复杂。提前谢谢!
答案 0 :(得分:0)
您可以将X-Amzn-Trace-Id
设置为方法参数,然后将参数映射到S3路径上的集成参数作为对象名称。
---
swagger: "2.0"
info:
version: "2017-12-04T23:03:26Z"
title: "API"
host: "xxxx.execute-api.us-east-1.amazonaws.com"
basePath: "/dev"
schemes:
- "https"
paths:
/:
post:
produces:
- "application/json"
parameters:
- name: "X-Amzn-Trace-Id"
in: "header"
required: false
type: "string"
responses:
200:
description: "200 response"
schema:
$ref: "#/definitions/Empty"
x-amazon-apigateway-integration:
credentials: "arn:aws:iam::178779171625:role/api-gate-way"
responses:
default:
statusCode: "200"
requestParameters:
integration.request.path.traceid: "method.request.header.X-Amzn-Trace-Id"
uri: "arn:aws:apigateway:us-east-1:bucketName.s3:path/{traceid}"
passthroughBehavior: "when_no_match"
httpMethod: "PUT"
type: "aws"
definitions:
Empty:
type: "object"
title: "Empty Schema"