AWS Sig v4签署API网关

时间:2016-04-21 01:51:11

标签: aws-sdk aws-api-gateway

有没有办法查找apigateway端点的区域并使用它来用sigv4签署您的请求?

我正在使用aws sdk进行签名

let req    = new AWS.HttpRequest( endpoint );
req.method = 'POST';
req.path   = endpoint.path;
req.region = QueryApi.getBaseUrlRegion( this._baseUrl );
req.body   = JSON.stringify( body );

req.headers[ 'Host' ]              = endpoint.host
req.headers[ 'presigned-expires' ] = false
req.headers[ 'Content-Type' ]      = 'application/json'

let signer = new AWS.Signers.V4( req, 'execute-api' )
signer.addAuthorization( this._awsCreds, new Date() )

现在我正在从内部aws execute-api url解析该区域,但这不适用于自定义dns名称。

是使用配置或进行DNS查找的唯一选项吗?

1 个答案:

答案 0 :(得分:1)

Unfortunately, currently there isn't a way to look up the region when using a custom domain name. Using DNS lookup will not work as well because API Gateway is fronted by CloudFront distributions.

相关问题