GithubHelp home page GithubHelp logo

aws-samples / aws-iot-rpi-fleet-provisioning Goto Github PK

View Code? Open in Web Editor NEW
15.0 4.0 9.0 1.31 MB

This CDK stack generates a custom raspbian image which uses AWS IoT Fleet Provisioning to automate onboarding of Raspberry Pi devices to AWS IoT Core.

License: Apache License 2.0

JavaScript 1.68% TypeScript 31.63% Python 55.97% Shell 10.73%
aws-iot raspberry-pi aws-iot-fleet-provisioning aws-iot-core

aws-iot-rpi-fleet-provisioning's Introduction

aws-iot-rpi-fleet-provisioning

This CDK stack generates a custom raspbian image which automates onboarding of Raspberry Pi devices to AWS IoT Core.

๐Ÿ“‹ Table of content

๐Ÿ”– Features

  • Create a custom raspbian based image which:
    • Enables connection to a WiFi network.
    • Sets a unique hostname for the device based on its Ethernet MAC address. As an example a Ethernet MAC address of dc:a6:32:01:23:45 will result in a hostname of dca632012345.
    • Requests a fully functional identity on first boot with the necessary IoT permissions that the device can use for subsequent communication with AWS IoT Core.

๐ŸŽ’ Pre-requisites

yarn -v && node -v

๐Ÿš€ Install

1/ Create a secret to store the password for the Wifi network used by your devices

You can do it from the AWS console or from the command line:

aws secretsmanager create-secret --name RPI_WIFI_PASSWORD \
    --description "RaspberryPi Wifi Password" \
    --secret-string 'redacted'

2/ Update the stack configuration

Update the Wifi network SSID/country and public SSH key used to connect to your devices in the lib/utils/constants.ts file.

3/ Deploy the stack

Deploy this stack to your AWS account/region:

yarn && yarn build
yarn cdk deploy '*'

๐Ÿ›  Usage

The CDK stack creates a CodePipeline which builds the custom raspbian image and stores it in S3.

Once the stack is deployed, you can check the progress of the pipeline in the AWS console. Once the pipeline is completed, download the custom raspbian image from S3 (Check the "Artifacts upload location" in the Codebuild project to find the S3 bucket).

Artifacts upload location

Unzip the image and write it on your Raspberry Pi sd card

unzip aws-raspbian.zip
# Find the SD card external disk
diskutil list external
# Write the image (replace /dev/disk123abcd with the name of the SD card external disk)
diskutil unmountDisk /dev/disk123abcd
sudo dd bs=1m if=aws-raspbian.img of=/dev/disk123abcd conv=sync

A Raspberry Pi booting using this image will automatically requests a fully functional identity on first boot with the necessary IoT permissions that the device can use for subsequent communication with AWS IoT Core (see rpi-image-builder/firstboot.bash).

AWS IoT Core console

Assuming you're on the same Wifi network as a device using this image, you can ssh into a device using its unique hostname and the SSH key you specified in the config:

# Replace dca632012345 with your device name
ssh [email protected]

๐Ÿ‘€ See also

Security

See CONTRIBUTING for more information.

License

This library is licensed under the Apache-2.0 License. See the LICENSE file.

aws-iot-rpi-fleet-provisioning's People

Contributors

abrenaut avatar amazon-auto avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

aws-iot-rpi-fleet-provisioning's Issues

Stack error

Hi,
While deploying the stack, i get this below error,

Resource handler returned message: "Could not unzip uploaded file. Please check your file, then try to upload again. (Service: Lambda, Status Code: 400"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.