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
144 stars 186 forks source link

New Cyclical references #107

Open PaulG77 opened 2 weeks ago

PaulG77 commented 2 weeks ago

I have a terraform solution which consists of: -

The S3 bucket website and api gateway sit on cloudfront using the cloudfront module: _

    s3_oac = {
      domain_name = "${module.test.s3_bucket_website_endpoint}"

.... and ...

    apigateway = {
      domain_name = "${module.api_gateway.stage_domain_name}" 
    //previously  domain_name = ${module.api_gateway.default_apigatewayv2_stage_domain_name}"

Meanwhile the callback Urls used in the cognito resource are configured with the following callback URLs: -

  callback_urls = [
    format("https://%s/Authentication",module.cdn.cloudfront_distribution_domain_name )]
  logout_urls   = [
    format("https://%s/Logout",module.cdn.cloudfront_distribution_domain_name )]

Finally API gateway using this module references cognitio: -

  authorizers = {
    "cognito" = {
      authorizer_type  = "JWT"
      identity_sources = ["$request.header.Authorization"]
      name             = "Cognito"
      jwt_configuration = {
        audience         =  [resource.aws_cognito_user_pool_client.test.id]
        issuer           = "https://${resource.aws_cognito_user_pool.test.endpoint}"
      }
    }
  }

This all worked in the previous version of the module. However, with version 5, I'm now getting a circular reference as below: -

β”‚ Error: Cycle: module.api_gateway.aws_apigatewayv2_route_response.this, module.api_gateway.aws_apigatewayv2_deployment.this, module.cdn.output.cloudfront_distribution_domain_name (expand), aws_cognito_user_pool_client.test, module.api_gateway.cognito (expand), module.api_gateway.aws_apigatewayv2_authorizer.this, module.api_gateway.aws_apigatewayv2_route.this, module.api_gateway.aws_apigatewayv2_stage.this, module.api_gateway.output.stage_domain_name (expand), module.cdn.var.origin (expand), module.cdn.aws_cloudfront_distribution.this

carpusherw commented 1 week ago

I also bumped into the cycle error although with different resources. It happens to be that I didn't update all the output references. You could double check if that's also the case for you. Please reference https://github.com/terraform-aws-modules/terraform-aws-apigateway-v2/blob/v5.0.0/UPGRADE-5.0.md#variable-and-output-changes