-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sudoblark/feature/initial-setup
Initial module setup
- Loading branch information
Showing
16 changed files
with
1,167 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
locals { | ||
actual_api_keys = flatten([ | ||
for api in var.raw_api_gateway_rest_apis : [ | ||
for key in api.api_keys : { | ||
api = api.suffix | ||
name = format("%s/%s", api.suffix, key) | ||
} | ||
] | ||
]) | ||
} | ||
|
||
resource "aws_api_gateway_api_key" "api_keys" { | ||
for_each = { for key in local.actual_api_keys : key.name => key } | ||
|
||
name = each.value["name"] | ||
description = format("Automatically generated key for %s API Gateway - managed by Terraform", each.value["api"]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
resource "aws_api_gateway_deployment" "deployments" { | ||
for_each = { for api in local.actual_raw_api_gateway_rest_apis : api.suffix => api } | ||
|
||
rest_api_id = aws_api_gateway_rest_api.api_gateway[each.value["suffix"]].id | ||
triggers = { | ||
redeployment = sha1(jsonencode(aws_api_gateway_rest_api.api_gateway[each.value["suffix"]].body)) | ||
} | ||
|
||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
|
||
depends_on = [ | ||
aws_api_gateway_rest_api.api_gateway | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
resource "aws_api_gateway_stage" "stages" { | ||
for_each = { for api in local.actual_raw_api_gateway_rest_apis : api.suffix => api } | ||
|
||
deployment_id = aws_api_gateway_deployment.deployments[each.value["suffix"]].id | ||
rest_api_id = aws_api_gateway_rest_api.api_gateway[each.value["suffix"]].id | ||
stage_name = var.environment | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
resource "aws_api_gateway_usage_plan" "usage_plans" { | ||
for_each = { for api in local.actual_raw_api_gateway_rest_apis : api.suffix => api } | ||
|
||
name = format("%s-usage-plan", each.value["suffix"]) | ||
description = format("API Gateway usage plan for %s - managed by Terraform", each.value["suffix"]) | ||
|
||
api_stages { | ||
api_id = aws_api_gateway_rest_api.api_gateway[each.value["suffix"]].id | ||
stage = aws_api_gateway_stage.stages[each.value["suffix"]].stage_name | ||
} | ||
|
||
quota_settings { | ||
limit = try(each.value["quota_limit"], 10) | ||
offset = try(each.value["quota_offset"], 0) | ||
period = try(each.value["quota_period"], "DAY") | ||
} | ||
|
||
throttle_settings { | ||
burst_limit = try(each.value["burst_limit"], 5) | ||
rate_limit = try(each.value["rate_limit"], 10) | ||
} | ||
|
||
depends_on = [ | ||
aws_api_gateway_rest_api.api_gateway, | ||
aws_api_gateway_stage.stages | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
resource "aws_api_gateway_usage_plan_key" "keys" { | ||
for_each = { for key in local.actual_api_keys : key.name => key } | ||
|
||
key_id = aws_api_gateway_api_key.api_keys[each.value["name"]].id | ||
key_type = "API_KEY" | ||
usage_plan_id = aws_api_gateway_usage_plan.usage_plans[each.value["api"]].id | ||
|
||
depends_on = [ | ||
aws_api_gateway_usage_plan.usage_plans, | ||
aws_api_gateway_api_key.api_keys | ||
] | ||
} |
Oops, something went wrong.