S3 Creation CloudFormation导致400错误请求 [英] S3 Creation CloudFormation results in 400 Bad Request
问题描述
使用CloudFormation创建S3存储桶时出现此问题。我收到400错误的要求。
aws cloudformation deploy --profile DEV --stack-name testBucket-模板文件create_bucket.yml --region us-east-1 --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM --parameter-overrides BucketName = myBucket
模板:
AWSTemplateFormatVersion:2010-09-09
参数:
BucketName:
说明:每个表的预配置读取吞吐量
类型:字符串
资源:
MYBUCKET:
类型:AWS :: S3 :: Bucket
属性:
BucketName:$ {BucketName}
MYBUCKETPOLICY:
类型:AWS :: S3 :: BucketPolicy
属性:
存储桶: !Ref MYBUCKET
PolicyDocument:
ID:ReportPolicy
版本: 2012-10-17
声明:
-Sid:ReportBucketPolicyDoc
效果:允许
操作: s3:*
主体:
AWS :!加入[,[ arn:aws:iam :: ,!Ref AWS :: AccountId,:root]]
资源:!Join ['',['arn:aws:s3 :::',!Ref MYBUCKET,'/ *']]
错误
错误请求(服务:Amazon S3;状态码:400;错误代码:400错误的
请求;申请编号:B4AEAA3C454B7868; S3扩展请求ID:
ATFscTA4dQw8J8AYUfkIARYhiT4 / BpVWRcD172WnR75Uzm + i5dlHOTC2HCb9drkO16dzYiELJZc =)
MYBUCKET:
类型:AWS :: S3 :: Bucket
属性:
BucketName:!Ref BucketName
I have this problem when creating S3 bucket using CloudFormation. I get a 400 Bad request. Would appreciate if anyone can help.
aws cloudformation deploy --profile DEV --stack-name testBucket --template-file create_bucket.yml --region us-east-1 --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM --parameter-overrides BucketName=myBucket
Template:
AWSTemplateFormatVersion: 2010-09-09
Parameters:
BucketName:
Description: Provisioned read throughput for each table
Type: String
Resources:
MYBUCKET:
Type: AWS::S3::Bucket
Properties:
BucketName: ${BucketName}
MYBUCKETPOLICY:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref MYBUCKET
PolicyDocument:
Id: ReportPolicy
Version: "2012-10-17"
Statement:
- Sid: ReportBucketPolicyDoc
Effect: Allow
Action: "s3:*"
Principal:
AWS: !Join ['', ["arn:aws:iam::", !Ref "AWS::AccountId", ":root"]]
Resource: !Join ['', ['arn:aws:s3:::', !Ref MYBUCKET, '/*']]
Error
Bad Request (Service: Amazon S3; Status Code: 400; Error Code: 400 Bad Request; Request ID: B4AEAA3C454B7868; S3 Extended Request ID: ATFscTA4dQw8J8AYUfkIARYhiT4/BpVWRcD172WnR75Uzm+i5dlHOTC2HCb9drkO16dzYiELJZc=)
You should be using !Ref BucketName instead of ${BucketName}
MYBUCKET:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref BucketName
这篇关于S3 Creation CloudFormation导致400错误请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!