Skip to content

Commit 26859db

Browse files
thenomantonbabenko
andauthored
feat!: Added the fail_on_warnings variable, bumped Terraform version to 1.0+ (#96)
Co-authored-by: Anton Babenko <anton@antonbabenko.com>
1 parent dd6826c commit 26859db

16 files changed

+264
-85
lines changed

.pre-commit-config.yaml

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.77.0
3+
rev: v1.86.0
44
hooks:
55
- id: terraform_fmt
6+
- id: terraform_wrapper_module_for_each
67
- id: terraform_validate
78
- id: terraform_docs
89
args:
9-
- '--args=--lockfile=false'
10+
- "--args=--lockfile=false"
1011
- id: terraform_tflint
1112
args:
12-
- '--args=--only=terraform_deprecated_interpolation'
13-
- '--args=--only=terraform_deprecated_index'
14-
- '--args=--only=terraform_unused_declarations'
15-
- '--args=--only=terraform_comment_syntax'
16-
- '--args=--only=terraform_documented_outputs'
17-
- '--args=--only=terraform_documented_variables'
18-
- '--args=--only=terraform_typed_variables'
19-
- '--args=--only=terraform_module_pinned_source'
20-
- '--args=--only=terraform_naming_convention'
21-
- '--args=--only=terraform_required_version'
22-
- '--args=--only=terraform_required_providers'
23-
- '--args=--only=terraform_standard_module_structure'
24-
- '--args=--only=terraform_workspace_remote'
13+
- "--args=--only=terraform_deprecated_interpolation"
14+
- "--args=--only=terraform_deprecated_index"
15+
- "--args=--only=terraform_unused_declarations"
16+
- "--args=--only=terraform_comment_syntax"
17+
- "--args=--only=terraform_documented_outputs"
18+
- "--args=--only=terraform_documented_variables"
19+
- "--args=--only=terraform_typed_variables"
20+
- "--args=--only=terraform_module_pinned_source"
21+
- "--args=--only=terraform_naming_convention"
22+
- "--args=--only=terraform_required_version"
23+
- "--args=--only=terraform_required_providers"
24+
- "--args=--only=terraform_standard_module_structure"
25+
- "--args=--only=terraform_workspace_remote"
2526
- repo: https://github.com/pre-commit/pre-commit-hooks
26-
rev: v4.4.0
27+
rev: v4.5.0
2728
hooks:
2829
- id: check-merge-conflict
2930
- id: end-of-file-fixer

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module "api_gateway" {
109109

110110
| Name | Version |
111111
|------|---------|
112-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
112+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
113113
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0 |
114114

115115
## Providers
@@ -162,6 +162,7 @@ No modules.
162162
| <a name="input_domain_name_certificate_arn"></a> [domain\_name\_certificate\_arn](#input\_domain\_name\_certificate\_arn) | The ARN of an AWS-managed certificate that will be used by the endpoint for the domain name | `string` | `null` | no |
163163
| <a name="input_domain_name_ownership_verification_certificate_arn"></a> [domain\_name\_ownership\_verification\_certificate\_arn](#input\_domain\_name\_ownership\_verification\_certificate\_arn) | ARN of the AWS-issued certificate used to validate custom domain ownership (when certificate\_arn is issued via an ACM Private CA or mutual\_tls\_authentication is configured with an ACM-imported certificate.) | `string` | `null` | no |
164164
| <a name="input_domain_name_tags"></a> [domain\_name\_tags](#input\_domain\_name\_tags) | A mapping of tags to assign to API domain name resource. | `map(string)` | `{}` | no |
165+
| <a name="input_fail_on_warnings"></a> [fail\_on\_warnings](#input\_fail\_on\_warnings) | Whether warnings should return an error while API Gateway is creating or updating the resource using an OpenAPI specification. Defaults to false. Applicable for HTTP APIs. | `bool` | `false` | no |
165166
| <a name="input_integrations"></a> [integrations](#input\_integrations) | Map of API gateway routes with integrations | `map(any)` | `{}` | no |
166167
| <a name="input_mutual_tls_authentication"></a> [mutual\_tls\_authentication](#input\_mutual\_tls\_authentication) | An Amazon S3 URL that specifies the truststore for mutual TLS authentication as well as version, keyed at uri and version | `map(string)` | `{}` | no |
167168
| <a name="input_name"></a> [name](#input\_name) | The name of the API | `string` | `""` | no |

examples/complete-http/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Note that this example may create resources which cost money. Run `terraform des
2020

2121
| Name | Version |
2222
|------|---------|
23-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
23+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
2424
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0 |
2525
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |
2626
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |

examples/complete-http/main.tf

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ provider "aws" {
22
region = "eu-west-1"
33

44
# Make it faster by skipping something
5-
skip_get_ec2_platforms = true
65
skip_metadata_api_check = true
76
skip_region_validation = true
87
skip_credentials_validation = true
@@ -27,6 +26,8 @@ module "api_gateway" {
2726
description = "My awesome HTTP API Gateway"
2827
protocol_type = "HTTP"
2928

29+
fail_on_warnings = false
30+
3031
cors_configuration = {
3132
allow_headers = ["content-type", "x-amz-date", "authorization", "x-api-key", "x-amz-security-token", "x-amz-user-agent"]
3233
allow_methods = ["*"]

examples/complete-http/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 0.13.1"
2+
required_version = ">= 1.0"
33

44
required_providers {
55
aws = {

examples/vpc-link-http/README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Note that this example may create resources which cost money. Run `terraform des
2020

2121
| Name | Version |
2222
|------|---------|
23-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
23+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
2424
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0 |
2525
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |
2626
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |
@@ -36,13 +36,12 @@ Note that this example may create resources which cost money. Run `terraform des
3636

3737
| Name | Source | Version |
3838
|------|--------|---------|
39-
| <a name="module_alb"></a> [alb](#module\_alb) | terraform-aws-modules/alb/aws | ~> 6.0 |
40-
| <a name="module_alb_security_group"></a> [alb\_security\_group](#module\_alb\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
39+
| <a name="module_alb"></a> [alb](#module\_alb) | terraform-aws-modules/alb/aws | ~> 9.0 |
4140
| <a name="module_api_gateway"></a> [api\_gateway](#module\_api\_gateway) | ../../ | n/a |
42-
| <a name="module_api_gateway_security_group"></a> [api\_gateway\_security\_group](#module\_api\_gateway\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
43-
| <a name="module_lambda_function"></a> [lambda\_function](#module\_lambda\_function) | terraform-aws-modules/lambda/aws | ~> 2.0 |
44-
| <a name="module_lambda_security_group"></a> [lambda\_security\_group](#module\_lambda\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
45-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 |
41+
| <a name="module_api_gateway_security_group"></a> [api\_gateway\_security\_group](#module\_api\_gateway\_security\_group) | terraform-aws-modules/security-group/aws | ~> 5.0 |
42+
| <a name="module_lambda_function"></a> [lambda\_function](#module\_lambda\_function) | terraform-aws-modules/lambda/aws | ~> 7.0 |
43+
| <a name="module_lambda_security_group"></a> [lambda\_security\_group](#module\_lambda\_security\_group) | terraform-aws-modules/security-group/aws | ~> 5.0 |
44+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
4645

4746
## Resources
4847

examples/vpc-link-http/main.tf

+67-56
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ provider "aws" {
66
region = local.region
77

88
# Make it faster by skipping something
9-
skip_get_ec2_platforms = true
109
skip_metadata_api_check = true
1110
skip_region_validation = true
1211
skip_credentials_validation = true
@@ -15,29 +14,6 @@ provider "aws" {
1514
skip_requesting_account_id = false
1615
}
1716

18-
################################
19-
# Supporting resources
20-
################################
21-
22-
resource "random_pet" "this" {
23-
length = 2
24-
}
25-
26-
module "vpc" {
27-
source = "terraform-aws-modules/vpc/aws"
28-
version = " ~> 3.0"
29-
30-
name = "vpc-link-http"
31-
cidr = "10.0.0.0/16"
32-
33-
azs = ["${local.region}a", "${local.region}b", "${local.region}c"]
34-
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
35-
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
36-
37-
enable_nat_gateway = false
38-
single_nat_gateway = true
39-
}
40-
4117
###################
4218
# HTTP API Gateway
4319
###################
@@ -67,7 +43,7 @@ module "api_gateway" {
6743
"GET /alb-internal-route" = {
6844
connection_type = "VPC_LINK"
6945
vpc_link = "my-vpc"
70-
integration_uri = module.alb.http_tcp_listener_arns[0]
46+
integration_uri = module.alb.listeners["default"].arn
7147
integration_type = "HTTP_PROXY"
7248
integration_method = "ANY"
7349
}
@@ -90,9 +66,32 @@ module "api_gateway" {
9066
}
9167
}
9268

69+
################################
70+
# Supporting resources
71+
################################
72+
73+
resource "random_pet" "this" {
74+
length = 2
75+
}
76+
77+
module "vpc" {
78+
source = "terraform-aws-modules/vpc/aws"
79+
version = "~> 5.0"
80+
81+
name = "vpc-link-http"
82+
cidr = "10.0.0.0/16"
83+
84+
azs = ["${local.region}a", "${local.region}b", "${local.region}c"]
85+
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
86+
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
87+
88+
enable_nat_gateway = false
89+
single_nat_gateway = true
90+
}
91+
9392
module "api_gateway_security_group" {
9493
source = "terraform-aws-modules/security-group/aws"
95-
version = "~> 4.0"
94+
version = "~> 5.0"
9695

9796
name = "api-gateway-sg-${random_pet.this.id}"
9897
description = "API Gateway group for example usage"
@@ -111,43 +110,55 @@ module "api_gateway_security_group" {
111110

112111
module "alb" {
113112
source = "terraform-aws-modules/alb/aws"
114-
version = "~> 6.0"
113+
version = "~> 9.0"
115114

116115
name = "alb-${random_pet.this.id}"
117116

118-
vpc_id = module.vpc.vpc_id
119-
security_groups = [module.alb_security_group.security_group_id]
120-
subnets = module.vpc.public_subnets
117+
vpc_id = module.vpc.vpc_id
118+
subnets = module.vpc.public_subnets
121119

122-
http_tcp_listeners = [
123-
{
124-
port = 80
125-
protocol = "HTTP"
126-
target_group_index = 0
127-
action_type = "forward"
120+
security_group_ingress_rules = {
121+
all_http = {
122+
from_port = 80
123+
to_port = 80
124+
ip_protocol = "tcp"
125+
description = "HTTP web traffic"
126+
cidr_ipv4 = "0.0.0.0/0"
128127
}
129-
]
130-
131-
target_groups = [
132-
{
133-
name_prefix = "l1-"
134-
target_type = "lambda"
128+
all_https = {
129+
from_port = 443
130+
to_port = 443
131+
ip_protocol = "tcp"
132+
description = "HTTPS web traffic"
133+
cidr_ipv4 = "0.0.0.0/0"
135134
}
136-
]
137-
}
138-
139-
module "alb_security_group" {
140-
source = "terraform-aws-modules/security-group/aws"
141-
version = "~> 4.0"
135+
}
142136

143-
name = "alb-sg-${random_pet.this.id}"
144-
description = "ALB for example usage"
145-
vpc_id = module.vpc.vpc_id
137+
security_group_egress_rules = {
138+
all = {
139+
ip_protocol = "-1"
140+
cidr_ipv4 = module.vpc.vpc_cidr_block
141+
}
142+
}
146143

147-
ingress_cidr_blocks = ["0.0.0.0/0"]
148-
ingress_rules = ["http-80-tcp"]
144+
listeners = {
145+
default = {
146+
port = 80
147+
protocol = "HTTP"
148+
forward = {
149+
target_group_key = "lambda"
150+
}
151+
}
152+
}
149153

150-
egress_rules = ["all-all"]
154+
target_groups = {
155+
lambda = {
156+
name_prefix = "l1-"
157+
target_type = "lambda"
158+
target_id = module.lambda_function.lambda_function_arn
159+
attach_lambda_permission = true
160+
}
161+
}
151162
}
152163

153164

@@ -172,7 +183,7 @@ resource "null_resource" "download_package" {
172183

173184
module "lambda_function" {
174185
source = "terraform-aws-modules/lambda/aws"
175-
version = "~> 2.0"
186+
version = "~> 7.0"
176187

177188
function_name = "${random_pet.this.id}-lambda"
178189
description = "My awesome lambda function"
@@ -198,7 +209,7 @@ module "lambda_function" {
198209

199210
module "lambda_security_group" {
200211
source = "terraform-aws-modules/security-group/aws"
201-
version = "~> 4.0"
212+
version = "~> 5.0"
202213

203214
name = "lambda-sg-${random_pet.this.id}"
204215
description = "Lambda security group for example usage"

examples/vpc-link-http/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 0.13.1"
2+
required_version = ">= 1.0"
33

44
required_providers {
55
aws = {

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ resource "aws_apigatewayv2_api" "this" {
1111
route_selection_expression = var.route_selection_expression
1212
api_key_selection_expression = var.api_key_selection_expression
1313
disable_execute_api_endpoint = var.disable_execute_api_endpoint
14+
fail_on_warnings = var.fail_on_warnings
1415

1516
/* Start of quick create */
1617
route_key = var.route_key

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ variable "disable_execute_api_endpoint" {
7777
default = false
7878
}
7979

80+
variable "fail_on_warnings" {
81+
description = "Whether warnings should return an error while API Gateway is creating or updating the resource using an OpenAPI specification. Defaults to false. Applicable for HTTP APIs."
82+
type = bool
83+
default = false
84+
}
85+
8086
variable "protocol_type" {
8187
description = "The API protocol. Valid values: HTTP, WEBSOCKET"
8288
type = string

versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 0.13.1"
2+
required_version = ">= 1.0"
33

44
required_providers {
55
aws = {

0 commit comments

Comments
 (0)