From e18d8dd1466c68a1283e37bb094ed1ccff4d13d2 Mon Sep 17 00:00:00 2001 From: xpk Date: Mon, 4 Mar 2024 16:39:19 +0800 Subject: [PATCH] UPD: added integration and method responses --- .../ApplicationIntegration/apigw-lambda/README.md | 12 ++++++++++-- .../ApplicationIntegration/apigw-lambda/main.tf | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/modules/ApplicationIntegration/apigw-lambda/README.md b/modules/ApplicationIntegration/apigw-lambda/README.md index ce45e84..53493a1 100644 --- a/modules/ApplicationIntegration/apigw-lambda/README.md +++ b/modules/ApplicationIntegration/apigw-lambda/README.md @@ -23,13 +23,17 @@ No modules. |------|------| | [aws_api_gateway_deployment.apigw-deployment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_deployment) | resource | | [aws_api_gateway_integration.api-integration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_integration) | resource | +| [aws_api_gateway_integration_response.MyDemoIntegrationResponse](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_integration_response) | resource | | [aws_api_gateway_method.api-method](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method) | resource | +| [aws_api_gateway_method_response.response_200](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method_response) | resource | | [aws_api_gateway_method_settings.apigw-method-settings](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method_settings) | resource | | [aws_api_gateway_resource.api-res](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_resource) | resource | | [aws_api_gateway_rest_api.api](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_rest_api) | resource | | [aws_api_gateway_rest_api_policy.api-policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_rest_api_policy) | resource | | [aws_api_gateway_stage.apigw-stage](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_stage) | resource | | [aws_api_gateway_vpc_link.api-vpc-link](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_vpc_link) | resource | +| [aws_cloudwatch_log_group.lambda-logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource | +| [aws_cloudwatch_log_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource | | [aws_iam_role.lambda-exec-role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | | [aws_iam_role_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource | | [aws_lambda_function.function](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource | @@ -39,6 +43,7 @@ No modules. | [aws_caller_identity.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | | [aws_iam_policy_document.api-policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | | [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | +| [aws_vpc.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source | ## Inputs @@ -48,13 +53,16 @@ No modules. | apigw-subnet-ids | Subnet IDs of apigateway | `list(string)` | n/a | yes | | apigw-vpc-id | VPC id of apigateway | `string` | n/a | yes | | apigw-vpc-link-target-arns | Target arns for apigateway VPC link | `list(string)` | `[]` | no | +| cloudwatchlog-retention | Cloudwatch log group retention days | `number` | `14` | no | | create-vpc-link | Set true to create vpc link for outbound access to specific targets | `bool` | n/a | yes | +| cwl-cmk-key-id | CMK arn for cloudwatch logs encryption | `string` | `null` | no | | description | Description of apigateway | `string` | n/a | yes | | lambda-archive-file | Path to lambda zip archive | `string` | n/a | yes | +| lambda-main-function-name | Main python file without the .py extension | `string` | n/a | yes | | lambda-runtime-version | Lambda runtime version | `string` | `"python3.12"` | no | | name | Name of apigateway | `string` | n/a | yes | | path\_part | Last path segment of this API resource | `string` | n/a | yes | -| stage-name | Apigateway stage name | `string` | n/a | yes | +| stages | apigateway stages | `map` | n/a | yes | ## Outputs @@ -62,4 +70,4 @@ No outputs. --- ## Authorship -This module was developed by Rackspace. \ No newline at end of file +This module was developed by xpk. \ No newline at end of file diff --git a/modules/ApplicationIntegration/apigw-lambda/main.tf b/modules/ApplicationIntegration/apigw-lambda/main.tf index 9d40567..d4a3bd1 100644 --- a/modules/ApplicationIntegration/apigw-lambda/main.tf +++ b/modules/ApplicationIntegration/apigw-lambda/main.tf @@ -55,6 +55,21 @@ resource "aws_api_gateway_integration" "api-integration" { uri = aws_lambda_function.function.invoke_arn } +resource "aws_api_gateway_method_response" "response_200" { + rest_api_id = aws_api_gateway_rest_api.api.id + resource_id = aws_api_gateway_resource.api-res.id + http_method = aws_api_gateway_method.api-method.http_method + status_code = "200" +} + +resource "aws_api_gateway_integration_response" "MyDemoIntegrationResponse" { + rest_api_id = aws_api_gateway_rest_api.api.id + resource_id = aws_api_gateway_resource.api-res.id + http_method = aws_api_gateway_method.api-method.http_method + status_code = aws_api_gateway_method_response.response_200.status_code +} + + # apigw deployment and stage resource "aws_api_gateway_deployment" "apigw-deployment" { rest_api_id = aws_api_gateway_rest_api.api.id