Skip to content

Codepipline s3 source action does not work

0

I want to build a pipeline that will get zip arifacts from chosen s3 bucket and deploy them. the deployment should start right after new file is added to a specific folder, but when i use the s3 source action in codesource stage it fails with an "The object with key 'bucket-path/*.zip' does not exist." error. Enter image description here also the eventbridgde rule does not invoke even after i add new files to the fodler. what can be the issue? Enter image description here

2 Answers
0

Hello,

The error message indicates the S3 source action can't find any files matching the path bucket-path/*.zip.

Problem: Wildcards (*) aren't supported with S3 source actions in CodePipeline.

Solution: Specify the exact filename of the zip artifact you expect.

Here's how to adjust your S3 source action:

Identify the filename: Locate the exact filename (e.g., deployment.zip) of the zip artifact you want to deploy.

Update S3ObjectKey: In your CodePipeline configuration, change the S3ObjectKey parameter of the S3 source action to the specific filename (deployment.zip).

Example:

# Incorrect (using wildcard)
S3Bucket: my-bucket
S3ObjectKey: bucket-path/*.zip

# Correct (specifying filename)
S3Bucket: my-bucket
S3ObjectKey: bucket-path/deployment.zip

link to the official AWS documentation that explains configuration options for the S3 source action and best practices for triggering pipelines based on S3 object changes: https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-S3.html

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago
  • and what if i want to use different zip artifact every time? is it possible to configure it with codepipeline variables, or i need some other aws service?

  • Overwrite the ZIP file each time. Pipeline takes a copy of that zip into its own S3 bucket with its own version ID there. On your source S3 bucket, you can enable versioning and or part of your process, create 2 copies of the zip.. One with you own name and one with the name that triggers the pipeline

0

you're right, specifying a single filename in the S3 source action won't work if you want to deploy different zip artifacts each time.

Here are two approaches to handle dynamic filenames with CodePipeline:

Dynamic filenames in CodePipeline:

  • Specify exact filename (not wildcards) in S3 source action.

Two approaches:

Manual (Environment Variables):

  • Set a variable in CodePipeline with the filename for each deployment.
  • Use a script in your buildspec to download the file based on the variable.

Automated (S3 Event):

  • Configure S3 to trigger a CodeBuild project on new uploads.
  • CodeBuild provides a variable with the uploaded filename for your script to use.

Both methods use variables to handle dynamic filenames

CodeBuild Environment Variables: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html

S3 Event Notifications: https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventNotifications.html

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.