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

Create lambda integrations from a list #81

Closed lashawnta-pf closed 2 years ago

lashawnta-pf commented 2 years ago

Is your request related to a new offering from AWS?

Is your request related to a problem? Please describe.

Describe the solution you'd like.

A way to leverage a list to create the integration map entries.

Describe alternatives you've considered.

Additional context

Please feel free to provide feedback especially in the case that this is not a good idea.

antonbabenko commented 2 years ago

Hi @lashawnta-pf !

I think it is a good idea to be able to manage multiple integrations dynamically.

The easiest way to do this is like you described in "alternatives" - using for loop to create a map of integrations passed into this module here.

module "api_gateway" {
  source = "terraform-aws-modules/apigateway-v2/aws"

  integrations = { for k, v in {"ANY /" => "my-lambda1", "POST /new" => "my-lambda2"}:

    k = {
      lambda_arn             = v
      payload_format_version = "2.0"
      timeout_milliseconds   = 12000
    }
  }
}

Another approach can be to generate YAML/JSON OpenAPI spec file and pass it like this.

These solutions will work great when Lambda functions can be created in advance. If you want to manage Lambdas at the same, you may need to add depends_on on modules.

I don't know what else we can do in this module to make this support better than it is now.

lashawnta-pf commented 2 years ago

@antonbabenko Thank you so much for your fast response. I was hoping this would be possible. This issue can be closed.

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.