Skip to content

Commit 4d58196

Browse files
committed
fix: Step function execution of example works
1 parent 7ae31f3 commit 4d58196

File tree

6 files changed

+63
-30
lines changed

6 files changed

+63
-30
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ terraform.rc
3131
# Zip archive
3232
*.zip
3333
builds
34+
35+
.DS_Store

examples/complete-http/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ Note that this example may create resources which cost money. Run `terraform des
7070
| <a name="output_domain_name_hosted_zone_id"></a> [domain\_name\_hosted\_zone\_id](#output\_domain\_name\_hosted\_zone\_id) | The Amazon Route 53 Hosted Zone ID of the endpoint |
7171
| <a name="output_domain_name_id"></a> [domain\_name\_id](#output\_domain\_name\_id) | The domain name identifier |
7272
| <a name="output_domain_name_target_domain_name"></a> [domain\_name\_target\_domain\_name](#output\_domain\_name\_target\_domain\_name) | The target domain name |
73-
| <a name="output_integrations"></a> [integrations](#output\_integrations) | Map of the integrations created and their attributes |
74-
| <a name="output_routes"></a> [routes](#output\_routes) | Map of the routes created and their attributes |
7573
| <a name="output_stage_access_logs_cloudwatch_log_group_arn"></a> [stage\_access\_logs\_cloudwatch\_log\_group\_arn](#output\_stage\_access\_logs\_cloudwatch\_log\_group\_arn) | Arn of cloudwatch log group created |
7674
| <a name="output_stage_access_logs_cloudwatch_log_group_name"></a> [stage\_access\_logs\_cloudwatch\_log\_group\_name](#output\_stage\_access\_logs\_cloudwatch\_log\_group\_name) | Name of cloudwatch log group created |
7775
| <a name="output_stage_arn"></a> [stage\_arn](#output\_stage\_arn) | The stage ARN |

examples/complete-http/main.tf

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ module "api_gateway" {
109109
# Note: jsonencode is used to pass argument as a string
110110
request_parameters = jsonencode({
111111
StateMachineArn = module.step_function.state_machine_arn
112+
Input = jsonencode({
113+
"key1" : "value1",
114+
"key2" : "value2"
115+
})
112116
})
113117

114118
payload_format_version = "1.0"
@@ -143,7 +147,23 @@ module "api_gateway" {
143147
stage_access_log_settings = {
144148
create_log_group = true
145149
log_group_retention_in_days = 7
146-
format = "$context.identity.sourceIp - - [$context.requestTime] \"$context.httpMethod $context.routeKey $context.protocol\" $context.status $context.responseLength $context.requestId $context.integrationErrorMessage"
150+
format = jsonencode({
151+
"requestId" : "$context.requestId",
152+
"extendedRequestId" : "$context.extendedRequestId",
153+
"ip" : "$context.identity.sourceIp",
154+
"caller" : "$context.identity.caller",
155+
"user" : "$context.identity.user",
156+
"requestTime" : "$context.requestTime",
157+
"httpMethod" : "$context.httpMethod",
158+
"resourcePath" : "$context.resourcePath",
159+
"status" : "$context.status",
160+
"protocol" : "$context.protocol",
161+
"responseLength" : "$context.responseLength",
162+
"domainName" : "$context.domainName",
163+
"errorMessage" : "$context.error.message",
164+
"errorResponseType" : "$context.error.responseType",
165+
"integrationErrorMessage" : "$context.integrationErrorMessage",
166+
})
147167
}
148168

149169
stage_default_route_settings = {
@@ -171,24 +191,35 @@ module "step_function" {
171191

172192
name = local.name
173193
role_name = "${local.name}-step-function"
194+
trusted_entities = [
195+
"apigateway.amazonaws.com",
196+
"lambda.amazonaws.com",
197+
]
198+
199+
attach_policies_for_integrations = true
200+
service_integrations = {
201+
stepfunction = {
202+
stepfunction = ["*"]
203+
}
204+
}
174205

175206
definition = <<-EOT
176-
{
177-
"Comment": "A Hello World example of the Amazon States Language using Pass states",
178-
"StartAt": "Hello",
179-
"States": {
180-
"Hello": {
181-
"Type": "Pass",
182-
"Result": "Hello",
183-
"Next": "World"
184-
},
185-
"World": {
186-
"Type": "Pass",
187-
"Result": "World",
188-
"End": true
207+
{
208+
"Comment": "A Hello World example of the Amazon States Language using Pass states",
209+
"StartAt": "Hello",
210+
"States": {
211+
"Hello": {
212+
"Type": "Pass",
213+
"Result": "Hello",
214+
"Next": "World"
215+
},
216+
"World": {
217+
"Type": "Pass",
218+
"Result": "World",
219+
"End": true
220+
}
189221
}
190222
}
191-
}
192223
EOT
193224

194225
tags = local.tags
@@ -206,6 +237,8 @@ module "lambda_function" {
206237
publish = true
207238
source_path = "lambda.py"
208239

240+
cloudwatch_logs_retention_in_days = 7
241+
209242
allowed_triggers = {
210243
AllowExecutionFromAPIGateway = {
211244
service = "apigateway"

examples/complete-http/outputs.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,19 @@ output "acm_certificate_arn" {
7878
# Integration(s)
7979
################################################################################
8080

81-
output "integrations" {
82-
description = "Map of the integrations created and their attributes"
83-
value = module.api_gateway.integrations
84-
}
81+
# output "integrations" {
82+
# description = "Map of the integrations created and their attributes"
83+
# value = module.api_gateway.integrations
84+
# }
8585

8686
################################################################################
8787
# Route(s)
8888
################################################################################
8989

90-
output "routes" {
91-
description = "Map of the routes created and their attributes"
92-
value = module.api_gateway.routes
93-
}
90+
# output "routes" {
91+
# description = "Map of the routes created and their attributes"
92+
# value = module.api_gateway.routes
93+
# }
9494

9595
################################################################################
9696
# Stage

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ resource "aws_apigatewayv2_stage" "this" {
286286
data_trace_enabled = local.is_websocket ? try(default_route_settings.value.data_trace_enabled, false) : null
287287
detailed_metrics_enabled = try(default_route_settings.value.detailed_metrics_enabled, false)
288288
logging_level = local.is_websocket ? try(default_route_settings.value.logging_level, null) : null
289-
throttling_burst_limit = try(default_route_settings.value.throttling_burst_limit, null)
290-
throttling_rate_limit = try(default_route_settings.value.throttling_rate_limit, null)
289+
throttling_burst_limit = try(default_route_settings.value.throttling_burst_limit, 500)
290+
throttling_rate_limit = try(default_route_settings.value.throttling_rate_limit, 1000)
291291
}
292292
}
293293

@@ -302,8 +302,8 @@ resource "aws_apigatewayv2_stage" "this" {
302302
detailed_metrics_enabled = try(route_settings.value.detailed_metrics_enabled, false)
303303
logging_level = local.is_websocket ? try(route_settings.value.logging_level, null) : null
304304
route_key = route_settings.key
305-
throttling_burst_limit = try(route_settings.value.throttling_burst_limit, null)
306-
throttling_rate_limit = try(route_settings.value.throttling_rate_limit, null)
305+
throttling_burst_limit = try(route_settings.value.throttling_burst_limit, 500)
306+
throttling_rate_limit = try(route_settings.value.throttling_rate_limit, 1000)
307307
}
308308
}
309309

wrappers/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ module "wrapper" {
3838
subdomain = try(each.value.subdomain, var.defaults.subdomain, null)
3939
tags = try(each.value.tags, var.defaults.tags, {})
4040
target = try(each.value.target, var.defaults.target, null)
41-
vpc_links = try(each.value.vpc_links, var.defaults.vpc_links, {})
4241
vpc_link_tags = try(each.value.vpc_link_tags, var.defaults.vpc_link_tags, {})
42+
vpc_links = try(each.value.vpc_links, var.defaults.vpc_links, {})
4343
}

0 commit comments

Comments
 (0)