Durch die Nutzung von AWS re:Post stimmt du den AWS re:Post Nutzungsbedingungen

Unable to locate credentials. you can configure creadential by running "aws configure"

0

I am setting up own mqtt broker ( mosqutto ) on the aws EC2. using blow blog. https://aws.amazon.com/blogs/iot/how-to-bridge-mosquitto-mqtt-broker-to-aws-iot/

I facing error mantion in topic.

#Create certificates and keys. Make a note of the certificate ARN as it will be #needed to configure the IoT Policy. sudo aws iot create-keys-and-certificate --set-as-active --certificate-pem-outfile cert.crt --private-key-outfile private.key --public-key-outfile public.key --region ap-south-1

for above command.

I have configure a credentials correctly.

for command :- aws configure list

ubuntu@ip-172-31-42-138:~$ aws configure list

Name Value Type Location ---- ----- ---- -------- profile <not set> None None access_key ****************LTGP shared-credentials-file secret_key ****************JQcF shared-credentials-file region ap-south-1 config-file ~/.aws/config

This output comes.

Permission :-

  1. AdministratorAccess
  2. AmazonEC2FullAccess
  3. AmazonS3FullAccess

I have created bucket also.

please guide me on this issue.

1 Antwort
0

Based on the information you've provided, it appears that you have configured your AWS credentials correctly on your EC2 instance. The output from 'aws configure list' shows that you have an access key and secret key set up in the shared credentials file, and your region is set to ap-south-1.

However, the error "Unable to locate credentials" suggests that the AWS CLI is not able to find or use these credentials when you're trying to run the 'aws iot create-keys-and-certificate' command.

Here are a few things you can try to resolve this issue:

  1. Ensure that the AWS CLI can access the credentials file. Check the permissions on the ~/.aws directory and the credentials file within it. They should be readable by your user.

  2. Try explicitly specifying the profile when running your command. Even if you haven't set up a named profile, you can use the default profile:

sudo aws iot create-keys-and-certificate --set-as-active --certificate-pem-outfile cert.crt --private-key-outfile private.key --public-key-outfile public.key --region ap-south-1 --profile default

  1. If you're using sudo to run the command, the AWS CLI might not be able to access your user's credentials. Try running the command without sudo, or if you need elevated permissions, use 'sudo -E' to preserve your environment variables:

sudo -E aws iot create-keys-and-certificate --set-as-active --certificate-pem-outfile cert.crt --private-key-outfile private.key --public-key-outfile public.key --region ap-south-1

  1. Verify that the IAM user associated with these credentials has the necessary permissions to create IoT certificates. The AdministratorAccess policy should be sufficient, but you might want to double-check that it's correctly attached to your IAM user.

  2. As a troubleshooting step, try running a simpler AWS CLI command, like 'aws s3 ls', to see if it can access your credentials and list your S3 buckets.

If none of these steps resolve the issue, you might want to consider re-running 'aws configure' to set up your credentials again, ensuring that you enter the correct access key and secret key.

Remember, when setting up an MQTT broker on EC2, you'll also need to ensure that your EC2 instance's security group allows incoming traffic on the MQTT port (typically 1883 for unencrypted or 8883 for encrypted connections).
Sources
Mqtt broker not working in remote access | AWS re:Post
Troubleshoot IAM credentials from an Amazon EC2 IMDS | AWS re:Post
AWS configuration profile credentials - Amazon Athena

profile picture
beantwortet vor 2 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen