尝试使用以下配置创建S3存储桶时,请继续运行此错误:模板验证错误

时间:2019-02-23 04:19:14

标签: amazon-s3 amazon-cloudformation amazon-iam

import re
def decode(inString):
    result=""
    String=re.findall(r'[A-Za-z]|-?\d+\.\d+|\d+',inString)
    if len(String)<2:
        return String[0]
    else:
        for i in range(len(String)):
            if String[i].isdigit():
                result +=  String[i-1] * (int(String[i])-1)
                i+=1
            else:
                result += String[i]
                i+=1            
    return result

print(decode("M"))      #M  <== output
print(decode("abu6"))   #abuuuuuu
print(decode("b2hp11")) #bbhppppppppppp
BucketUser:
    Type: AWS::IAM::User 
    Properties:
      PolicyName: InTheBucket  
      PolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Action:
          - s3:GetObject
          - s3:PutObject
          - s3:PutBucketCORS
          - s3:PutObjectAcl
          Resource: arn:aws:s3:::flask-Bucket

BucketKey:
    Type: AWS::IAM::AccessKey
    Properties:
      Username:
        !Ref BucketUser

Outputs:
  WebsiteURL:
    Value: !GetAtt S3Bucket
    Export:
      Name: S3Bucket
  BucketKey:
    Value: !Ref BucketKey
    Export:
      Name: BucketKey
  SecretAccessKey:
    Value: !GetAtt BucketKey.SecretAccessKey
    Export:
      Name: SecretAccessKey

我一直在引用this

1 个答案:

答案 0 :(得分:1)

检查return values中是否有AWS::S3::Bucket

对于WebsiteURL输出,请尝试:

WebsiteURL:
  Value: !GetAtt S3Bucket.WebsiteURL
  Export:
    Name: S3Bucket