Last active
March 15, 2020 17:59
-
-
Save abdrehma/2a55eef8ec0bf1021acb3bbbea514843 to your computer and use it in GitHub Desktop.
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
variable "apigw_map" { | |
description = "Map for APIGW Resources and Methods" | |
default = { | |
categories = { | |
GET = { | |
authorization = "NONE" | |
authorizer_id = "" | |
key_req = true | |
target_path = "categories" | |
} | |
PUT = { | |
authorization = "NONE" | |
authorizer_id = "" | |
key_req = true | |
target_path = "categories" | |
} | |
POST = { | |
authorization = "NONE" | |
authorizer_id = "" | |
key_req = true | |
target_path = "categories" | |
} | |
DELETE = { | |
authorization = "NONE" | |
authorizer_id = "" | |
key_req = true | |
target_path = "categories" | |
} | |
} | |
images = { | |
GET = { | |
authorization = "NONE" | |
authorizer_id = "" | |
key_req = true | |
target_path = "images" | |
} | |
PUT = { | |
authorization = "NONE" | |
authorizer_id = "" | |
key_req = true | |
target_path = "images" | |
} | |
POST = { | |
authorization = "NONE" | |
authorizer_id = "" | |
key_req = true | |
target_path = "images" | |
} | |
DELETE = { | |
authorization = "NONE" | |
authorizer_id = "" | |
key_req = true | |
target_path = "images" | |
} | |
} | |
} | |
} | |
locals { | |
intermediate = flatten([for key, dict in var.apigw_map: | |
[ for method, value in dict: | |
merge({"method"=method,"key"=key},value) | |
]]) | |
pseudo_dict = {for value in local.intermediate: | |
md5(jsonencode(value)) => value | |
} | |
} | |
output "Name" { | |
value = local.pseudo_dict | |
} | |
resource "null_resource" "example1" { | |
for_each = local.pseudo_dict | |
provisioner "local-exec" { | |
command = "echo key: ${each.value.key} method: ${each.value.method} target_path: ${each.value.target_path}" | |
} | |
} |
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
Apply complete! Resources: 0 added, 0 changed, 0 destroyed. | |
Outputs: | |
Name = { | |
"2db86378ea26681fc77563bb5d4f4dc4" = { | |
"authorization" = "NONE" | |
"authorizer_id" = "" | |
"key" = "categories" | |
"key_req" = true | |
"method" = "PUT" | |
"target_path" = "categories" | |
} | |
"7ee94572751da18716e4a93115b081c0" = { | |
"authorization" = "NONE" | |
"authorizer_id" = "" | |
"key" = "images" | |
"key_req" = true | |
"method" = "GET" | |
"target_path" = "images" | |
} | |
"9ce4a84d870991794a675e6113641dcc" = { | |
"authorization" = "NONE" | |
"authorizer_id" = "" | |
"key" = "images" | |
"key_req" = true | |
"method" = "DELETE" | |
"target_path" = "images" | |
} | |
"b46ccd6bae4c4e3c68e430abf62d8e95" = { | |
"authorization" = "NONE" | |
"authorizer_id" = "" | |
"key" = "categories" | |
"key_req" = true | |
"method" = "DELETE" | |
"target_path" = "categories" | |
} | |
"bbb3fc87571a1b24e4e50fc79a3d72c4" = { | |
"authorization" = "NONE" | |
"authorizer_id" = "" | |
"key" = "categories" | |
"key_req" = true | |
"method" = "POST" | |
"target_path" = "categories" | |
} | |
"dcf833fdfcd47001e3add967eba65606" = { | |
"authorization" = "NONE" | |
"authorizer_id" = "" | |
"key" = "images" | |
"key_req" = true | |
"method" = "PUT" | |
"target_path" = "images" | |
} | |
"f0528cb0f26c46cd4e65ee5bfe6af09c" = { | |
"authorization" = "NONE" | |
"authorizer_id" = "" | |
"key" = "images" | |
"key_req" = true | |
"method" = "POST" | |
"target_path" = "images" | |
} | |
"f46e1bed332223b42f1bfb3d143013d8" = { | |
"authorization" = "NONE" | |
"authorizer_id" = "" | |
"key" = "categories" | |
"key_req" = true | |
"method" = "GET" | |
"target_path" = "categories" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment