Amazon S3 source action - Amazon CodePipeline
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Amazon S3 source action

Triggers the pipeline when a new object is uploaded to the configured bucket and object key.

Note

This reference topic describes the Amazon S3 source action for CodePipeline where the source location is an Amazon S3 bucket configured for versioning. For reference information about the Amazon S3 deploy action in CodePipeline, see Amazon S3 deploy action.

You can create an Amazon S3 bucket to use as the source location for your application files.

Note

When you create your source bucket, make sure you enable versioning on the bucket. If you want to use an existing Amazon S3 bucket, see Using versioning to enable versioning on an existing bucket.

If you use the console to create or edit your pipeline, CodePipeline creates a CloudWatch Events rule that starts your pipeline when a change occurs in the S3 source bucket.

You must have already created an Amazon S3 source bucket and uploaded the source files as a single ZIP file before you connect the pipeline through an Amazon S3 action.

Note

When Amazon S3 is the source provider for your pipeline, you may zip your source file or files into a single .zip and upload the .zip to your source bucket. You may also upload a single unzipped file; however, downstream actions that expect a .zip file will fail.

Action type

  • Category: Source

  • Owner: AWS

  • Provider: S3

  • Version: 1

Configuration parameters

S3Bucket

Required: Yes

The name of the Amazon S3 bucket where source changes are to be detected.

S3ObjectKey

Required: Yes

The name of the Amazon S3 object key where source changes are to be detected.

PollForSourceChanges

Required: No

PollForSourceChanges controls whether CodePipeline polls the Amazon S3 source bucket for source changes. We recommend that you use CloudWatch Events and CloudTrail to detect source changes instead. For more information about configuring CloudWatch Events, see Migrate polling pipelines with an S3 source and CloudTrail trail (CLI) or Migrate polling pipelines with an S3 source and CloudTrail trail (Amazon CloudFormation template).

Important

If you intend to configure CloudWatch Events, you must set PollForSourceChanges to false to avoid duplicate pipeline executions.

Valid values for this parameter:

  • true: If set, CodePipeline polls your source location for source changes.

    Note

    If you omit PollForSourceChanges, CodePipeline defaults to polling your source location for source changes. This behavior is the same as if PollForSourceChanges is included and set to true.

  • false: If set, CodePipeline does not poll your source location for source changes. Use this setting if you intend to configure a CloudWatch Events rule to detect source changes.

Input artifacts

  • Number of Artifacts: 0

  • Description: Input artifacts do not apply for this action type.

Output artifacts

  • Number of artifacts: 1

  • Description: Provides the artifacts that are available in the source bucket configured to connect to the pipeline. The artifacts generated from the bucket are the output artifacts for the Amazon S3 action. The Amazon S3 object metadata (ETag and version ID) is displayed in CodePipeline as the source revision for the triggered pipeline execution.

Output variables

When configured, this action produces variables that can be referenced by the action configuration of a downstream action in the pipeline. This action produces variables which can be viewed as output variables, even if the action doesn't have a namespace. You configure an action with a namespace to make those variables available to the configuration of downstream actions.

For more information about variables in CodePipeline, see Variables.

ETag

The entity tag for the object related to the source change that triggered the pipeline. The ETag is an MD5 hash of the object. ETag reflects only changes to the contents of an object, not its metadata.

VersionId

The version ID for the version of the object related to the source change that triggered the pipeline.

Action declaration

YAML
Name: Source Actions: - RunOrder: 1 OutputArtifacts: - Name: SourceArtifact ActionTypeId: Provider: S3 Owner: AWS Version: '1' Category: Source Region: us-west-2 Name: Source Configuration: S3Bucket: my-bucket-oregon S3ObjectKey: my-application.zip PollForSourceChanges: 'false' InputArtifacts: []
JSON
{ "Name": "Source", "Actions": [ { "RunOrder": 1, "OutputArtifacts": [ { "Name": "SourceArtifact" } ], "ActionTypeId": { "Provider": "S3", "Owner": "AWS", "Version": "1", "Category": "Source" }, "Region": "us-west-2", "Name": "Source", "Configuration": { "S3Bucket": "my-bucket-oregon", "S3ObjectKey": "my-application.zip", "PollForSourceChanges": "false" }, "InputArtifacts": [] } ] },

The following related resources can help you as you work with this action.

  • Tutorial: Create a simple pipeline (S3 bucket) – This tutorial provides a sample app spec file and sample CodeDeploy application and deployment group. Use this tutorial to create a pipeline with an Amazon S3 source that deploys to Amazon EC2 instances.