Awair Sensor Data Backup
The Terraform file
awair.tf sets up the AWS services and permissions necessary to run a nightly Lambda job to back up sensor data from the Awair API to a S3 bucket.
The next step is obtaining your device_id and device_type from the Awair API. The curl request below will return information about your sensor from the Awair API. Enter your own account token after
Bearer in the Authorization header. Take note of your
device_type and enter them and your API access token into the
curl 'https://developer-apis.awair.is/v1/users/self/devices' \ --header 'Authorization: Bearer YOUR-ACCOUNT-TOKEN`
Read through the
awair.tf Terraform file and review the execution plan to make sure you understand and are OK with what is going on.
# Clone this gist $ git clone https://gist.github.com/epsalt/94a9fc09574c52d7baa532bd1c072ed3.git awair-backup-terraform $ cd awair-backup-terraform # Add your awair token and device info to awair.tfvars $ nano awair.tfvars # Archive the Lambda function $ zip awair-request.zip awair-request.js # Make sure everything looks good in the execution plan $ terraform init $ terraform plan -vars-file awair.tfvars # Execute $ terraform apply -vars-file awair-tfvars
Data from the awair
5-min-avg endpoint will be downloaded to an S3 bucket called
awair-backup-bucket at 10:00 UTC daily. Resource names, AWS region, backup frequency, and other parameters can be altered by changing fields in