- 최신
- 최다 투표
- 가장 많은 댓글
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:
-
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.
-
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
- 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
-
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.
-
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
관련 콘텐츠
- AWS 공식업데이트됨 3년 전