Copy Files To S3

Action ID: aws:s3:cp
NPM Package:

@aws/aws-core-plugin-for-backstage-scaffolder-actions

Description

Copies files to an Amazon S3 bucket

Input Schema

PropertyTypeDescriptionRequired
accountIdstringThe AWS account ID to create the resource.
regionstringThe AWS region to create the resource.
bucketNamestringName of the Amazon S3 bucket.
pathstringFile pattern to copy to the bucket
prefixstringAmazon S3 bucket prefix to add to the files.

Output Schema

No output schema defined for this action.

Usage Examples

Upload a static site build to an S3 website bucket

Copies the build output of a single page application to an S3 bucket under a service specific prefix. Use this after fetching and generating the app with fetch:template.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: ./template
      targetPath: .
      values:
        serviceName: ${{ parameters.serviceName }}
        owner: ${{ parameters.owner }}

  - id: upload-site
    action: aws:s3:cp
    input:
      bucketName: acme-websites-prod
      region: us-east-1
      path: build/**
      prefix: sites/${{ parameters.serviceName }}/

Push service configuration files to a central config bucket

Copies only YAML config files to a shared configuration bucket using a service scoped prefix. Use this to distribute runtime configuration after template generation with fetch:template.

Copy
steps:
  - id: fetch-config-template
    action: fetch:template
    input:
      url: ./config-template
      targetPath: .
      values:
        serviceId: ${{ parameters.serviceId }}
        environment: ${{ parameters.environment }}

  - id: upload-config
    action: aws:s3:cp
    input:
      bucketName: acme-config-prod
      region: us-west-2
      path: config/*.yaml
      prefix: services/${{ parameters.serviceId }}/config/${{ parameters.environment }}/

Cross account upload of build artifacts to a staging bucket

Copies compiled artifacts to an S3 bucket in a different AWS account and region. Use this to deliver builds to a centralized staging account after preparing sources with fetch:template.

Copy
steps:
  - id: fetch-app
    action: fetch:template
    input:
      url: ./app-template
      targetPath: .
      values:
        name: ${{ parameters.name }}
        buildId: ${{ parameters.buildId }}

  - id: upload-artifacts-staging
    action: aws:s3:cp
    input:
      accountId: "123456789012"
      region: eu-west-1
      bucketName: acme-staging-artifacts
      path: dist/**
      prefix: apps/${{ parameters.name }}/builds/${{ parameters.buildId }}/

Publish generated documentation to an S3 techdocs bucket

Copies the docs directory to a TechDocs style bucket using an owner and service prefix. Use this after assembling docs with fetch:template.

Copy
steps:
  - id: fetch-docs
    action: fetch:template
    input:
      url: ./docs-template
      targetPath: .
      values:
        owner: ${{ parameters.owner }}
        service: ${{ parameters.service }}

  - id: upload-techdocs
    action: aws:s3:cp
    input:
      bucketName: acme-techdocs
      region: us-east-2
      path: docs/**
      prefix: techdocs/${{ parameters.owner }}/${{ parameters.service }}/

Upload a versioned Helm chart package to a charts bucket

Copies a packaged Helm chart to an S3 bucket under a versioned prefix. Use this after preparing chart artifacts with fetch:template.

Copy
steps:
  - id: fetch-chart
    action: fetch:template
    input:
      url: ./helm-chart
      targetPath: .
      values:
        chartName: ${{ parameters.chartName }}
        version: ${{ parameters.version }}

  - id: upload-helm-chart
    action: aws:s3:cp
    input:
      bucketName: acme-helm-charts
      region: ap-southeast-1
      path: charts/${{ parameters.chartName }}-${{ parameters.version }}.tgz
      prefix: helm/${{ parameters.chartName }}/${{ parameters.version }}/