Skip to content
This repository has been archived by the owner on Aug 17, 2019. It is now read-only.

Commit

Permalink
Add tf file for API-gateway as delete-branch2
Browse files Browse the repository at this point in the history
to create test resource but working delete-branch will be deleted 😢

Terraform plan:
---
Terraform will perform the following actions:

  + aws_api_gateway_deployment.prod
      id:                                 <computed>
      created_date:                       <computed>
      execution_arn:                      <computed>
      invoke_url:                         <computed>
      rest_api_id:                        "4x61liwu14"
      stage_description:                  "production"
      stage_name:                         "prod"

  + aws_api_gateway_integration.delete-branch
      id:                                 <computed>
      cache_namespace:                    <computed>
      connection_type:                    "INTERNET"
      http_method:                        "POST"
      integration_http_method:            "POST"
      passthrough_behavior:               <computed>
      request_templates.%:                "1"
      request_templates.application/json: "{\n  \"id\": \"$input.params('id')\",\n  \"_method\": \"POST\"\n}\n"
      resource_id:                        "${aws_api_gateway_resource.post.id}"
      rest_api_id:                        "4x61liwu14"
      timeout_milliseconds:               "29000"
      type:                               "AWS"
      uri:                                "arn:aws:apigateway:ap-northeast-1:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-northeast-1:655123516369:function:delete_branch_bot/invocations"

  + aws_api_gateway_integration_response.post_200
      id:                                 <computed>
      http_method:                        "POST"
      resource_id:                        "${aws_api_gateway_resource.post.id}"
      rest_api_id:                        "4x61liwu14"
      status_code:                        "200"

  + aws_api_gateway_method.post
      id:                                 <computed>
      api_key_required:                   "false"
      authorization:                      "NONE"
      http_method:                        "POST"
      resource_id:                        "${aws_api_gateway_resource.post.id}"
      rest_api_id:                        "4x61liwu14"

  + aws_api_gateway_method_response.200
      id:                                 <computed>
      http_method:                        "POST"
      resource_id:                        "${aws_api_gateway_resource.post.id}"
      rest_api_id:                        "4x61liwu14"
      status_code:                        "200"

  + aws_api_gateway_resource.post
      id:                                 <computed>
      parent_id:                          "3jwhv4uvta"
      path:                               <computed>
      path_part:                          "/"
      rest_api_id:                        "4x61liwu14"

  - aws_api_gateway_rest_api.delete-branch

Plan: 6 to add, 0 to change, 1 to destroy.
  • Loading branch information
chaspy committed Oct 6, 2018
1 parent 88b1b5c commit 54d0d69
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
55 changes: 55 additions & 0 deletions api-gateway.tf
Expand Up @@ -6,3 +6,58 @@ resource "aws_api_gateway_rest_api" "delete-branch2" {
types = ["REGIONAL"]
}
}

resource "aws_api_gateway_deployment" "prod" {
depends_on = [
"aws_api_gateway_integration.delete-branch",
]
rest_api_id = "${aws_api_gateway_rest_api.delete-branch2.id}"
stage_description = "production"
stage_name = "prod"
}

# /post
resource "aws_api_gateway_resource" "post" {
parent_id = "${aws_api_gateway_rest_api.delete-branch2.root_resource_id}"
path_part = "/"
rest_api_id = "${aws_api_gateway_rest_api.delete-branch2.id}"
}

resource "aws_api_gateway_integration" "delete-branch" {
http_method = "${aws_api_gateway_method.post.http_method}"
integration_http_method = "POST"
request_templates = {
"application/json" = <<EOF
{
"id": "$input.params('id')",
"_method": "POST"
}
EOF
}
resource_id = "${aws_api_gateway_resource.post.id}"
rest_api_id = "${aws_api_gateway_rest_api.delete-branch2.id}"
type = "AWS"
uri = "arn:aws:apigateway:${var.region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${var.region}:${var.aws_account_id}:function:${aws_lambda_function.delete_branch_bot.function_name}/invocations"
}

resource "aws_api_gateway_method" "post" {
authorization = "NONE"
http_method = "POST"
resource_id = "${aws_api_gateway_resource.post.id}"
rest_api_id = "${aws_api_gateway_rest_api.delete-branch2.id}"
}

resource "aws_api_gateway_method_response" "200" {
http_method = "${aws_api_gateway_method.post.http_method}"
resource_id = "${aws_api_gateway_resource.post.id}"
rest_api_id = "${aws_api_gateway_rest_api.delete-branch2.id}"
status_code = "200"
}

resource "aws_api_gateway_integration_response" "post_200" {
depends_on = ["aws_api_gateway_integration.delete-branch"]
http_method = "${aws_api_gateway_method.post.http_method}"
resource_id = "${aws_api_gateway_resource.post.id}"
rest_api_id = "${aws_api_gateway_rest_api.delete-branch2.id}"
status_code = "${aws_api_gateway_method_response.200.status_code}"
}
4 changes: 4 additions & 0 deletions variables.tf
Expand Up @@ -19,3 +19,7 @@ provider "aws" {
secret_key = "${var.aws_secret_key}"
region = "${var.region}"
}

variable "aws_account_id" {
default = "655123516369"
}

0 comments on commit 54d0d69

Please sign in to comment.