I am trying to create an EC2 instance on AWS in an automatical manner.
I am calling a HTTP method through an amazon endpoint using a HTTP client installed on my computer, which clearly is not on AWS.
I am calling the endpoint in the following way, as specified in amazon documentation:
https://ec2.amazonaws.com/?Action=RunInstances&
ImageId=ami-0129bfde49ddb0ed6&
MaxCount=1&
MinCount=1&
KeyName=chiavepem.pem&
SecurityGroupId.1=sg-0983aeb061077d2ab&
Placement.AvailabilityZone=eu-north-1&
AWSSecretKey=<redacted>&
AWSAccessKeyId=<redacted>
However, I get this response:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Errors>
<Error>
<Code>AuthFailure</Code>
<Message>AWS was not able to validate the provided access credentials</Message>
</Error>
</Errors>
<RequestID>c3c559d8-fe3f-4e60-bd16-1db621dfcbe4</RequestID>
</Response>
Regarding AuthFailure, Amazon Documentation says:
The provided credentials could not be validated. You might not be
authorized to carry out the request; for example, trying to associate
an Elastic IP address that is not yours, or trying to use an AMI for
which you do not have permissions. Ensure that your account is
authorized to use Amazon EC2, that your credit card details are
correct, and that you are using the correct credentials.
I made sure these conditions are respected.
What might be the cause for this specific behavior?
As a side note, I am using access keys here, but I understood that it is not the best way to authenticate a call to the aws api, but i didn’t find any valid alternative for doing so. As far as I understand, I cannot use my IAM credentials to authenticate to the API.
Maybe someone could point me in the right direction on this matter as well.
Thanks.