How to authenticate with AWS API to launch a EC2 instance

时间:2017-08-13 14:06:45

标签: amazon-web-services amazon-ec2

I need to create Java REST API(not with SDK) to launch a AWS EC2 instance.

First of all I need to Authenticate with the AWS API server by using Signature and Accesskey. I tried using the AWS documentations but I am facing the below error.

<Code>AuthFailure</Code><Message>AWS was not able to validate the provided access credentials</Message>

Could someone suggest me the steps to implement authentication with API and launching the instance in AWS. Also share if any existing GitHub code for the above requirement.

1 个答案:

答案 0 :(得分:0)

你必须使用,

http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/ec2/AmazonEC2Client.html

您可以通过多种方式获得访问权限。 使用IAM创建访问密钥和密钥并将它们传递给Java客户端。

或者您可以为EC2实例创建角色并将角色分配给您的Ec2实例。从该EC2实例运行的任何代码都可以访问所提到的角色。

使用IAM访问密钥或EC2实例角色,您需要具有EC2FullAccess的EC2策略才能访问API。

相关问题