hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.78k stars 9.14k forks source link

[Bug]: Creation of FunctionURLAllowPublicAccess resource-based Lambda policy by the Terraform provider #38260

Open EreminAnton opened 3 months ago

EreminAnton commented 3 months ago

Terraform Core Version

v.1.7.4

AWS Provider Version

v5.55.0

Affected Resource(s)

aws_lambda_function_url

Expected Behavior

Provider should create lambda URL for the lambda

Actual Behavior

The provider creates a Lambda URL and a resource-based policy statement for the Lambda: FunctionURLAllowPublicAccess

I am unsure if creating a policy on a user's behalf is appropriate, and it isn't documented in the resource's documentation. Additionally, this resource-based policy persists even when the aws_lambda_function_url resource is deleted.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

# Lambda url configuration from the terraform-aws-lambda module. 
  create_lambda_function_url = true
  authorization_type = "NONE" # By default. and exactly this line will cause creation of a policy

  cors = {
    allow_credentials = true
    allow_origins     = ["https://slack.com"]
    allow_methods     = ["POST"]
    max_age           = 86400
  }

Steps to Reproduce

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

https://github.com/hashicorp/terraform-provider-aws/blob/main/internal/service/lambda/function_url.go#L153-L175

Would you like to implement a fix?

None

github-actions[bot] commented 3 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue