terraform-aws-modules / terraform-aws-apigateway-v2

Terraform module to create AWS API Gateway v2 (HTTP/WebSocket) 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/apigateway-v2/aws
Apache License 2.0
148 stars 200 forks source link

Suppporting authorization_scopes #61

Closed oulman closed 2 years ago

oulman commented 2 years ago

Is your request related to a new offering from AWS?

No

Describe the solution you'd like.

17 added support for authorization_type and authorizer_id but left a commented out block for authorization_scopes. I started digging into seeing what it might take to enable that an ran into a problem since var.integrations is defined as a map(any) and Terraform is erroring with a type constraint because authorization_scopes wants a set of strings.

Looking over the documentation around map(any) it's not obvious to me how to pass in a set via the integrations map without violating the type constraint but perhaps I'm misunderstanding the problem. I started to work on a fork with a var integrations type = map(object({})) but I wanted to reach out here to see what the projects thoughts were on supporting authorization_scopes first.

Thank you!

Additional context

 Error: Invalid value for module argument
│ 
│   on apigw.tf line 27, in module "api_gateway":
│   27:   integrations = {
│   28:     "POST /status" = {
│   29:       lambda_arn             = data.aws_lambda_function.start_status.arn
│   30:       payload_format_version = "2.0"
│   31:       authorization_type     = "JWT"
│   32:       authorizer_id          = aws_apigatewayv2_authorizer.azuread.id
│   33:       authorization_scopes   = toset(["access_as_user"])
│   34:     }
│   35:     "POST /execute" = {
│   36:       integration_type    = "AWS_PROXY"
│   37:       integration_subtype = "StepFunctions-StartExecution"
│   38:       credentials_arn     = data.aws_iam_role.sfn_start_role.arn
│   39:       # Note: jsonencode is used to pass argument as a string
│   40:       request_parameters = jsonencode({
│   41:         StateMachineArn = data.aws_sfn_state_machine.start.arn
│   42:         Input           = "\"{\"environment\": \"${var.stage}\"}\""
│   43:       })
│   44:       payload_format_version = "1.0"
│   45:       timeout_milliseconds   = 12000
│   46:     }
│   47:   }
│ 
│ The given value is not suitable for child module variable "integrations" defined at .terraform/modules/api_gateway/variables.tf:191,1-24: attribute types must all match for conversion to map.
github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] commented 2 years ago

This issue was automatically closed because of stale in 10 days

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

antonbabenko commented 3 months ago

This issue has been resolved in version 5.0.0 :tada: