python - python sdk 中的 PutBucketWebsite 命令出错
问题描述
我正在使用下面显示的代码通过 python sdk 在 S3 存储桶中创建静态网站
website_configuration = {
'ErrorDocument': {'Key': 'error.html'},
'IndexDocument': {'Suffix': 'index.html'}
}
s3_client.put_bucket_website(Bucket='bucket_name',
WebsiteConfiguration=website_configuration
)
还尝试在方法参数中明确说明 WebsiteConfiguration。我收到以下错误(带有回溯)
Traceback (most recent call last):
File "/home/ec2-user/environment/aws-modern-application-workshop/sdk_code.py", line 107, in <module>
WebsiteConfiguration=website_configuration
File "/home/ec2-user/.local/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/ec2-user/.local/lib/python3.6/site-packages/botocore/client.py", line 661, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (AllAccessDisabled) when calling the PutBucketWebsite operation: All access to this object has been disabled
似乎是权限问题,但是相同的程序(代码未显示)用于创建存储桶、设置存储桶策略和上传 index.html 和 error.html 文件。此外,我可以在同一个 IDE 会话中通过 AWS CLI 命令创建静态网站(使用 Cloud9)。与 Cloud9 会话关联的 IAM 用户具有 ADMIN 权限,我检查了配置和凭证文件以确保它们分别包含区域和用户密钥。我需要有关如何解决此错误的建议。
解决方案
推荐阅读
- python - 尝试在我的 Windows 电脑上执行以下命令: pip install pyadomd 但出现错误
- c# - 在 C# 中针对不同情况使用 Try Catch 的正确方法
- javascript - for..in 循环返回未定义
- r - 如何让我的双循环填充到数据框中?
- sql - 根据另一个参数按日期过滤
- flutter - 即使在授予存储权限后权限被拒绝
- python - Python pandas 没有像在 Oracle 上那样导入值
- shell - 查找快乐素数的 shell 代码中的问题
- python - 返回 Google SERP 上标题的链接地址
- c# - 如何知道用户何时按下某个 MediaPlayerElement 按钮(播放、暂停、下一曲目等)?