The AWS Credentials provider can give a remote device AWS credentials if it has a valid certificate. The device certificate is stored inside AWS IoT’s service and can be revoked, deactivated or deleted at any time. AWS IoT can also record and index individual IoT Things within a fleet. Each IoT thing will have its own unique certificate verified by AWS, and can be given unique attributes to identify each device along with policies which control the approved actions of each device.
Using AWS IoT also allows device data to be used by other AWS cloud services. Once the device is given credentials, other AWS services can be configured to receive data from the device.
The IoT device’s AWS credentials are only valid for a period of time. If the credentials expire, when the AWS CLI tries to connect to AWS servers, it will run an installed script to get new credentials.
There are four devices in the provisioning process:
If wanted, the CA and provisioning device can be on the same device.
The provisioning device can be any device with AWS CLI installed, but we recommend it not be an IoT device you deploy because the provisioning device will have more AWS permissions.
aws configure
and fill in the appropriate values from the AWS page.git clone https://github.com/zymbit-applications/aws-credentials-provider.git
sudo mkdir /opt/zymbit
The Certificate Authority can be a private CA you own or you can use AWS’s CA service. If you want to create a CA on your own device, follow these instructions.
On the device you want to hold your private CA and sign certificate requests, do the following.
git clone https://github.com/zymbit-applications/aws-credentials-provider.git
cd aws-credentials-provider
mk_ca.sh
There are now three files in the directory (~/aws-credentials-provider/CA_files).
If you have your own private CA, then you need to register it with AWS.
Steps 1 and 6 are done on the provisioning device. Steps 2-5 must be done on the private CA.
aws iot get-registration-code
openssl genrsa -out verificationCert.key 2048
openssl req -new -key verificationCert.key -out verificationCert.csr
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []: 9c9df696a8a09688d040b4b719129e4d6dbd6a898eeb0c654af0a5753b41
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
openssl x509 -req -in verificationCert.csr -CA CA_files/zk_ca.pem \
-CAkey CA_files/zk_ca.key -CAcreateserial -out verificationCert.crt \
-days 500 -sha256
aws iot register-ca-certificate --ca-certificate file://CA_files/zk_ca.crt \
--verification-certificate file://verificationCert.crt \
--set-as-active \
--allow-auto-registration
All of these steps happen on the provisioning device
aws iam create-role --role-name credential_helper --assume-role-policy-document file://aws-credentials-provider/role-trust-policy.json
aws iot create-role-alias --role-alias deviceRoleAlias --role-arn <roleARN>
aws iam get-role --role-name credential_helper
to find it again.aws sts get-caller-identity
on your provisioning device.credential_helper
)aws sts get-caller-identity
aws iot create-policy --policy-name credentialHelper --policy-document file://aws-credentials-provider/iot-role-policy.json
git clone https://github.com/zymbit-applications/aws-credentials-provider.git
sudo mkdir /opt/zymbit
sudo cp ~/aws-credentials-provider/credentials.sh /opt/zymbit/ && sudo chmod +x /opt/zymbit/credentials.sh
~/aws-credentials-provider/config
to specify the appropriate region.mkdir ~/.aws && cp ~/aws-credentials-provider/config ~/.aws/config
openssl req -key nonzymkey.key -new -out zymkey.csr -engine zymkey_ssl -keyform e
aws iot describe-endpoint --endpoint-type iot:CredentialProvider
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]: <IOT-POLICY>
Locality Name (eg, city) []: <REGION>
Organization Name (eg, company) [Internet Widgits Pty Ltd]: <CREDENTIAL-URL>
Organizational Unit Name (eg, section) []: <ROLE-ALIAS>
Common Name (e.g. server FQDN or YOUR name) []: <THING-NAME>
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
bash sign_csr.sh zymkey.csr device.crt
. The first argument is the path to your CSR and the second argument the name you wish to give the signed device Certificate file.sudo cp device.crt /opt/zymbit/ && sudo cp root.ca.pem /opt/zymbit/
cd ~/aws-credentials-provider; bash provision-device.sh
sudo mv device.crt /opt/zymbit/ && sudo mv root.ca.pem /opt/zymbit/
/opt/zymbit/credentials.sh
to test the TLS connection.aws --profile zymkey iot describe-endpoint