Skip to content

Commit 4cae93f

Browse files
author
Nikita Dugar
authored
Merge pull request #13 from clouddrove/CD-262
add new features
2 parents 15f7728 + b883108 commit 4cae93f

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

_example/basic/example.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ provider "aws" {
33
}
44

55
module "api-gateway" {
6-
source = "../../"
7-
name = "api-gateway"
8-
6+
source = "../../"
7+
name = "api-gateway"
98
repository = "https://registry.terraform.io/modules/clouddrove/api-gateway/aws/0.14.0"
109
environment = "test"
1110
label_order = ["name", "environment"]

_example/complete/example.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module "api-gateway" {
66
source = "../../"
77

88
name = "api-gateway"
9+
repository = "https://registry.terraform.io/modules/clouddrove/api-gateway/aws/0.14.0"
910
environment = "test"
1011
label_order = ["name", "environment"]
1112
enabled = true

main.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
module "labels" {
99
source = "git::https://github.com/clouddrove/terraform-labels.git?ref=tags/0.14.0"
1010

11+
enabled = var.enabled
1112
name = var.name
1213
repository = var.repository
1314
environment = var.environment
1415
managedby = var.managedby
15-
attributes = var.attributes
1616
label_order = var.label_order
17+
attributes = var.attributes
1718
}
1819

1920
# Module : Api Gateway
@@ -30,6 +31,7 @@ resource "aws_api_gateway_rest_api" "default" {
3031
endpoint_configuration {
3132
types = var.types
3233
}
34+
policy = var.api_policy
3335
}
3436

3537
# Module : Api Gateway Resource
@@ -51,7 +53,7 @@ resource "aws_api_gateway_model" "default" {
5153
description = length(var.model_descriptions) > 0 ? element(var.model_descriptions, count.index) : ""
5254
content_type = element(var.content_types, count.index)
5355

54-
schema = <<EOF
56+
schema = length(var.model_schemas) > 0 ? element(var.model_schemas, count.index) : <<EOF
5557
{"type":"object"}
5658
EOF
5759
}
@@ -65,7 +67,7 @@ resource "aws_api_gateway_method" "default" {
6567
resource_id = aws_api_gateway_resource.default.*.id[count.index]
6668
http_method = element(var.http_methods, count.index)
6769
authorization = length(var.authorizations) > 0 ? element(var.authorizations, count.index) : "NONE"
68-
authorizer_id = length(var.authorizer_ids) > 0 ? element(var.authorizer_ids, count.index) : null
70+
authorizer_id = length(var.authorizer_ids) > 0 ? element(var.authorizer_ids, count.index) : (var.authorizer_count > 0 ? aws_api_gateway_authorizer.default.*.id[count.index] : null)
6971
authorization_scopes = length(var.authorization_scopes) > 0 ? element(var.authorization_scopes, count.index) : null
7072
api_key_required = length(var.api_key_requireds) > 0 ? element(var.api_key_requireds, count.index) : null
7173
request_models = length(var.request_models) > 0 ? element(var.request_models, count.index) : { "application/json" = "Empty" }

variables.tf

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ variable "repository" {
1010
type = string
1111
default = ""
1212
description = "Terraform current module repo"
13+
14+
validation {
15+
# regex(...) fails if it cannot find a match
16+
condition = can(regex("^https://", var.repository))
17+
error_message = "The module-repo value must be a valid Git repo link."
18+
}
19+
1320
}
1421

1522
variable "environment" {
@@ -550,5 +557,14 @@ variable "values" {
550557
type = list(any)
551558
default = []
552559
description = "The value of the API key. If not specified, it will be automatically generated by AWS on creation."
553-
sensitive = true
560+
}
561+
562+
variable "api_policy" {
563+
default = null
564+
description = "The policy document."
565+
}
566+
567+
variable "model_schemas" {
568+
default = []
569+
description = "The schema of the model in a JSON form."
554570
}

0 commit comments

Comments
 (0)