0

创建云形成模板以创建带有通知的存储桶。

以下是代码:

AWSTemplateFormatVersion: '2010-09-09'

Parameters:
  CBRS3ToS3IADelay:
    Description: Number of days before an S3 object is transitioned from S3 to S3-IA
    Type: Number
    Default: 365
  CBRS3ToGlacierDelay:
    Description: Number of days before an S3-IA object is transitioned from S3-IA to Glacier.
    Type: Number
    Default: 1460
  CBRBucketName:
    Description: S3 bucket name
    Type: String
    Default: "my-bucket-test0011"

Resources:
  CBRS3Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName:
        Ref: CBRBucketName
      AccessControl: Private
      LifecycleConfiguration:
        Rules:
          - Id: CbrCertReportGlacierArchiveRule
            Status: Enabled
            Transitions:
              - StorageClass: STANDARD_IA
                TransitionInDays: !Ref CBRS3ToS3IADelay
              - StorageClass: GLACIER
                TransitionInDays: !Ref CBRS3ToGlacierDelay
      NotificationConfiguration:
        LambdaConfigurations:
          -
            Function: "arn:aws:lambda:xxxx:xxxx:function:xxxx"
            Event: "s3:ObjectCreated:Put"
            Filter:
              S3Key:
                Rules:
                  -
                    Name: suffix
                    Value: ".gz"
      Tags:
        - Key: PRODUCT
          Value: CRAWS
      VersioningConfiguration:
        Status: Enabled

使用通知块的代码。但上面的模板不适用于通知。

收到以下错误:

Unable to validate the following destination configurations (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument

我可以从控制台做。

有人帮我解决这个问题吗?

4

2 回答 2

1

这已经晚了,所以更多地回答自己这个问题(只是设法解决了同样的问题):由于对 s3 进行初步检查以调用该 lambda 函数,它失败了,我们将需要这个:

  CBRS3BucketCanInvokeFunctionX:
    Type: 'AWS::Lambda::Permission'
    Properties:
      FunctionName: ARN_OF_FUNCTION_X
      Action: 'lambda:InvokeFunction'
      Principal: s3.amazonaws.com
      SourceAccount: !Ref 'AWS::AccountId'
      SourceArn: !Sub 'arn:aws:s3:::${CBRBucketName}'

您的 CBRS3Bucket 还需要让上述资源首先运行:

  CBRS3Bucket:
    Type: AWS::S3::Bucket
    DependsOn: CBRS3BucketCanInvokeFunctionX
于 2020-07-24T04:52:55.787 回答
0

尝试使用 .gz 并只输入 gz。

于 2019-02-21T16:19:05.577 回答