

Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.

# Étape 1 : Création de la AWS IoT politique
<a name="iot-moisture-policy"></a>

Créez une AWS IoT politique qui permet à votre Raspberry Pi de se connecter et d'envoyer des messages à AWS IoT.

1. Dans la [console AWS IoT](https://console.aws.amazon.com/iot), si un bouton **Commencer** s'affiche, appuyez dessus. Dans le panneau de navigation du service, développez **Sécurité**, puis choisissez **Politiques**.

1. Si une boîte de dialogue **Vous ne possédez pas encore de stratégie** s'affiche, choisissez **Créer une stratégie**. Sinon, cliquez sur **Create**.

1. Entrez le nom de la AWS IoT politique (par exemple,**MoistureSensorPolicy**).

1. Dans la section **Ajouter des instructions**, remplacez la stratégie existante par le code JSON suivant. Remplacez {{region}} et {{account}} par votre Compte AWS numéro Région AWS et.  
****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Effect": "Allow",
               "Action": "iot:Connect",
               "Resource": "arn:aws:iot:{{us-east-1}}:123456789012:client/RaspberryPi"
           },
           {
               "Effect": "Allow",
               "Action": "iot:Publish",
               "Resource": [
                   "arn:aws:iot:{{us-east-1}}:123456789012:topic/$aws/things/RaspberryPi/shadow/update",
                   "arn:aws:iot:{{us-east-1}}:123456789012:topic/$aws/things/RaspberryPi/shadow/delete",
                   "arn:aws:iot:{{us-east-1}}:123456789012:topic/$aws/things/RaspberryPi/shadow/get"
               ]
           },
           {
               "Effect": "Allow",
               "Action": "iot:Receive",
               "Resource": [
                   "arn:aws:iot:{{us-east-1}}:123456789012:topic/$aws/things/RaspberryPi/shadow/update/accepted",
                   "arn:aws:iot:{{us-east-1}}:123456789012:topic/$aws/things/RaspberryPi/shadow/delete/accepted",
                   "arn:aws:iot:{{us-east-1}}:123456789012:topic/$aws/things/RaspberryPi/shadow/get/accepted",
                   "arn:aws:iot:{{us-east-1}}:123456789012:topic/$aws/things/RaspberryPi/shadow/update/rejected",
                   "arn:aws:iot:{{us-east-1}}:123456789012:topic/$aws/things/RaspberryPi/shadow/delete/rejected"
               ]
           },
           {
               "Effect": "Allow",
               "Action": "iot:Subscribe",
               "Resource": [
                   "arn:aws:iot:{{us-east-1}}:123456789012:topicfilter/$aws/things/RaspberryPi/shadow/update/accepted",
                   "arn:aws:iot:{{us-east-1}}:123456789012:topicfilter/$aws/things/RaspberryPi/shadow/delete/accepted",
                   "arn:aws:iot:{{us-east-1}}:123456789012:topicfilter/$aws/things/RaspberryPi/shadow/get/accepted",
                   "arn:aws:iot:{{us-east-1}}:123456789012:topicfilter/$aws/things/RaspberryPi/shadow/update/rejected",
                   "arn:aws:iot:{{us-east-1}}:123456789012:topicfilter/$aws/things/RaspberryPi/shadow/delete/rejected"
               ]
           },
           {
               "Effect": "Allow",
               "Action": [
                   "iot:GetThingShadow",
                   "iot:UpdateThingShadow",
                   "iot:DeleteThingShadow"
               ],
               "Resource": "arn:aws:iot:{{us-east-1}}:123456789012:thing/RaspberryPi"
           }
       ]
   }
   ```

1. Choisissez **Créer**.