From f84e838d617eda7a22ef9bc8c034f4e4aac1f94b Mon Sep 17 00:00:00 2001 From: adamwshero Date: Tue, 18 Oct 2022 16:16:40 -0600 Subject: [PATCH] Bug fix. --- CHANGELOG.md | 6 ++ README.md | 72 +++------------- examples/terraform/README.md | 104 ++++++++++------------- examples/terraform/main.tf | 2 +- examples/terragrunt/README.md | 130 ++++++++--------------------- examples/terragrunt/terragrunt.hcl | 2 +- variables.tf | 18 +--- 7 files changed, 105 insertions(+), 229 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83f2b08..958d1d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.0.2 (October 18, 2022) + +BUG: + + * Fixed scenario where HTTP code block was expecting an input. + ## 1.0.1 (September 23, 2022) CHORE: diff --git a/README.md b/README.md index 33d191d..1bef67b 100644 --- a/README.md +++ b/README.md @@ -51,45 +51,15 @@ Look at our [Terraform example](latest/examples/terraform/) where you can get a * Both rest or http types can be enabled at the same time during apply.
-### Terragrunt Complete Example -``` -locals { - external_deps = read_terragrunt_config(find_in_parent_folders("external-deps.hcl")) - account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl")) - product_vars = read_terragrunt_config(find_in_parent_folders("product.hcl")) - env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl")) - product = local.product_vars.locals.product_name - prefix = local.product_vars.locals.prefix - account = local.account_vars.locals.account_id - env = local.env_vars.locals.env - - tags = merge( - local.env_vars.locals.tags, - local.additional_tags - ) - - additional_tags = { - } -} - -include { - path = find_in_parent_folders() -} - -dependency "internal_nlb_1" { - config_path = "../nlb/internal/1" -} - -dependency "internal_nlb_2" { - config_path = "../nlb/internal/2" -} - -dependency "vpc" { - config_path = "../vpc" -} +## Special Notes + * (REST VPC Link) + * When renaming a REST VPC Link, the attached NLB resource may not be detached from the VPC Link and the module will return an error. In this case, you will need to delete the VPC Link manually. +
+### Basic Terragrunt Example +``` terraform { - source = "git::git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.0" + source = "git::git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.2" } @@ -102,11 +72,6 @@ inputs = { name = "rest-vpc-link1-dev" description = "VPC Link for development REST APIs." target_arns = [dependency.internal_nlb_1.outputs.lb_arn] - }, - { - name = "rest-vpc-link2-qa" - description = "VPC Link for production REST APIs." - target_arns = [dependency.internal_nlb_2.outputs.lb_arn] } ] @@ -115,22 +80,17 @@ inputs = { name = "http-vpc-link1-dev" security_group_ids = [dependency.vpc.outputs.default_security_group_id] subnet_ids = dependency.vpc.outputs.private_subnets - }, - { - name = "http-vpc-link1-qa" - security_group_ids = [dependency.vpc.outputs.default_security_group_id] - subnet_ids = dependency.vpc.outputs.private_subnets - }, + } ] tags = local.tags } ``` -## Complete Terraform Example +## Basic Terraform Example ``` module "vpc-links" { - source = "git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.0" + source = "git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.2" create_rest_vpc_links = true create_http_vpc_links = true @@ -139,11 +99,6 @@ module "vpc-links" { name = "rest-vpc-link1-dev" description = "VPC Link for development REST APIs." target_arns = ["arn:aws:elasticloadbalancing:us-east-1:1111111111111:loadbalancer/net/test1/abcd12345"] - }, - { - name = "rest-vpc-link2-qa" - description = "VPC Link for production REST APIs." - target_arns = ["arn:aws:elasticloadbalancing:us-east-1:1111111111111:loadbalancer/net/test2/abcd12345"] } ] @@ -152,12 +107,7 @@ module "vpc-links" { name = "http-vpc-link1-dev" security_group_ids = ["sg-123456789abcdefg"] subnet_ids = ["subnet-132456789abcdefg"] - }, - { - name = "http-vpc-link1-qa" - security_group_ids = ["sg-123456789abcdefg"] - subnet_ids = ["subnet-132456789abcdefg"] - }, + } ] tags = { Environment = "dev" diff --git a/examples/terraform/README.md b/examples/terraform/README.md index 30f4968..35172b9 100644 --- a/examples/terraform/README.md +++ b/examples/terraform/README.md @@ -1,7 +1,51 @@ +## Basic Terraform Example (REST) +``` +module "vpc-links" { + source = "git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.2" + create_rest_vpc_links = true + create_http_vpc_links = false + + rest_vpc_links = [ + { + name = "rest-vpc-link1-dev" + description = "VPC Link for development REST APIs." + target_arns = ["arn:aws:elasticloadbalancing:us-east-1:1111111111111:loadbalancer/net/test1/abcd12345"] + } + ] + + tags = { + Environment = "dev" + Owner = "DevOps" + CreatedByTerraform = true + } +} +``` +## Basic Terraform Example (HTTP) +``` +module "vpc-links" { + source = "git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.2" + create_rest_vpc_links = false + create_http_vpc_links = true + + http_vpc_links = [ + { + name = "http-vpc-link1-dev" + security_group_ids = ["sg-123456789abcdefg"] + subnet_ids = ["subnet-132456789abcdefg"] + } + ] + + tags = { + Environment = "dev" + Owner = "DevOps" + CreatedByTerraform = true + } +} +``` ## Complete Terraform Example ``` module "vpc-links" { - source = "git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.0" + source = "git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.2" create_rest_vpc_links = true create_http_vpc_links = true @@ -37,61 +81,3 @@ module "vpc-links" { } } ``` -
- -## Requirements - -| Name | Version | -|------|---------| -| [aws](#requirement\_aws) | >= 2.67.0 | -| [terraform](#requirement\_terraform) | >= 0.14.0 -| [terragrunt](#requirement\_terragrunt) | >= 0.28.0 | - -## Providers - -| Name | Version | -|------|---------| -| [aws](#provider\_aws) | >= 4.30.0 | - -## Resources - -| Name | Type | -|------|------| -| [apigateway_vpc_link.rsm](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_vpc_link) | resource | -| [apigatewayv2_vpc_link.rsm](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/apigatewayv2_vpc_link) | resource | - -## Available Inputs - -| Name | Resource | Variable | Data Type | Default | Required? -| ----------------------------- | ----------------------- | -------------------- | --------- | ------- | -------- | -| REST VPC Link Name | `apigateway_vpc_link` | `name` | `string` | `null` | Yes | -| REST VPC Link Description | `apigateway_vpc_link` | `description` | `string` | `null` | No | -| REST NLB Target Arns | `apigateway_vpc_link` | `target_arns` | `string` | `null` | Yes | -| HTTP VPC Link Name | `apigatewayv2_vpc_link` | `name` | `string` | `null` | Yes | -| HTTP VPC Link Security Groups | `apigatewayv2_vpc_link` | `security_group_ids` | `string` | `null` | Yes | -| HTTP VPC Link Subnet Ids | `apigatewayv2_vpc_link` | `subnet_ids` | `string` | `null` | Yes | - -## Predetermined Inputs - -| Name | Resource | Property | Data Type | Default | Required? -| -------------------- | ---------------------- | ---------- | --------- | ------- | -------- | -| | | | | | | - -## Outputs - -| Name | Description | -|------------------------------------------|--------------------------------------- | -| apigateway_vpc_link.id | Id of the REST VPC Link. | -| apigateway_vpc_link.name | Name of the REST VPC Link. | -| apigateway_vpc_link.description | Description of the REST VPC Link. | -| apigateway_vpc_link.target_arns | NLB Arns of the REST VPC link. | -| apigatewayv2_vpc_link.name | Name of the HTTP VPC Link. | -| apigatewayv2_vpc_link.security_group_ids | Security Groups for the HTTP VPC link. | -| apigatewayv2_vpc_link.subnet_ids | Subnet Ids for the HTTP VPC link. | - -## Supporting Articles & Documentation - - AWS Hyperplane and AWS PrivateLink - - https://aws.amazon.com/blogs/compute/understanding-vpc-links-in-amazon-api-gateway-private-integrations/ - - Building private cross-account APIs using Amazon API Gateway and AWS PrivateLink - - https://aws.amazon.com/blogs/compute/building-private-cross-account-apis-using-amazon-api-gateway-and-aws-privatelink/ - diff --git a/examples/terraform/main.tf b/examples/terraform/main.tf index ce30de3..4896a6a 100644 --- a/examples/terraform/main.tf +++ b/examples/terraform/main.tf @@ -1,5 +1,5 @@ module "vpc-links" { - source = "git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.0" + source = "git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.2" create_rest_vpc_links = true create_http_vpc_links = true diff --git a/examples/terragrunt/README.md b/examples/terragrunt/README.md index 2461359..b03b448 100644 --- a/examples/terragrunt/README.md +++ b/examples/terragrunt/README.md @@ -1,42 +1,49 @@ -### Terragrunt Complete Example +### Terragrunt Basic Example (REST) ``` -locals { - external_deps = read_terragrunt_config(find_in_parent_folders("external-deps.hcl")) - account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl")) - product_vars = read_terragrunt_config(find_in_parent_folders("product.hcl")) - env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl")) - product = local.product_vars.locals.product_name - prefix = local.product_vars.locals.prefix - account = local.account_vars.locals.account_id - env = local.env_vars.locals.env +terraform { + source = "git::git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.2" +} - tags = merge( - local.env_vars.locals.tags, - local.additional_tags - ) +inputs = { + create_rest_vpc_links = true + create_http_vpc_links = false - additional_tags = { - } -} + rest_vpc_links = [ + { + name = "rest-vpc-link1-dev" + description = "VPC Link for development REST APIs." + target_arns = [dependency.internal_nlb_1.outputs.lb_arn] + } + ] -include { - path = find_in_parent_folders() + tags = local.tags } - -dependency "internal_nlb_1" { - config_path = "../nlb/internal/1" +``` +### Terragrunt Basic Example (HTTP) +``` +terraform { + source = "git::git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.2" } -dependency "internal_nlb_2" { - config_path = "../nlb/internal/2" -} +inputs = { + create_rest_vpc_links = false + create_http_vpc_links = true -dependency "vpc" { - config_path = "../vpc" -} + http_vpc_links = [ + { + name = "http-vpc-link1-dev" + security_group_ids = [dependency.vpc.outputs.default_security_group_id] + subnet_ids = dependency.vpc.outputs.private_subnets + } + ] + tags = local.tags +} +``` +### Terragrunt Complete Example +``` terraform { - source = "git::git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.0" + source = "git::git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.2" } inputs = { @@ -71,67 +78,4 @@ inputs = { tags = local.tags } -``` -
- -## Requirements - -| Name | Version | -|------|---------| -| [aws](#requirement\_aws) | >= 2.67.0 | -| [terraform](#requirement\_terraform) | >= 0.14.0 -| [terragrunt](#requirement\_terragrunt) | >= 0.28.0 | - -
- - -## Providers - -| Name | Version | -|------|---------| -| [aws](#provider\_aws) | >= 4.30.0 | - -
- -## Resources - -| Name | Type | -|------|------| -| [apigateway_vpc_link.rsm](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_vpc_link) | resource | -| [apigatewayv2_vpc_link.rsm](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/apigatewayv2_vpc_link) | resource | - -## Available Inputs - -| Name | Resource | Variable | Data Type | Default | Required? -| ----------------------------- | ----------------------- | -------------------- | --------- | ------- | -------- | -| REST VPC Link Name | `apigateway_vpc_link` | `name` | `string` | `null` | Yes | -| REST VPC Link Description | `apigateway_vpc_link` | `description` | `string` | `null` | No | -| REST NLB Target Arns | `apigateway_vpc_link` | `target_arns` | `string` | `null` | Yes | -| HTTP VPC Link Name | `apigatewayv2_vpc_link` | `name` | `string` | `null` | Yes | -| HTTP VPC Link Security Groups | `apigatewayv2_vpc_link` | `security_group_ids` | `string` | `null` | Yes | -| HTTP VPC Link Subnet Ids | `apigatewayv2_vpc_link` | `subnet_ids` | `string` | `null` | Yes | - -## Predetermined Inputs - -| Name | Resource | Property | Data Type | Default | Required? -| -------------------- | ---------------------- | ---------- | --------- | ------- | -------- | -| | | | | | | - -## Outputs - -| Name | Description | -|------------------------------------------|--------------------------------------- | -| apigateway_vpc_link.id | Id of the REST VPC Link. | -| apigateway_vpc_link.name | Name of the REST VPC Link. | -| apigateway_vpc_link.description | Description of the REST VPC Link. | -| apigateway_vpc_link.target_arns | NLB Arns of the REST VPC link. | -| apigatewayv2_vpc_link.name | Name of the HTTP VPC Link. | -| apigatewayv2_vpc_link.security_group_ids | Security Groups for the HTTP VPC link. | -| apigatewayv2_vpc_link.subnet_ids | Subnet Ids for the HTTP VPC link. | - -## Supporting Articles & Documentation - - AWS Hyperplane and AWS PrivateLink - - https://aws.amazon.com/blogs/compute/understanding-vpc-links-in-amazon-api-gateway-private-integrations/ - - Building private cross-account APIs using Amazon API Gateway and AWS PrivateLink - - https://aws.amazon.com/blogs/compute/building-private-cross-account-apis-using-amazon-api-gateway-and-aws-privatelink/ - +``` \ No newline at end of file diff --git a/examples/terragrunt/terragrunt.hcl b/examples/terragrunt/terragrunt.hcl index 89abc8d..748f503 100644 --- a/examples/terragrunt/terragrunt.hcl +++ b/examples/terragrunt/terragrunt.hcl @@ -34,7 +34,7 @@ dependency "vpc" { } terraform { - source = "git::git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.0" + source = "git::git@github.com:adamwshero/terraform-aws-api-gateway-vpc-link.git//.?ref=1.0.2" } diff --git a/variables.tf b/variables.tf index 356c0f6..7346148 100644 --- a/variables.tf +++ b/variables.tf @@ -9,13 +9,8 @@ variable "create_rest_vpc_links" { variable "rest_vpc_links" { description = "Map of objects that define the vpc links that get created." - type = list(object( - { - name = string - description = string - target_arns = list(string) - } - )) + type = any + default = [] } #################################### @@ -29,13 +24,8 @@ variable "create_http_vpc_links" { variable "http_vpc_links" { description = "Map of objects that define the vpc links that get created." - type = list(object( - { - name = string - security_group_ids = list(string) - subnet_ids = list(string) - } - )) + type = any + default = [] } variable "tags" {