AWS 时间流写入获取 "An error occurred (AccessDeniedException) when calling the DescribeEndpoints operation: This operation is not allowed."

AWS timestream-write gets "An error occurred (AccessDeniedException) when calling the DescribeEndpoints operation: This operation is not allowed."

我正在试验 python 的 AWS SDK 以访问 Timestream。我尝试了来自 repository 的内部示例代码,并编写了自己的代码来创建数据库:

import boto3
from botocore.config import Config

client = boto3.client('timestream-write')

response = client.create_database(DatabaseName='test')

示例代码和我自己的代码都出现了以下错误:

AccessDeniedException: An error occurred (AccessDeniedException) when calling the DescribeEndpoints operation: This operation is not allowed.

我用谷歌搜索了一下,但找不到任何相关信息。谢谢!

您用于与 Timestream 交互的凭证应使用 IAM 角色,该角色具有 AWS 托管策略或允许您调用 timestream:DescribeEndpoints 的自定义策略。有关示例,请参见此页面:https://docs.aws.amazon.com/timestream/latest/developerguide/security_iam_id-based-policy-examples.html

假设您将环境配置为使用 AWS CLI 和 运行 aws configure,绑定到这些凭证的 IAM 用户应该是 g运行ted timestream:DescribeEndpoints . https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html

您可能会收到此权限错误,因为您缺少 TableName,这是一个必需的参数。 https://docs.aws.amazon.com/timestream/latest/developerguide/API_CreateTable.html

Timestream 目前仅在少数几个地区可用。确保 boto3 区域配置将正确的区域设置为符合条件的区域。

在您的 iam 角色中添加此权限策略

{
"Version": "2012-10-17",
"Statement": [
    {
        "Sid": "VisualEditor0",
        "Effect": "Allow",
        "Action": [
            "timestream:DescribeEndpoints"
        ],
        "Resource": "*"
    }
] }

DescribeEndpoints 称为 bt sdk,以防您在 vpc 中定义这样的端点接口 查询-cell2.timestream..amazonaws.com.