Not able to connect mqtt server

If you are asking a question, please follow this template:

  1. My goal is: I am trying to connect aws iot core but getting MQTT disconnect. I am using ESP32-WROOM-32.
  2. My actions are:
    step-1 : cmd connected to aws configure, able to get things list.
    setp-2 : connected to wifi , status showing connected …
    step-3 : created policy , here is my policy , policy name “device-policy”
    {
    “Version”: “2012-10-17”,
    “Statement”: [
    {
    “Effect”: “Allow”,
    “Action”: “iot:",
    “Resource”: "

    }
    ]
    }
    step4 : try to connect aws iot core : mos aws-iot-setup --aws-region us-east-1 --aws-iot-policy device-policy

my mos.yml config
config_schema:

  • [“temperature”, “o”, {title: “Temperature related configurations”}]
  • [“temperature.basis”, “d”, 107, {title: “Ambient temperature to act as reference:”}]
  • [“temperature.unit”, “s”, “Fahrenheit”, {title: “Temperature unit:”}]
  • [“led”, “o”, {title: “LED configurations”}]
  • [“led.gpio”, “i”, 2, {title: “Built-in LED GPIO:”}]
  • [“sleep_duration”, “d”, 10, {title: “Time in minutes after for which the device should (deep) sleep:”}]
  • [“mqtt.enable”, “b”, true, {title: “Enable MQTT service:”}]
  • [“mqtt.server”, “s”, “a2kjz65eoad---------dasdasd-ats.iot.us-east-1.amazonaws.com”, {title: “MQTT server to publish to.”}]
  • [“mqtt.ssl_ca_cert”, “s”, “ca.pem”, {title: “Path to trusted CA certificate, relative to ‘fs’.”}]

= > ca certificate is inside fs/ca.pem

  1. The result I see is: I am getting MQTT disconnected
  2. My expectation & question is: I am not able to figure out how , how to connect . I am very much struggling to find out it . Please help me to connect to aws iot core. Thanks

What does the command aws-iot-setup inform? Does it sucessfuly creates a new thing and fill your ESP with the necessary credentials? (left side logs for commands)

You might wanna add permissions to your policy in AWS IAM, Give your user the necessary permissions, if you are new, grant AdministratorAccess, but beware with your credentials.

Verify if your file credentials has a AWS IAM that has all permission for AWS IoT

[profile_name_with_permissions]
aws_access_key_id = AKIA…
aws_secret_access_key =

After that, you can use

mos aws-iot-setup --aws-region REGION --aws-iot-policy YOUR_POLICY

It will get your device id, generate the certs for this device, download from AWS and upload to your MCU.

Check this link