我想create a step function API using API gateway使用Terraforms api_gateway_integration和sfn_state_machine。
我现在必须在api_gateway_integration处填写uri-parameter。
我的step函数已创建,我可以引用step函数的ID(类似arn:aws:states:*region*:*account*:stateMachine:*step-function-name*:stateMachine:*step-function-entry-point*
)。
如果目标是AWS step函数,谁能告诉我该方案或uri参数外观的示例吗?
resource "aws_api_gateway_integration" "endpoint_integration" {
...
integration_http_method = "POST"
type = "AWS"
uri = <<<<< What to place here???
}
答案 0 :(得分:0)
与Terraform-integrate an AWS lambda with an API gateway相比,您不能从API网关“直接”(使用“ uri”-参数”指向特定的AWS状态机,而是aws_api_gateway_integration-resource指向AWS状态通常,AWS ARN会在请求中引用特定的AWS状态机。您可以使用API gateway request template从API网关映射到特定状态机,以便您可以省略请求API时,会死于stateMachineArn。有关详细说明,请参见AWS documentation "Creating a Step Functions API Using API Gateway"。
工作示例
# var.aws_region = eu-central-1
# var.sfn_orchestrater_arn = arn:aws:states:eu-central-1:*account*:stateMachine:*step-function-entry-point*
resource "aws_api_gateway_integration" "endpoint_integration" {
http_method = "POST"
integration_http_method = "POST"
type = "AWS"
passthrough_behavior = "NEVER"
uri = "arn:aws:apigateway:${var.aws_region}:states:action/StartExecution"
request_templates = {
"application/json" = <<EOF
{
"input": "$util.escapeJavaScript($input.json('$'))",
"stateMachineArn": "${var.sfn_orchestrater_arn)}"
}
EOF
}
}