Search code examples
amazon-web-servicesamazon-s3aws-codepipelineaws-event-bridge

My CodePipeline is not getting triggered on s3 event trigger


My CodePipeline is not getting triggered when I upload code.zip to s3-bucket or I copy code.zip using aws cli (aws s3 cp).

Cloudformation event Rule snippet:

Type: AWS::Events::Rule
    Properties:
      EventPattern:
        source:
          - 'aws.s3'
        detail:
          eventSource:
            - 's3.amazonaws.com'
          eventName:
            - 'CopyObject'
            - 'PutObject'
            - 'CompleteMultipartUpload'
          requestParameters:
            bucketName:
              - 's3-bucket'
            key:
              - 'code.zip'
      State: 'ENABLED'
      Targets:
        -
          Arn: <CodePipeline ARN>'
          Id: 'Target-1'
          RoleArn: <trigger role ARN>

Trigger role policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "codepipeline:StartPipelineExecution"
            ],
            "Resource": "*"
        }
    ]
}

Event Pattern:

{
  "source": [
    "aws.s3"
  ],
  "detail": {
    "eventSource": [
      "s3.amazonaws.com"
    ],
    "requestParameters": {
      "bucketName": [
        "s3-bucket"
      ],
      "key": [
        "code.zip"
      ]
    },
    "eventName": [
      "CopyObject",
      "PutObject",
      "CompleteMultipartUpload"
    ]
  }
}

What is missing here ? Or anyone has any pointers on how this can be debugged further?


Solution

  • The problem was events were not getting triggered out of S3 and when i enabled it from CloudTrail it worked.

    Here is the related answer using which i resolved it: S3 object level events are not getting triggered