Terraform 不会将 step 功能部署到 API 网关

Posted

技术标签:

【中文标题】Terraform 不会将 step 功能部署到 API 网关【英文标题】:Terraform won't deploy step function to API gateway 【发布时间】:2021-12-24 23:32:38 【问题描述】:

我正在尝试部署 API GW,并在 post 方法执行中集成步进函数。

我收到的错误是;

错误:创建 API 网关集成时出错:BadRequestException:用于集成的 AWS ARN 必须包含路径或操作

集成如下所示;

resource "aws_api_gateway_integration" "approve_get_integration_POST" 
  rest_api_id                 = aws_api_gateway_rest_api.ccc_api.id
  resource_id                 = aws_api_gateway_resource.QuestionnaireResponseID.id
  http_method                 = aws_api_gateway_method.approve_get_integration_POST.http_method
  integration_http_method     = "POST"
  type                        = "AWS"
  passthrough_behavior        = "NEVER"
  uri                         = "arn:aws:states:us-west-2:1431651122:StartExecution/ccc-step-function-POST"

  request_templates = 
    "application/json" = <<EOF

  "Comment": "Test express state machine",
  "StartAt": "Validate",
  "States": 
    "Validate": 
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "OutputPath": "$.Payload",
      "Parameters": 
        "Payload.$": "$",
        "FunctionName": "arn:aws:lambda:us-west-2:65163961147:function:sb-ccc-validate-submission:$LATEST"
      ,
      "Retry": [
        
          "ErrorEquals": [
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException"
          ],
          "IntervalSeconds": 2,
          "MaxAttempts": 6,
          "BackoffRate": 2
        
      ],
      "Next": "CheckForValidateError"
    ,
    "CheckForValidateError": 
      "Type": "Choice",
      "Choices": [
        
          "Not": 
            "Variable": "$.statusCode",
            "NumericEquals": 200
          ,
          "Next": "ValidateFailError"
        
      ],
      "Default": "Create"
    ,
    "ValidateFailError": 
      "Type": "Succeed"
    ,
EOF
  
```

from what I have read that URI is correct and should be deploying ok.

【问题讨论】:

为什么 uri 是硬编码的而不是另一个资源的输出? 对 terraform 比较陌生 【参考方案1】:

对于 AWS 集成,URI 的格式应为

arn:aws:apigateway:region:subdomain.service|service:path|action/service_api

【讨论】:

***.com/questions/70213550/…

以上是关于Terraform 不会将 step 功能部署到 API 网关的主要内容,如果未能解决你的问题,请参考以下文章

Step By Step将Dotnet Core部署到Docker上

如何获取使用 Terraform 部署的功能应用程序中的“功能网址”?

markdown 用于将VSI部署到专用主机的Terraform示例

在不使用 Terraform 文件配置器的情况下将本地文件部署到实例

将现有 GKE 集群添加到 terraform stat 文件

使用 Terraform 进行分层部署