Skip to content

Commit 90ae16b

Browse files
authored
Merge pull request #1297 from ArmDeveloperEcosystem/main
Merge to production
2 parents 2adb292 + 619417d commit 90ae16b

File tree

37 files changed

+1661
-55
lines changed

37 files changed

+1661
-55
lines changed
File renamed without changes.
3.64 MB
Loading
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
---
2+
title: AWS SAM CLI
3+
4+
author_primary: Jason Andrews
5+
minutes_to_complete: 15
6+
7+
official_docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html
8+
9+
additional_search_terms:
10+
- AWS
11+
- Lambda
12+
13+
layout: installtoolsall
14+
multi_install: false
15+
multitool_install_part: false
16+
test_maintenance: false
17+
tool_install: true
18+
weight: 1
19+
---
20+
21+
The Amazon Web Services (AWS) Serverless Application Model (SAM) CLI is an open-source command-line tool that you can use to build, test, and deploy serverless applications. The SAM CLI provides a Lambda-like execution environment that lets you locally build, test and debug applications defined by AWS SAM templates. It is available for a variety of operating systems and Linux distributions, and supports the Arm architecture.
22+
23+
## Before you begin
24+
25+
Follow the instructions below to install and try the latest version of the AWS SAM CLI for Ubuntu on Arm.
26+
27+
Confirm you are using an Arm machine by running:
28+
29+
```bash { target="ubuntu:latest" }
30+
uname -m
31+
```
32+
33+
The output should be:
34+
35+
```output
36+
aarch64
37+
```
38+
39+
If you see a different result, you are not using an Arm-based computer running 64-bit Linux.
40+
41+
Running the AWS SAM CLI requires Docker. Refer to the [Docker](/install-guides/docker/) Install Guide for installation instructions. Confirm Docker is running before installing the SAM CLI.
42+
43+
Python and Python pip are also required to run the SAM CLI example.
44+
45+
To install, run the following command:
46+
47+
```console
48+
sudo apt install python-is-python3 python3-pip -y
49+
```
50+
51+
## Download and install the AWS SAM CLI
52+
53+
There are two options to install the SAM CLI, you can select your preferred method:
54+
55+
* From a zip file.
56+
* Using the Python `pip` command.
57+
58+
### Download and install from zip file
59+
60+
Use `wget`:
61+
62+
```bash
63+
wget https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-arm64.zip
64+
unzip aws-sam-cli-linux-arm64.zip -d sam-install
65+
sudo ./sam-install/install
66+
```
67+
68+
### Install the SAM CLI using Python pip
69+
70+
```
71+
sudo apt install python3-venv -y
72+
python -m venv .venv
73+
source .venv/bin/activate
74+
pip install aws-sam-cli
75+
```
76+
77+
### Confirm that the SAM CLI has been installed
78+
79+
```bash
80+
sam --version
81+
```
82+
83+
The version should be printed on screen:
84+
85+
```output
86+
SAM CLI, version 1.125.0
87+
```
88+
89+
## Example application
90+
91+
You can use the AWS SAM CLI to build and deploy a simple "Hello World" serverless application that includes the line `uname -m` to check the platform it is running on, by following these steps.
92+
93+
1. Create the project
94+
95+
Use the code below, adjusting the runtime argument if you have a different version of Python:
96+
97+
```console
98+
sam init --runtime python3.12 --architecture arm64 --dependency-manager pip --app-template hello-world --name uname-app --no-interactive
99+
```
100+
101+
2. Change to the new directory:
102+
103+
```console
104+
cd uname-app
105+
```
106+
107+
3. Modify the `hello_world/app.py` file to include the command `uname -m`
108+
109+
Use a text editor to replace the contents of the `hello_world/app.py` file with the code below:
110+
111+
```python
112+
import json
113+
import os
114+
115+
def lambda_handler(event, context):
116+
"""Sample pure Lambda function
117+
118+
Parameters
119+
----------
120+
event: dict, required
121+
API Gateway Lambda Proxy Input Format
122+
123+
Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
124+
125+
context: object, required
126+
Lambda Context runtime methods and attributes
127+
128+
Context doc: https://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html
129+
130+
Returns
131+
------
132+
API Gateway Lambda Proxy Output Format: dict
133+
134+
Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
135+
"""
136+
137+
ret = os.popen('uname -m').read()
138+
139+
return {
140+
"statusCode": 200,
141+
"body": json.dumps({
142+
"message": ret,
143+
# "location": ip.text.replace("\n", "")
144+
}),
145+
}
146+
```
147+
148+
4. Build the application:
149+
150+
```console
151+
sam build
152+
```
153+
154+
5. Test the deployed application:
155+
156+
```console
157+
sam local invoke "HelloWorldFunction" -e events/event.json
158+
```
159+
160+
The output below shows the results from the command `uname -m` and the value of `aarch64` confirms an Arm Linux computer:
161+
162+
```output
163+
Invoking app.lambda_handler (python3.12)
164+
Local image was not found.
165+
Removing rapid images for repo public.ecr.aws/sam/emulation-python3.12
166+
Building image........................................................................................................................
167+
Using local image: public.ecr.aws/lambda/python:3.12-rapid-arm64.
168+
169+
Mounting /home/ubuntu/uname-app/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated, inside runtime container
170+
START RequestId: 7221da4d-346d-4e2e-831e-dcde1cb47b5b Version: $LATEST
171+
END RequestId: 513dbd6f-7fc0-4212-ae13-a9a4ce2f21f4
172+
REPORT RequestId: 513dbd6f-7fc0-4212-ae13-a9a4ce2f21f4 Init Duration: 0.26 ms Duration: 84.22 ms Billed Duration: 85 ms Memory Size: 128 MB Max Memory Used: 128 MB
173+
{"statusCode": 200, "body": "{\"message\": \"aarch64\\n\"}"}
174+
```
175+
176+
You are ready to use the AWS SAM CLI to build more complex functions and deploy them into AWS. Make sure to select `arm64` as the architecture for your Lambda functions.
177+

