Adding the "Amazon S3 publish" action - Amazon CodeCatalyst

Adding the "Amazon S3 publish" action

This section describes how to add the Amazon S3 publish action to your workflow. The Amazon S3 publish action copies files from a source directory to an Amazon S3 bucket. The source directory can reside in:

When to use this action

Use this action if:

  • You have a workflow that generates files that you want to store in Amazon S3.

    For example, you might have a workflow that builds a static website that you want to host in Amazon S3. In this case, your workflow would include a build action to build the site's HTML and supporting files, and an Amazon S3 publish action to copy the files to Amazon S3.

  • You have a source repository that contains files that you want to store in Amazon S3.

    For example, you might have a source repository with application source files that you want to archive on a nightly basis to Amazon S3.

Example workflow

The following example workflow includes the Amazon S3 publish action, along with a build action. The workflow builds a static documentation website and then publishes it to Amazon S3, where it is hosted. The workflow consists of the following building blocks that run sequentially:

Note

The following workflow example is for illustrative purposes, and will only work with additional configuration.

  • A trigger – This trigger starts the workflow run automatically when you push a change to your source repository. For more information about triggers, see Working with triggers.

  • A build action (BuildDocs) – On trigger, the action builds a static documentation website (mkdocs build) and adds the associated HTML files and supporting metadata to an artifact called MyDocsSite. For more information about the build action, see Building using workflows in CodeCatalyst.

  • An Amazon S3 publish action (PublishToS3) – On completion of the build action, this action copies the site in the MyDocsSite artifact to Amazon S3 for hosting.

Name: codecatalyst-s3-publish-workflow SchemaVersion: 1.0 Triggers: - Type: PUSH Branches: - main Actions: BuildDocs: Identifier: aws/build@v1 Inputs: Sources: - WorkflowSource Configuration: Steps: - Run: echo BuildDocs started on `date` - Run: pip install --upgrade pip - Run: pip install mkdocs - Run: mkdocs build - Run: echo BuildDocs completed on `date` Outputs: Artifacts: - Name: MyDocsSite Files: - "site/**/*" PublishToS3: Identifier: aws/s3-publish@v1 Environment: Name: codecatalyst-s3-publish-environment Connections: - Name: codecatalyst-account-connection Role: codecatalyst-s3-publish-build-role Inputs: Sources: - WorkflowSource Artifacts: - MyDocsSite Configuration: DestinationBucketName: my-bucket SourcePath: /artifacts/PublishToS3/MyDocSite/site TargetPath: my/docs/site

Adding the "Amazon S3 publish" action

Use the following instructions to add the Amazon S3 publish action to your workflow.

Visual
To add the "Amazon S3 publish" action using the visual editor
  1. Open the CodeCatalyst console at https://codecatalyst.aws/.

  2. Choose your project.

  3. In the navigation pane, choose CI/CD, and then choose Workflows.

  4. Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name.

  5. Choose Edit.

  6. Choose Visual.

  7. At the top-left, choose + Actions to open the action catalog.

  8. From the drop-down list, choose Amazon CodeCatalyst.

  9. Search for the Amazon S3 publish action, and do one of the following:

    • Choose the plus sign (+) to add the action to the workflow diagram and open its configuration pane.

      Or

    • Choose Amazon S3 publish. The action details dialog box appears. On this dialog box:

      • (Optional) Choose View source to view the action's source code.

      • Choose Add to workflow to add the action to the workflow diagram and open its configuration pane.

  10. In the Inputs, Configuration, and Outputs tabs, complete the fields according to your needs. For a description of each field, see the "Amazon S3 publish" action reference. This reference provides detailed information on each field (and corresponding YAML property value) as it appears in both the YAML and visual editors.

  11. (Optional) Choose Validate to validate the workflow's YAML code before committing.

  12. Choose Commit, enter a commit message, and then choose Commit again.

YAML
To add the "Amazon S3 publish" action using the YAML editor
  1. Open the CodeCatalyst console at https://codecatalyst.aws/.

  2. Choose your project.

  3. In the navigation pane, choose CI/CD, and then choose Workflows.

  4. Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name.

  5. Choose Edit.

  6. Choose YAML.

  7. At the top-left, choose + Actions to open the action catalog.

  8. From the drop-down list, choose Amazon CodeCatalyst.

  9. Search for the Amazon S3 publish action, and do one of the following:

    • Choose the plus sign (+) to add the action to the workflow diagram and open its configuration pane.

      Or

    • Choose Amazon S3 publish. The action details dialog box appears. On this dialog box:

      • (Optional) Choose View source to view the action's source code.

      • Choose Add to workflow to add the action to the workflow diagram and open its configuration pane.

  10. Modify the properties in the YAML code according to your needs. An explanation of each available property is provided in the "Amazon S3 publish" action reference.

  11. (Optional) Choose Validate to validate the workflow's YAML code before committing.

  12. Choose Commit, enter a commit message, and then choose Commit again.

Variables produced by the "Amazon S3 publish" action

When the Amazon S3 publish action runs, it produces variables that you can use in subsequent workflow actions. For details, see "Amazon S3 publish" action variables in the List of predefined variables.

"Amazon S3 publish" action definition

The Amazon S3 publish action is defined as a set of YAML properties inside your workflow definition file. For information about these properties, see "Amazon S3 publish" action reference in the Workflow definition reference.