问题:
我想通过 SDK 以编程方式获取 quicksight 仪表板 URL(区域中的仪表板:eu-west-1)但是,每当我使用以下区域时,当我使用以下区域时都会出现以下错误:
- eu-west-1:错误:
Operation is being called from endpoint eu-west-1, but your identity region is us-east-1. Please use the us-east-1 endpoint.
- us-east-1:没有错误,但嵌入 url 是 us-east-1 并导致
us-east-1.quicksight.aws.amazon.com refused to connect
浏览器出错,例如:https ://us-east-1.quicksight.aws.amazon.com/embed/ XXXXXX&identityprovider=quicksight&isauthcode=true ',
示例代码:
注意:为简洁起见添加了凭据,但从配置文件加载。也试过Java SDK。
const AWS = require('aws-sdk')
const dotenv = require('dotenv').config()
const init = async () => {
AWS.config.credentials = {accessKeyId: process.env.ACCESS_KEY_ID, secretAccessKey: process.env.SECRET_ACCESS_KEY}
AWS.config.region = 'us-east-1'
// AWS.config.region = 'eu-west-1'
const quicksight = new AWS.QuickSight()
const embedUrlParams = {
AwsAccountId: '111122223333',
DashboardId: '11111111-2222-3333-4444-555555555555',
IdentityType: 'QUICKSIGHT',
UserArn: 'arn:aws:quicksight:us-east-1:111122223333:user/default/quicksight-user-1111'
}
const embedUrlRes = await quicksight.getDashboardEmbedUrl(embedUrlParams).promise()
console.log('embedUrlRes', embedUrlRes)
}
init()
命令行:
当我通过 CLI 调用完全相同时,例如:
aws quicksight get-dashboard-embed-url --aws-account-id 111122223333 --dashboard-id 11111111-2222-3333-4444-555555555555 --identity-type QUICKSIGHT --user-arn "arn:aws:quicksight:us-east-1:111122223333:user/default/quicksight-user-1111" --profile my-quicksight-profile
我在 eu-west-1 中获得了一个完全有效的嵌入 url,它通过浏览器完美嵌入:
https://eu-west-1.quicksight.aws.amazon.com/embed/XXXXXXXX&identityprovider=quicksight&isauthcode=true
所以:
我认为 SDK 在承担角色方面的行为不像 CLI 那样,但我尝试过这种方法并没有成功,并且指向快速的区域端点。
在我进入兔子洞之前,最好看看是否有人经历过同样的事情以及他们是如何解决的。
谢谢!