amazon-web-services - 在 CFN 资源提供程序测试中创建 S3 存储桶时出现 IllegalLocationConstraintException
问题描述
我正在使用 cloudformation cli 创建一个 Cloudformation 资源提供程序。当我尝试使用本地测试我的资源时,cfn test
出现以下错误:
An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The us-east-2 location constraint is incompatible for the region specific endpoint this request was sent to.
我的代码如下所示:
s3 = session.client("s3")
s3.create_bucket(Bucket='mybucket123',CreateBucketConfiguration={'LocationConstraint': 'us-east-2'})
我也尝试过其他区域,并尝试不使用 LocationConstraint,但我得到与undefined
区域代码所在的单词相同的错误:
s3 = session.client("s3")
s3.create_bucket(Bucket='mybucket123')
cfn test
实际上在 sam local using 中运行代码,sam local start-lambda
所以我有点困惑为什么我什至需要一个区域?
有任何想法吗?
解决方案
您client
还必须设置为您想要的区域:
s3 = session.client("s3", region_name='us-east-2')
s3.create_bucket(Bucket='mybucket123',CreateBucketConfiguration={'LocationConstraint': 'us-east-2'})
推荐阅读
- sql - 如何总结每个索赔忽略日期的损失金额
- solr - 根据 Solr 中的搜索查询请求将字段添加到架构
- javascript - Axios:在 POST 请求的正文中发送变量而不是参数
- javascript - 覆盖日期构造函数
- android - android studio 模拟器和真正的 android 设备 Mate 9 选择的不同布局
- javascript - 移动设备 (iOS) 上 iFrame 的大小问题
- spring-boot - 无法使用客户端中的 Spring Cloud Config 将 Hikari 属性外部化
- python - 使用列表推导而不是通常的 for 循环从重复成员中删除列表
- python - 如何不断地添加到一个字符串?
- r - 如何删除R中同一列中匹配的部分字符串?