Created
June 29, 2016 21:55
-
-
Save gwincr11/4770616e6bf66ad91db79e0d39eea36f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create and configure a AWS IOT | |
# | |
set -e | |
echo -e "What is the device name? \c" | |
read NAME | |
# Create the IOT device | |
aws iot create-thing --thing-name $NAME | |
# setup IOT policy | |
# get device certificate | |
curl https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem > root.pem | |
# get AWS certificates | |
ARN=$(aws iot create-keys-and-certificate --set-as-active --certificate-pem-outfile cert.pem --public-key-outfile publicKey.pem --private-key-outfile privateKey.pem | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["certificateArn"]') | |
echo $ARN | |
# setup policy | |
aws iot attach-principal-policy --principal $ARN --policy-name "PubSubToAnyTopic" | |
# attach certificate to thing | |
aws iot attach-thing-principal --thing-name $NAME --principal $ARN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment