【问题标题】:Javascript access to dynamodb via cognito with different regionsJavascript 通过不同地区的 cognito 访问 dynamodb
【发布时间】:2016-03-23 06:06:32
【问题描述】:

我的认知区域是东京 (ap-northeast-1),而 DynamoDB 设置在悉尼 (ap-southeast-2)。我遇到的问题是,如果我配置

AWS.config.region = 'ap-northeast-1';

然后我可以访问凭证,但 AWS 假设我的数据库位于同一区域,我得到:

POST https://dynamodb.ap-northeast-1.amazonaws.com/ 400 (Bad Request)

如果我配置

AWS.config.region = "ap-southeast-2";

然后我得到:

OPTIONS https://cognito-identity.ap-southeast-2.amazonaws.com/ net::ERR_NAME_NOT_RESOLVED

大概是因为找不到身份。

现在 Cognito 仅在 3 个区域可用,没有一个与我拥有的任何资源相对应。

那么如何同时使用两者呢?

【问题讨论】:

    标签: javascript amazon-web-services amazon-dynamodb amazon-cognito


    【解决方案1】:

    您可以为 Cognito 的区域设置 SDK 的全局配置,并使用 Service specific configuration 实例化其他区域的服务客户端。

    //Set global region
    AWS.config.region = 'ap-northeast-1';
    
    //Get identity and credentials from Cognito
    
    //Get dynamo db region specific client
    var dynamoDB = new AWS.DynamoDB({region: "ap-southeast-2"});
    

    【讨论】:

      猜你喜欢
      • 2020-01-19
      • 2019-06-20
      • 2016-10-25
      • 1970-01-01
      • 2017-07-22
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 2016-01-08
      相关资源
      最近更新 更多