From 4b6889d1534d29e08956169ffe06d05961badb2a Mon Sep 17 00:00:00 2001 From: Himanshu Ahirwar Date: Tue, 30 Jan 2024 21:49:56 +0530 Subject: [PATCH] remove unused variables and fix create condtion on resources --- .../complete/http-api-gateway/example.tf | 13 +- .../private-rest-api-gateway/example.tf | 40 ++-- .../complete/rest-api-gateway/example.tf | 34 +--- main.tf | 106 ++++++----- outputs.tf | 9 +- variables.tf | 178 +++--------------- 6 files changed, 129 insertions(+), 251 deletions(-) diff --git a/_examples/complete/http-api-gateway/example.tf b/_examples/complete/http-api-gateway/example.tf index a575d31..94026e0 100644 --- a/_examples/complete/http-api-gateway/example.tf +++ b/_examples/complete/http-api-gateway/example.tf @@ -10,10 +10,11 @@ provider "aws" { ####---------------------------------------------------------------------------------- locals { - name = "api" - environment = "test" - domain_name = "clouddrove.ca" - region = "us-east-1" + name = "api" + environment = "test" + region = "us-east-1" + domain_name = "clouddrove.ca" + hosted_zone_id = "Z015XXXXXXXXXXXXXXIEP" } ####---------------------------------------------------------------------------------- ## ACM @@ -78,10 +79,10 @@ module "api_gateway" { name = local.name environment = local.environment - domain_name = "clouddrove.ca" + domain_name = "api.${local.domain_name}" domain_name_certificate_arn = module.acm.arn integration_uri = module.lambda.invoke_arn - zone_id = "Z082xxxxxxxxxxx" + zone_id = local.hosted_zone_id auto_deploy = true stage_name = "$default" create_vpc_link_enabled = false diff --git a/_examples/complete/private-rest-api-gateway/example.tf b/_examples/complete/private-rest-api-gateway/example.tf index e86ed51..def0eb5 100644 --- a/_examples/complete/private-rest-api-gateway/example.tf +++ b/_examples/complete/private-rest-api-gateway/example.tf @@ -10,10 +10,11 @@ provider "aws" { ####---------------------------------------------------------------------------------- locals { - name = "api" - environment = "test" - domain_name = "clouddrove.ca" - region = "us-east-1" + name = "api" + environment = "test" + region = "us-east-1" + domain_name = "clouddrove.ca" + hosted_zone_id = "Z015XXXXXXXXXXXXXXIEP" } ####---------------------------------------------------------------------------------- ## ACM @@ -114,7 +115,7 @@ module "subnets" { rule_action = "allow" from_port = 0 to_port = 0 - protocol = "tcp" + protocol = "-1" cidr_block = module.vpc.vpc_cidr_block } ] @@ -124,28 +125,28 @@ module "subnets" { rule_action = "allow" from_port = 0 to_port = 0 - protocol = "tcp" + protocol = "-1" cidr_block = module.vpc.vpc_cidr_block } ] - public_outbound_acl_rules = [ + public_inbound_acl_rules = [ { rule_number = 100 rule_action = "allow" from_port = 0 to_port = 0 - protocol = "tcp" - cidr_block = module.vpc.vpc_cidr_block + protocol = "-1" + cidr_block = "0.0.0.0/0" } ] - public_inbound_acl_rules = [ + public_outbound_acl_rules = [ { rule_number = 100 rule_action = "allow" from_port = 0 to_port = 0 - protocol = "tcp" - cidr_block = module.vpc.vpc_cidr_block + protocol = "-1" + cidr_block = "0.0.0.0/0" } ] @@ -200,25 +201,22 @@ module "rest_api_private" { rest_api_endpoint_type = "PRIVATE" rest_api_description = "Private REST API for ${module.lambda.name} lambda function" integration_uri = module.lambda.invoke_arn - rest_api_stage_name = "tests" + rest_api_stage_name = "default" auto_deploy = true rest_api_base_path = "test" - # -- Required - domain_name = local.domain_name - zone_id = "Z0156xxxxxxxxxxxxxx" + domain_name = "api.${local.domain_name}" + zone_id = local.hosted_zone_id # -- VPC Endpoint configuration vpc_id = module.vpc.vpc_id - service_name = "com.amazonaws.us-east-1.execute-api" - vpc_endpoint_type = "Interface" - private_dns_enabled = true subnet_ids = module.subnets.private_subnet_id security_group_ids = [module.security_group.security_group_id] + service_name = "com.amazonaws.${local.region}.execute-api" + vpc_endpoint_type = "Interface" + private_dns_enabled = true domain_name_certificate_arn = module.acm.arn - #---access log---- - enable_access_logs = true retention_in_days = 7 } diff --git a/_examples/complete/rest-api-gateway/example.tf b/_examples/complete/rest-api-gateway/example.tf index 60fb701..89ba1ab 100644 --- a/_examples/complete/rest-api-gateway/example.tf +++ b/_examples/complete/rest-api-gateway/example.tf @@ -10,10 +10,11 @@ provider "aws" { ####---------------------------------------------------------------------------------- locals { - name = "api" - environment = "test" - domain_name = "clouddrove.ca" - region = "us-east-1" + name = "api" + environment = "test" + region = "us-east-1" + domain_name = "clouddrove.ca" + hosted_zone_id = "Z015XXXXXXXXXXXXXXIEP" } ####---------------------------------------------------------------------------------- ## ACM @@ -80,8 +81,10 @@ module "rest_api" { name = "${local.name}-rest-api" environment = local.environment - domain_name_certificate_arn = module.acm.arn create_rest_api = true + domain_name_certificate_arn = module.acm.arn + domain_name = "api.${local.domain_name}" + zone_id = local.hosted_zone_id rest_api_description = "REST API for ${module.lambda.name} lambda function" rest_api_endpoint_type = "REGIONAL" integration_uri = module.lambda.invoke_arn @@ -101,29 +104,8 @@ module "rest_api" { } #---access log---- - enable_access_logs = true retention_in_days = 7 - - - # -- Required - domain_name = local.domain_name - zone_id = "Z015646xxxxxxxxxxx" - rest_api_role = <