我正在尝试使用C ++ SDK连接到AWS但无法连接我在CLI中使用此访问密钥是否需要为C ++ API访问授予任何单独的权限?我的代码如下: -
Checkout.configure({
merchant: 'xxxxxx',
order: {
amount: function() {
//Dynamic calculation of amount
return 70;
},
运行此代码后,我得到以下输出: -
干运行失败以描述实例请求:无法连接到端点
在〜/ .aws / credentials中设置我的凭证后,我运行了ec2的集成测试代码,其输出如下: -
static const char* AWS_ACCESS_KEY_ID = "XXXX";
static const char* AWS_SECRET_ACCESS_KEY = "XXXXXX";
int main()
{
Aws::SDKOptions options;
Aws::InitAPI(options);
{
Aws::Auth::AWSCredentials credentials(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY);
Aws::EC2::EC2Client *ec2=new Aws::EC2::EC2Client(credentials);
Aws::EC2::Model::DescribeInstancesRequest request;
request.SetDryRun(true);
auto dry_run_outcome = ec2->DescribeInstances(request);
if (dry_run_outcome.GetError().GetErrorType() != Aws::EC2::EC2Errors::DRY_RUN_OPERATION)
{
std::cout << "Failed dry run to describe instance request : "<< dry_run_outcome.GetError().GetMessage() << std::endl;
return 0;
}
else
{
std::cout << "DRY RUN Succeeded , dry_run_outcome.IsSuccess() = "<< dry_run_outcome.IsSuccess() << std::endl;
}
}
Aws::ShutdownAPI(options);
return 0;
}
注意::我可以使用此代码从EC2实例连接,但不能从本地计算机连接,它运行的是Ubuntu 18.04 LTS,10 GB RAM和i7 CPU。