【发布时间】:2021-11-02 03:55:39
【问题描述】:
Reading this document for how to setup an AWS Transfer Family SFTP server 指定您需要application/json UserConfigResponseModel 方法响应类型。通过 Web 控制台进行设置时,这是一种可能的配置
但是当我尝试在 Terraform 中创建相同的配置时,我遇到了
Error: Error creating API Gateway Method Response: BadRequestException: Invalid model identifier specified: UserConfigResponseModel
on ../../../../module/data-platform-sftp/api_gateway.tf line 53, in resource "aws_api_gateway_method_response" "status_200":
53: resource "aws_api_gateway_method_response" "status_200" {
带有 terraform 声明
resource "aws_api_gateway_method_response" "status_200" {
rest_api_id = aws_api_gateway_rest_api.reconciliation_auth.id
resource_id = aws_api_gateway_resource.config_path.id
http_method = aws_api_gateway_method.config_get.http_method
status_code = "200"
response_models = {
"application/json" = "UserConfigResponseModel"
}
}
我想知道是否可以找到所有有效的模型标识符,或者是否有人知道声明此 response_model 的正确语法。
第一次编辑
感谢@marcin 让我走上了正确的道路。我知道我需要做什么,但目前还没有明确的方法。
尝试一
resource "aws_api_gateway_model" "status_200" {
rest_api_id = aws_api_gateway_rest_api.reconciliation_auth.id
name = "UserConfigResponseModel"
description = "a JSON schema that matches the documented schema here: https://aws.amazon.com/premiumsupport/knowledge-center/transfer-customize-identity-provider/"
content_type = "application/json"
schema = <<EOF
{"$schema":"http://json-schema.org/draft-04/schema#","title":"UserUserConfig","type":"object","properties":{"Role":{"type":"string"},"Policy":{"type":"string"},"HomeDirectory":{"type":"string"},"PublicKeys":{"type":"array","items":{"type":"string"}}}}
EOF
}
resource "aws_api_gateway_method_response" "status_200" {
rest_api_id = aws_api_gateway_rest_api.reconciliation_auth.id
resource_id = aws_api_gateway_resource.config_path.id
http_method = aws_api_gateway_method.config_get.http_method
status_code = "200"
response_models = aws_api_gateway_model.status_200
}
导致
Error: Error creating API Gateway Method Response: BadRequestException: Invalid model identifier specified: {"$schema":"http://json-schema.org/draft-04/schema#","title":"UserUserConfig","type":"object","properties":{"Role":{"type":"string"},"Policy":{"type":"string"},"H
omeDirectory":{"type":"string"},"PublicKeys":{"type":"array","items":{"type":"string"}}}}
on ../../../../module/data-platform-sftp/api_gateway.tf line 65, in resource "aws_api_gateway_method_response" "status_200":
65: resource "aws_api_gateway_method_response" "status_200" {
尝试二
这会导致正确的配置 enter image description here
【问题讨论】:
标签: amazon-web-services terraform api-gateway