content/install-guides/java.md

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ Below are some of the common methods to install Java. This includes both the Jav
3232

3333
Pick the one that works best for you.
3434

35-
## Install Java using the Linux package manager
35+
{{% notice Note %}}
36+
The Java Technology Compatibility Kit (TCK) is a test suite that verifies whether a Java implementation conforms to the Java SE Platform Specification. It's a crucial tool for ensuring that Java applications can run consistently across different platforms and implementations.
37+
38+
Check the [OCTLA Signatories List](https://openjdk.org/groups/conformance/JckAccess/jck-access.html) to see who has been granted access to the TCK.
39+
{{% /notice %}}
40+
41+
## Can I install Java using the Linux package manager?
3642

3743
For distributions using `apt` - including Debian and Ubuntu:
3844

@@ -55,7 +61,15 @@ sudo pacman -S jdk-openjdk
5561
sudo pacman -S jre-openjdk
5662
```
5763

58-
## Install Java using Amazon Corretto
64+
## Can I install Java using Snap?
65+
66+
For Linux distributions with `snap` you can install Java using:
67+
68+
```console
69+
sudo snap install openjdk
70+
```
71+
72+
## How do I install Amazon Corretto?
5973

6074
Amazon Corretto is a no-cost distribution of the Open Java Development Kit (OpenJDK). It is maintained and supported by Amazon Web Services (AWS).
6175

@@ -69,15 +83,64 @@ sudo apt-get update; sudo apt-get install -y java-21-amazon-corretto-jdk
6983

7084
More installation options for Corretto are available in the [Amazon Corretto 21 Guide for Linux](https://docs.aws.amazon.com/corretto/latest/corretto-21-ug/linux-info.html)
7185

72-
## Install Java using Snap
86+
## How do I install the Microsoft Build of OpenJDK?
7387

74-
For Linux distributions with `snap` you can install Java using:
88+
The Microsoft Build of OpenJDK is a no-cost, open source distribution of OpenJDK. It includes Long-Term Support (LTS) binaries for Java 11 and Java 17 and runs on Arm Linux.
89+
90+
{{% notice Note %}}
91+
The Arm architecture is not available in the repositories for the `apt` package manager.
92+
{{% /notice %}}
93+
94+
You can download a tar.gz file from [Download the Microsoft Build of OpenJDK](https://learn.microsoft.com/en-gb/java/openjdk/download)
95+
96+
For example:
7597

7698
```console
77-
sudo snap install openjdk
99+
wget https://aka.ms/download-jdk/microsoft-jdk-21.0.4-linux-aarch64.tar.gz
100+
```
101+
102+
Extract the contents of the file:
103+
104+
```console
105+
tar xvf microsoft-jdk-21.0.4-linux-aarch64.tar.gz
78106
```
79107

80-
## Is there a way to install Java from the official website?
108+
Move the contents to a directory of your choice:
109+
110+
```console
111+
sudo mv jdk-21.0.4+7/ /usr/local
112+
```
113+
114+
Set up environment variables to locate your installation:
115+
116+
```console
117+
export JAVA_HOME=/usr/local/jdk-21.0.4+7
118+
export PATH=$JAVA_HOME/bin:$PATH
119+
```
120+
121+
Add the environment variables to your `~/.bashrc` file to set them permanently.
122+
123+
For more information about the available versions and supported platforms refer to [About the Microsoft Build of OpenJDK](https://learn.microsoft.com/en-gb/java/openjdk/overview).
124+
125+
## How do I install Eclipse Temurin from the Adoptium Working Group?
126+
127+
The Adoptium Working Group promotes and supports high-quality, TCK certified runtimes and associated technology for use across the Java ecosystem.
128+
129+
Eclipse Temurin is the name of the OpenJDK distribution from Adoptium.
130+
131+
To install Temurin on Ubuntu run:
132+
133+
```console
134+
sudo apt install -y wget apt-transport-https gpg
135+
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null
136+
echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
137+
sudo apt update
138+
sudo apt install temurin-17-jdk -y
139+
```
140+
141+
For more information about the available versions and supported platforms refer to [Temurin documentation](https://adoptium.net/docs/).
142+
143+
## How do I install Java from Oracle?
81144

82145
You can download Java from the [Oracle website](https://www.oracle.com/java/technologies/javase-downloads.html) and install it manually. Look for the files with ARM64 in the description.
83146

@@ -159,7 +222,7 @@ javac 21.0.4
159222

160223
## Which version of Java should I use for Arm Linux systems?
161224

162-
It’s important to ensure that your version of Java is at least 11.0.9. There are large performance improvements starting from version 11.0.9. Since then, Java performance has steadily increased over time and newer versions will provide better performance.
225+
For performance and security, it’s important to ensure that your version of Java is at least 11.0.12. Earlier versions lack significant performance improvements. Java performance has steadily increased over time and newer versions will provide better performance.
163226

164227
## Which flags are available for tuning the JVM?
165228

0 commit comments

Comments
 (0)