1

I'm trying to add an S3 trigger to a lambda function using CloudFormation. From what I've read about circular references the lambda function and S3 bucket needs to be created first, which I've done with a template and they get created successfully.

Then I go into "Update Stack" and enter the template:

 "Resources": {
        "MyBucket": {
            "Type": "AWS::S3::Bucket",
            "NotificationConfiguration": {
                "LambdaConfigurations": [
                    {
                        "Event": "s3:ObjectCreated:*",
                        "Function": "arn:aws:lambda:ap-southeast-2:newlyCreatedLambda"
                    }
                ]
            },
            "Properties": {
                "BucketName": "MyBucket"
....
....

But when I try to deploy it gives the error:

Template is not valid: Invalid template resource property 'NotificationConfiguration'

Any idea how to get the trigger added or what I'm doing wrong?

3
  • 2
    NotificationConfiguration should be a key in the Properties dictionary Commented Aug 23, 2018 at 17:53
  • Thanks @yorodm! Missed that :) Commented Aug 23, 2018 at 20:51
  • I created a related question here as the update is failing for a different reason: stackoverflow.com/questions/51995003/… Commented Aug 23, 2018 at 22:16

1 Answer 1

2

Here's what we use:

"BucketForFunctionsAcesImportNewFileUploaded": {
  "Type": "AWS::S3::Bucket",
  "Properties": {
    "NotificationConfiguration": {
      "TopicConfigurations": [],
      "QueueConfigurations": [],
      "LambdaConfigurations": [
        {
          "Function": {
            "Fn::GetAtt": [
              "FunctionsAcesImportNewFileUploaded",
              "Arn"
            ]
          },
          "Event": "s3:ObjectCreated:*"
        }
      ]
    },
    "VersioningConfiguration": {
      "Status": "Suspended"
    }
  },
  "DeletionPolicy": "Delete"
}
Sign up to request clarification or add additional context in comments.

2 Comments

Where do you create the S3 bucket in this case? And do you have a YAML version of this by any chance?
This is the definition for the bucket... "Type": "AWS::S3::Bucket". No, no YAML, sorry

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.