私はいくつかのAWSリソース、特にラムダに接続されているAPIゲートウェイをプロビジョニングしようとしています。私はTerraform v0.8.8を使用しています。Terraform - AWS - APIゲートウェイの依存関係conundrum
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.region}"
}
# Variables
variable "myregion" { default = "eu-west-2" }
variable "accountId" { default = "" }
variable "lambdaArn" { default = "" }
variable "stageName" { default = "lab" }
# API Gateway
resource "aws_api_gateway_rest_api" "api" {
name = "myapi"
}
resource "aws_api_gateway_method" "method" {
rest_api_id = "${aws_api_gateway_rest_api.api.id}"
resource_id = "${aws_api_gateway_rest_api.api.root_resource_id}"
http_method = "GET"
authorization = "NONE"
}
resource "aws_api_gateway_integration" "integration" {
rest_api_id = "${aws_api_gateway_rest_api.api.id}"
resource_id = "${aws_api_gateway_rest_api.api.root_resource_id}"
http_method = "${aws_api_gateway_method.method.http_method}"
integration_http_method = "POST"
type = "AWS"
uri = "arn:aws:apigateway:${var.myregion}:lambda:path/2015-03-31/functions/${var.lambdaArn}/invocations"
}
# Lambda
resource "aws_lambda_permission" "apigw_lambda" {
statement_id = "AllowExecutionFromAPIGateway"
action = "lambda:InvokeFunction"
function_name = "${var.lambdaArn}"
principal = "apigateway.amazonaws.com"
source_arn = "arn:aws:execute-api:${var.myregion}:${var.accountId}:${aws_api_gateway_rest_api.api.id}/*/${aws_api_gateway_method.method.http_method}/resourcepath/subresourcepath"
}
resource "aws_api_gateway_deployment" "deployment" {
rest_api_id = "${aws_api_gateway_rest_api.api.id}"
stage_name = "${var.stageName}"
}
:
私はその後、(the example in the TF docsに基づいている)コードをプロビジョニング以下のAPIゲートウェイへのパラメータとして提供する出力としてラムダ関数ARNを返し規定ラムダ及びモジュールを有します(リソースのいずれも存在しないとき、すなわち)を
私は最初から上記を実行して、私は次のエラーを取得する:私は第二TFアプリケーションを実行する場合
Error applying plan:
1 error(s) occurred:
* aws_api_gateway_deployment.deployment: Error creating API Gateway Deployment: BadRequestException: No integration defined for method
status code: 400, request id: 15604135-03f5-11e7-8321-f5a75dc2b0a3
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
それは一貫して成功した適用されますが、私は破壊するたびに私はその後、受信します上記の最初のアプリケーションでのエラー。
これは私が明示的にどこかで宣言する必要がある依存関係がありますなら、私は不思議させ、私は(aws_api_gateway_integration_response
ではなくaws_api_gateway_deployment
に関連するが)同様のパターンを記述した、#7486を発見しました。私は手動でaws_api_gateway_deployment
からaws_api_gateway_integration
に明示的な依存関係を追加しようとしましたが、これは効果がありませんでした。
本当にTFのバグかもしれないかどうかなど、何か考えていただければ幸いです。その場合は問題追跡ツールで問題を提起します。私は明らかに何かが欠けている場合に備えて、そうする前にコミュニティに確認すると思った。
多くのおかげで、
エド
P.S.私はthis question on the Terraform user groupと尋ねましたが、これは応答の方法ではほとんど得られないようですが、私はまだここで今質問している問題の原因を把握していません。
どのバージョンのterraformを使用していますか? – user3610360
こんにちは、@ user3610360 - 私はv0.8.8を使用しています –