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

[RunBook]: Migrate lambda function to gravitron2 processor #539

Open
1 task done
amit-chandak-unskript opened this issue Apr 26, 2023 · 4 comments
Open
1 task done

Comments

@amit-chandak-unskript
Copy link
Contributor

Contact Details

No response

RunBook Name

Migrate lambda function to gravitron2 processor

runbook Inputs

region, list of lambda function names

runBook Actions

#537

Comments

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@shloka-bhalgat-unskript
Copy link
Member

shloka-bhalgat-unskript commented Apr 26, 2023

@amit-chandak-unskript The command to update the configuration architecture for a non graviton2 processor is aws lambda update-function-code --function-name <function-name> --zip-file fileb://<path-to-zip-file>

We need a new zip file path of the arm64 compatible code. Once that is updated the new runtime architecture also get's updated. Since we don't have a way to upload files for a lego, I think we can contain the scope of this runbook to posting a slack message of all the lambda functions that don't use the graviton2 processor.

Also the reference article that you linked is not really migrating the lambda function, they are simply creating a new one using create-lambda and specifying -architectures arm64

I found this too - https://repost.aws/questions/QUe69VPTSHS3mVnJj9KL-12w/bug-cannot-change-lambda-architecture-without-providing-a-new-zip-file-in-the-management-console

@amit-chandak-unskript
Copy link
Contributor Author

@amit-chandak-unskript The command to update the configuration architecture for a non graviton2 processor is aws lambda update-function-code --function-name <function-name> --zip-file fileb://<path-to-zip-file>

We need a new zip file path of the arm64 compatible code. Once that is updated the new runtime architecture also get's updated. Since we don't have a way to upload files for a lego, I think we can contain the scope of this runbook to posting a slack message of all the lambda functions that don't use the graviton2 processor.

Also the reference article that you linked is not really migrating the lambda function, they are simply creating a new one using create-lambda and specifying -architectures arm64

I found this too - https://repost.aws/questions/QUe69VPTSHS3mVnJj9KL-12w/bug-cannot-change-lambda-architecture-without-providing-a-new-zip-file-in-the-management-console

@shloka-bhalgat-unskript lets handle the case where the binaries need not be recompiled

Many Lambda functions may only need a configuration change to take advantage of the price/performance of Graviton2. Other functions may require repackaging the Lambda function using Arm-specific dependencies, or rebuilding the function binary or container image.

You may not require an Arm processor on your development machine to create Arm-based functions. You can build, test, package, compile, and deploy Arm Lambda functions on x86 machines using AWS SAM and Docker Desktop. If you have an Arm-based system, such as an Apple M1 Mac, you can natively compile binaries.

Functions without architecture-specific dependencies or binaries
If your functions don’t use architecture-specific dependencies or binaries, you can switch from one architecture to the other with a single configuration change. Many functions using interpreted languages such as Node.js and Python, or functions compiled to Java bytecode, can switch without any changes. Ensure you check binaries in dependencies, Lambda layers, and Lambda extensions.

To switch functions from x86 to arm64, you can change the Architecture within the function runtime settings using the Lambda console.

@shloka-bhalgat-unskript
Copy link
Member

That's correct @amit-chandak-unskript , I tried it for the case where binaries were not needed to be recompiled. We could simply update the runtime configuration for architecture type.

But, there is no way to do it. Documentation for update-lambda-configuration

The --architectures is not a valid flag for this api even when I specify the runtime (like python3.7)
Screenshot 2023-04-26 at 6 33 19 PM

As per the article , we can do it via console but there isn't a way to update the architecture configuration for the function. They have simply created a new one...

When using the AWS CLI to create a Lambda function, specify the --architectures option. If you do not specify the architecture, the default value is x86-64. For example, to create an arm64 function, specify--architectures arm64.

aws lambda create-function \
    --function-name MyArmFunction \
    --runtime nodejs14.x \
    --architectures arm64 \
    --memory-size 512 \
    --zip-file fileb://MyArmFunction.zip \
    --handler lambda.handler \
    --role arn:aws:iam::123456789012:role/service-role/MyArmFunction-role

@amit-chandak-unskript
Copy link
Contributor Author

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

No branches or pull requests

2 participants