简体   繁体   English

AWS Config API 返回 403:禁止错误

[英]AWS Config API returning 403: Forbidden Error

I am testing AWS Config APIs using postman and cannot figure out root cause of 403 forbidden error.我正在使用 postman 测试 AWS Config API,但无法找出 403 禁止错误的根本原因。 The authorization is setup using AWS Signature (4) with the awsAccessKeyId and awsSecretAccessKey of the user who has following policies attached:使用 AWS 签名 (4) 设置授权,并使用附加了以下策略的用户的 awsAccessKeyId 和 awsSecretAccessKey:

AWSConfigRoleForOrganizations, AWSConfigRole, AWSConfigUserAccess and AWSConfigRulesExecutionRole AWSConfigRoleForOrganizations、AWSConfigRole、AWSConfigUserAccess 和 AWSConfigRulesExecutionRole

curl --location --request POST 'https://config.us-west-2.amazonaws.com/?Action=ListDiscoveredResources&AUTHPARAMS&Version=2010-05-08' \
--header 'X-Amz-Content-Sha256: {generatedHash}' \
--header 'X-Amz-Date: 20200531T194002Z' \
--header 'Authorization: AWS4-HMAC-SHA256 Credential={accessKeyId}/20200531/us-west-2/config/aws4_request, SignedHeaders=content-length;host;x-amz-content-sha256;x-amz-date, Signature={signature}' \
--header 'Content-Type: text/plain' \
--data-raw '{
    "resourceType": "AWS::EC2::Instance"
}

I cannot find any example of URL parameter or HTTP header requirements for AWS Config API online.我找不到任何 URL 参数或 HTTP header 在线要求的示例Has anyone been able to successfully authentication with AWS Config API if so, provide an example of Parameters or Request Header?是否有人能够使用 AWS Config API 成功进行身份验证,如果是,请提供参数示例或请求 Header?

I was able to successfully fix the 403 forbidden error.我能够成功修复 403 禁止错误。 The Parameter and HTTP header blow work properly and return the response 200:参数和 HTTP header 正常工作并返回响应 200:

curl --location --request POST 'https://config.us-west-2.amazonaws.com/?Action=ListDiscoveredResources&AUTHPARAMS&Version=2010-05-08' \ --header 'Content-Type: application/x-amz-json-1.1' \ --header 'X-Amz-Target: StarlingDoveService.ListDiscoveredResources' \

(omitted rest of header for simplicity) (为简单起见,省略了 header 的 rest)

Having said that, I am still not sure about 'X-Amz-Target: StarlingDoveService.ListDiscoveredResources' .话虽如此,我仍然不确定'X-Amz-Target: StarlingDoveService.ListDiscoveredResources' There is no mention of it in in AWS documentation for AWS Config API . AWS Config API的 AWS 文档中没有提及它。 Stumbled upon it from the AWS discuss forum by luck.幸运地从AWS 讨论论坛偶然发现了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM