- Clone the repository and
cd
into it
git clone [email protected]:imharvol/fan-aws-iot-esp01-mqtt.git && \
cd ./fan-aws-iot-esp01-mqtt/
- Zip the lambda code, name the archive
function.zip
and move it into theterraform
folder:
cd ./lambda/ && \
zip ./function.zip ./index.js && \
cd .. && \
mv ./lambda/function.zip ./terraform/
- Create the lambda layer for
@aws-sdk/client-iot-data-plane
in a file namedlayer.zip
and move it into theterraform
folder. Feel free to usecreate-lambda-layer-aws
:
cd ./terraform/ && \
npx create-lambda-layer-aws @aws-sdk/client-iot-data-plane && \
cd ..
- Initialize and apply with Terraform:
terraform init && \
terraform apply
- Rename
esp01-arduino/secrets.example.h
asesp01-arduino/secrets.h
mv esp01-arduino/secrets.example.h esp01-arduino/secrets.h
-
Replace the values for the WiFi SSDI and password, and make sure that the Thing's name matches the deployed Thing's name.
-
Fetch the Amazon Root CAs and replace the values in
esp01-arduino/secrets.h
:
curl https://www.amazontrust.com/repository/G2-RootCA1.pem
curl https://www.amazontrust.com/repository/G2-RootCA3.pem
- After deploying to AWS with Terraform, get the endpoint, the device's certificate and the private key and replace the values in
esp01-arduino/secrets.h
:
terraform output -raw iot_endpoint
terraform output -raw thing_private_key
terraform output -raw thing_certificate_pem