Looking for Modification to `UserConfigResponseModel` To Declare a Correct `aws_api_gateway_method_response` resource

Viewed 71

Reading this document for how to setup an AWS Transfer Family SFTP server it's specified that you need a application/json UserConfigResponseModel method response type. When Setting up through the web console this is a possible configuration

enter image description here

but when attempting to create this same configuration in Terraform I'm hitting

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" {

With a terraform declaration of

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"
  }
}

I was wondering if it's possible to either Find all valid model identifiers or if someone knows off hand the correct syntax to declare this response_model.

First Edit

Thanks to @marcin for sending me down the right path. I know what I need to do but I haven't gotten the explicit how at this point.

Attempt One

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
}

Which Leads to

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" {

Attempt Two

Which leads to the correct configuration enter image description here enter image description here

1 Answers

You have to first create your UserConfigResponseModel using api_gateway_model. The schema that you need is in the link that you provided.

Related