Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: aws_apigatewayv2_api.body not setting CORS using OAS30 extension x-amazon-apigateway-cors #33390

Open
garysassano opened this issue Sep 10, 2023 · 4 comments
Labels
bug Addresses a defect in current functionality. service/apigatewayv2 Issues and PRs that pertain to the apigatewayv2 service.

Comments

@garysassano
Copy link
Contributor

garysassano commented Sep 10, 2023

Terraform Core Version

1.5.2

AWS Provider Version

4.65.0

Affected Resource(s)

If you import OAS30 in your aws_apigatewayv2_api.body and you specified x-amazon-apigateway-cors in your OAS30 definition, Terraform ignores it and won't set the defined CORS settings.

Expected Behavior

I expected Terraform to appy the CORS settings defined by x-amazon-apigateway-cors in the OAS30 definition.

Actual Behavior

Terraform ignores the x-amazon-apigateway-cors field specified in your OAS30 definition and won't set the related CORS settings to your aws_apigatewayv2_api resource, thus forcing you to use the cors_configuration argument.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

{
  "//": {
    "metadata": {
      "backend": "local",
      "stackName": "root",
      "version": "0.17.0"
    },
    "outputs": {
      "root": {
        "Default": {
          "cloud.TestRunner": {
            "TestFunctionArns": "WING_TEST_RUNNER_FUNCTION_ARNS"
          }
        }
      }
    }
  },
  "data": {
    "aws_region": {
      "Region": {
        "//": {
          "metadata": {
            "path": "root/Default/Region",
            "uniqueId": "Region"
          }
        }
      }
    }
  },
  "output": {
    "WING_TEST_RUNNER_FUNCTION_ARNS": {
      "value": "[]"
    }
  },
  "provider": {
    "aws": [{}]
  },
  "resource": {
    "aws_apigatewayv2_api": {
      "cloudApi_api_2B334D75": {
        "//": {
          "metadata": {
            "path": "root/Default/Default/cloud.Api/api/api",
            "uniqueId": "cloudApi_api_2B334D75"
          }
        },
        "body": "{\"openapi\":\"3.0.1\",\"info\":{\"title\":\"foo\",\"version\":\"2023-09-10 04:19:34UTC\"},\"servers\":[{\"url\":\"https://8xmxvgtxqc.execute-api.eu-central-1.amazonaws.com/{basePath}\",\"variables\":{\"basePath\":{\"default\":\"\"}}}],\"paths\":{\"/$default\":{\"x-amazon-apigateway-any-method\":{\"isDefaultRoute\":true,\"x-amazon-apigateway-integration\":{\"payloadFormatVersion\":\"1.0\",\"type\":\"http_proxy\",\"httpMethod\":\"ANY\",\"uri\":\"https://example.com/\",\"connectionType\":\"INTERNET\"}}}},\"x-amazon-apigateway-importexport-version\":\"1.0\"}",
        "name": "api-c895068c",
        "protocol_type": "HTTP"
      }
    },
    "aws_apigatewayv2_stage": {
      "cloudApi_api_stage_BBB283E4": {
        "//": {
          "metadata": {
            "path": "root/Default/Default/cloud.Api/api/stage",
            "uniqueId": "cloudApi_api_stage_BBB283E4"
          }
        },
        "api_id": "${aws_apigatewayv2_api.cloudApi_api_2B334D75.id}",
        "auto_deploy": true,
        "name": "$default"
      }
    }
  },
  "terraform": {
    "backend": {
      "local": {
        "path": "./terraform.tfstate"
      }
    },
    "required_providers": {
      "aws": {
        "source": "aws",
        "version": "4.65.0"
      }
    }
  }
}

Steps to Reproduce

terraform apply

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@garysassano garysassano added the bug Addresses a defect in current functionality. label Sep 10, 2023
@garysassano garysassano changed the title [Bug]: aws_apigatewayv2_api.body not setting CORS using x-amazon-apigateway-cors [Bug]: aws_apigatewayv2_api.body not setting CORS using OAS30 extension x-amazon-apigateway-cors Sep 10, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 10, 2023
@justinretzolk
Copy link
Member

Hey @garysassano 👋 Thank you for taking the time to raise this! Are you able to supply a sample Terraform configuration that can be used to reproduce this, as well as debug logs (redacted as needed)?

@justinretzolk justinretzolk added waiting-response Maintainers are waiting on response from community or contributor. service/apigatewayv2 Issues and PRs that pertain to the apigatewayv2 service. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 11, 2023
@garysassano
Copy link
Contributor Author

@justinretzolk I provided the Terraform configuration file in the original post. That Terraform is generated by some TypeScript code using CDKTF.

@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 11, 2023
@justinretzolk
Copy link
Member

Thanks for the quick follow up @garysassano, and sorry about that miss!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/apigatewayv2 Issues and PRs that pertain to the apigatewayv2 service.
Projects
None yet
Development

No branches or pull requests

2 participants