mon*_*mon 10 amazon-web-services terraform-provider-aws amazon-kinesis-firehose amazon-api-gateway
问题的解决方案或解决方法。
如果 Firehose 是提前单独创建的,则下面的 Terraform API Gateway 与 Firehose 的集成有效。
resource "aws_api_gateway_integration" "click_put" {
rest_api_id = data.aws_api_gateway_rest_api.mysfit.id
resource_id = aws_api_gateway_resource.click.id
type = "AWS"
uri = "arn:aws:apigateway:${var.REGION}:firehose:action/PutRecord"
credentials = aws_iam_role.api_click.arn
http_method = aws_api_gateway_method.click_put.http_method
integration_http_method = "POST"
request_parameters = {
"integration.request.header.Content-Type" = "'application/x-amz-json-1.1'"
}
passthrough_behavior = "NEVER"
request_templates = {
"application/json" = <<EOF
{
"DeliveryStreamName": "${local.firehose_name}",
"Record": {
"Data": "$util.base64Encode($input.json('$'))"
}
}
EOF
}
}
...
resource "aws_api_gateway_integration_response" "click_put" {
rest_api_id = data.aws_api_gateway_rest_api.mysfit.id
resource_id = aws_api_gateway_resource.click.id
http_method = aws_api_gateway_method.click_put.http_method
status_code = aws_api_gateway_method_response.click_put.status_code
response_parameters = {
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
}
Run Code Online (Sandbox Code Playgroud)
但是,如果它们是在同一个根模块中创建的,则会导致错误。
Error creating API Gateway Integration Response: NotFoundException: Invalid Integration identifier specified
on api_click.tf line 185, in resource "aws_api_gateway_integration_response" "click_put":
185: resource "aws_api_gateway_integration_response" "click_put" {
Run Code Online (Sandbox Code Playgroud)
mon*_*mon 15
将导致“NotFoundException:指定的集成标识符无效”的资源依赖于 aws_api_gateway_integration。
resource "aws_api_gateway_integration_response" "click_put" {
rest_api_id = data.aws_api_gateway_rest_api.mysfit.id
resource_id = aws_api_gateway_resource.click.id
http_method = aws_api_gateway_method.click_put.http_method
status_code = aws_api_gateway_method_response.click_put.status_code
response_parameters = {
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
depends_on = [
aws_api_gateway_integration.click_put
]
}
Run Code Online (Sandbox Code Playgroud)
有迹象表明,depends_on aws_api_gateway_integration或等待将是方法。
推荐的做法可能是等待 aws_api_gateway_integration 资源的完全完成。
aws_api_gateway_integration_response
注意:取决于您的 rest api 中有 aws_api_gateway_integration。为了确保这一点,您可能需要为干净的运行添加一个明确的depends_on。
API 网关集成问题 - 指定的方法标识符无效错误 #4001
我正在使用以下解决方法来解决类似的问题。在同一应用期间创建所有资源时,我在第一次运行时收到无效方法标识符错误。为 Lambda 创建了一个代理 API:
resource "aws_api_gateway_resource" "proxy" {
rest_api_id = aws_api_gateway_rest_api.rest-api.id
parent_id = aws_api_gateway_rest_api.rest-api.root_resource_id
path_part = "{proxy+}"
}
resource "null_resource" "method-delay" {
provisioner "local-exec" {
command = "sleep 5"
}
triggers = {
response = aws_api_gateway_resource.proxy.id
}
}
resource "aws_api_gateway_method_response" "response" {
depends_on = [null_resource.method-delay]
http_method = "ANY"
resource_id = aws_api_gateway_resource.proxy.id
rest_api_id = aws_api_gateway_rest_api.rest-api.id
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6263 次 |
| 最近记录: |