terraform-aws-next-js
terraform-aws-next-js copied to clipboard
terraform Apply is failed with basePath
I have added basePath in next.config.js as "/my-app". And after when I deploy the app then getting this error-
[31m│[0m [0m [31m│[0m [0m[0m with module.tf_next.aws_iam_role.lambda["my-app/__NEXT_PAGE_LAMBDA_0"], [31m│[0m [0m on ../original_source/iam.tf line 20, in resource "aws_iam_role" "lambda": [31m│[0m [0m 20: name = [4m"${var.deployment_name}_${each.key}"[0m[0m [31m│[0m [0m [31m[0m[0m [31m[0m[0m [31m│[0m [0m[1m[31mError: [0m[0m[1m"function_name" doesn't comply with restrictions ("^(arn:[\\w-]+:lambda:)?([a-z]{2}-(?:[a-z]+-){1,2}\\d{1}:)?(\\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\\$LATEST|[a-zA-Z0-9-_]+))?$"): "my-deployment-name_my-app/__NEXT_PAGE_LAMBDA_0"[0m [31m│[0m [0m [31m│[0m [0m[0m with module.tf_next.aws_lambda_permission.current_version_triggers["my-app/__NEXT_PAGE_LAMBDA_0"], [31m│[0m [0m on ../original_source/main.tf line 96, in resource "aws_lambda_permission" "current_version_triggers": [31m│[0m [0m 96: function_name = [4m"${var.deployment_name}_${each.key}"[0m[0m
It works fine without basePath. I think the problem is with the forward-slash which is appended after my-app. Do you have any suggestions?
Yes, seems like the basePath
setting creates invalid function names since it prefixes the basePath.
Need to take a look how this could be solved.
I am thinking to use replace function in Terraform which will replace the forward slash with an underscore. I will create a PR if this works.
We are seeing this issue as well. @sumantapakira did you end up making a PR?