Basically, follows this document: https://docs.aws.amazon.com/greengrass/latest/developerguide/quick-start.html
Download Raspberry Pi Imager and write Raspberry Pi OS (32-bit) image to your SD card. https://www.raspberrypi.org/software/
Add empty file with filename ssh
under the /boot.
$ touch /Volumes/boot/ssh
Add wpa_supplicant.conf
to /boot
with this contents:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=JP
network={
ssid="YOUR_SSID"
psk="YOUR_PASSWORD"
}
Set SD card to your Rapberry Pi Zero W and power it up. Connect to your raspberry pi with ssh
.
ssh pi@raspberrypi.local
Run this command to update.
$ sudo apt update
$ sudo apt upgrade
Create an IAM user for Greengrass in IAM user service with Programmatic access Access type, and then attach AdministratorAccess
policy to it.
You'll get its Access Key ID
and Secret access key
.
Set Access Key ID
and Secret access key
to your environment variables.
$ export AWS_ACCESS_KEY_ID=AKxxxxxxxxxxxxxxxx
$ export AWS_SECRET_ACCESS_KEY=Ci+5yyyyyyyyyyyyyyyyyyyyyyyyyy
Run this command:
$ curl https://d1onfpft10uf5o.cloudfront.net/greengrass-device-setup/downloads/gg-device-setup-latest.sh > gg-device-setup-latest.sh && chmod +x ./gg-device-setup-latest.sh && sudo -E ./gg-device-setup-latest.sh bootstrap-greengrass-interactive
In the middle, you'll be prompted to reboot. Then reboot.
$ sudo reboot -h now
After reboot, set your credential again:
$ export AWS_ACCESS_KEY_ID=AKxxxxxxxxxxxxxxxx
$ export AWS_SECRET_ACCESS_KEY=Ci+5yyyyyyyyyyyyyyyyyyyyyyyyyy
Restart the script.
$ sudo -E ./gg-device-setup-latest.sh bootstrap-greengrass-interactive
After setup done, you'll see these messages in the end:
You can now use the AWS IoT Console to subscribe
to the 'hello/world' topic to receive messages published from your
Greengrass core.
=======================================================================================
You can verify the Lambda function by following this guide: https://docs.aws.amazon.com/greengrass/latest/developerguide/lambda-check.html
Note that you need to choose the right region which you entered in your setup process.
To check what region is set up for your Raspberry Pi, run this command on your pi:
$ sudo cat /greengrass/config/config.json | grep Host
"iotHost": "XXXXXXXXXXXX-ats.iot.us-west-2.amazonaws.com",
"ggHost": "greengrass-ats.iot.us-west-2.amazonaws.com",
If you are using raspbian bullseye, install pip before you run the curl command. That command is not able to install pip and the whole installation fails because of that.