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

fix: load the file content instead of base64 encoded payload for uploading the zipfile in resource_alicloud_fc_layer_version.go #8391

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NIZ-elsevier
Copy link

@NIZ-elsevier NIZ-elsevier commented Feb 21, 2025

What's the problem?

With the current version, a FC layer can be created with a local zipfile, but the plugin is unable to do any follow-up terraform plan or terraform apply. In my testing ,my custom layer was only 1.2 MB, but still exceeding the grpc maximum input limit. I think it's because the provider plugin is trying to compare the encoded base64 contents. For a zipfile, it's payload can be incredibly large...

Error message:

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Plugin error
│
│   with module.ami-manager.alicloud_fc_layer_version.ecs_layer,
│   on ../../../core-alicloud-ami-manager/function.tf line 25, in resource "alicloud_fc_layer_version" "ecs_layer":
│   25: resource "alicloud_fc_layer_version" "ecs_layer" {
│
│ The plugin returned an unexpected error from plugin.(*GRPCProvider).PlanResourceChange: rpc error: code = ResourceExhausted desc = grpc: received message
│ larger than max (4706981 vs. 4194304)

How to reproduce the problem?

Create a resource as follows:

resource "alicloud_fc_layer_version" "ecs_layer" {
  layer_name         = "ecs_layer"
  description        = "A layer for python module alibabacloud_ecs20140526"
  compatible_runtime = ["python3.10"]
  zip_file           = filebase64("${path.module}/function_compute/alibabacloud_ecs20140526.zip")
}

My changes

As following the code block in the resource_alicloud_fc_function.go, I think it would be wise to use the same approach to load the content, rather than loading the raw payload of a zipfile. ref: https://github.com/aliyun/terraform-provider-alicloud/blob/master/alicloud/resource_alicloud_fc_function.go#L448-L453

Please verify my changes, or let me know how shall I test them properly. I can submit another change regarding the similar code block in resource resource_alicloud_fcv3_layer_version.go too if this is deemed good enough. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant