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

Max length char of 140 for layers arn in lambda update-function-configuration --layers command #8426

Open
gcontarini opened this issue Dec 22, 2023 · 1 comment
Labels
documentation This is a problem with documentation. feature-request A feature should be added or improved. lambda p3 This is a minor priority issue

Comments

@gcontarini
Copy link

Describe the bug

Cannot update the many layers from a lambda function using cli if more than one layer is used.
Also, cannot update layers incrementally since the command replaces all layers at once, so if the layer ARN is not provided it will be removed from the lambda.

Expected Behavior

Expected to all layers provided in the sequence to be added/updated to the function.

Current Behavior

The following error is shown:

An error occurred (ValidationException) when calling the UpdateFunctionConfiguration operation: 1 validation error detected: Value 'FULL_LAYER_ARN_1,FULL_LAYER_ARN_2' at 'layers' failed to satisfy constraint: Member must satisfy constraint: [Member must have length less than or equal to 140, Member must have length greater than or equal to 1, Member must satisfy regular expression pattern: (arn:[a-zA-Z0-9-]+:lambda:[a-zA-Z0-9-]+:\d{12}:layer:[a-zA-Z0-9-_]+:[0-9]+)|(arn:[a-zA-Z0-9-]+:lambda:::awslayer:[a-zA-Z0-9-_]+), Member must not be null]

Reproduction Steps

While trying to update the layers from a given lambda function with the following command:

aws lambda update-function-configuration --function-name FUNCTION_NAME --layers FULL_LAYER_ARN_1,FULL_LAYER_ARN_2

Use 2 or more layers in the same call and the error will show.

Possible Solution

Allow to use more than 140 chars in the layers parameter if the parameter is a comma separated value, meaning there are multiple layer ARNs being provided.

Additional Information/Context

No response

CLI version used

aws-cli/2.13.26

Environment details (OS name and version, etc.)

Python/3.11.6 Darwin/23.0.0 source/arm64

@gcontarini gcontarini added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 22, 2023
@tim-finnigan tim-finnigan self-assigned this Apr 8, 2024
@tim-finnigan tim-finnigan added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Apr 8, 2024
@tim-finnigan
Copy link
Contributor

tim-finnigan commented Apr 8, 2024

Hi @gcontarini - thanks for your patience here. The CLI update-function-config command corresponds to the Lambda UpdateFunctionConfig API. Therefore, any changes to the ARN validation requirements would need to be implemented by the Lambda service team (and then would be reflected in the AWS CLI/SDKs).

But in this case it appears that the input validation will fail with a comma-separated list even if each individual ARN or total length of ARNs is less than 140 chars. As an alternative, you can use the --cli-input-json parameter, for example:

aws lambda update-function-configuration \
    --function-name <function_name> \
    --cli-input-json '{"Layers": ["arn:aws:lambda:us-west-2:<account>:layer:<layer>:<version>", "arn:aws:lambda:us-west-2:<account>:layer:<layer>:<version>, "arn:aws:lambda:us-west-2:<account>:layer:<layer>:<version>"]}'

Maybe the CLI documentation could be improved here in regard to when --cli-input-json should be used versus a comma-separated list.

Edit: updating this to a feature request to improve the documentation here, specifically to have more visibility on when to use --cli-input-json. But as mentioned, the 140 length limit is imposed by the API:

image

@tim-finnigan tim-finnigan added documentation This is a problem with documentation. lambda p3 This is a minor priority issue and removed needs-triage This issue or PR still needs to be triaged. investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Apr 8, 2024
@tim-finnigan tim-finnigan removed their assignment Apr 8, 2024
@tim-finnigan tim-finnigan added feature-request A feature should be added or improved. and removed bug This issue is a bug. labels Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This is a problem with documentation. feature-request A feature should be added or improved. lambda p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

2 participants