1. circleci/aws-s3@4.1.1

circleci/aws-s3@4.1.1

Certified
Sections
Integrate Amazon AWS S3 with your CircleCI CI/CD pipeline easily with the aws-s3 orb.
Created: August 22, 2018Version Published: February 4, 2025Releases: 26
Org Usage:
1455

Orb Quick Start Guide

Use CircleCI version 2.1 at the top of your .circleci/config.yml file.

1 version: 2.1

Add the orbs stanza below your version, invoking the orb:

1 2 orbs: aws-s3: circleci/aws-s3@4.1.1

Use aws-s3 elements in your existing workflows and jobs.

Usage Examples

authentication_with_jobs

The S3 orb allows you to "sync" directories or "copy" files to an S3 bucket. The example below demonstrates how to use the "sync" and "copy" jobs. It also demonstrates the use of OIDC authentication in a job with the required "auth" parameter. The aws-cli orb must be imported and the aws-cli/setup command must be used with a valid AWS role_arn.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 version: '2.1' orbs: aws-cli: circleci/aws-cli@5.1.1 aws-s3: circleci/aws-s3@4.1 workflows: s3-example: jobs: - aws-s3/copy: auth: - aws-cli/setup: profile_name: OIDC-User role_arn: arn:aws:iam::123456789012/role/VALID-S3-ROLE from: PATH/TO/FILE profile_name: OIDC-User to: s3://my-s3-bucket-name - aws-s3/sync: auth: - aws-cli/setup: role_arn: arn:aws:iam::123456789012/role/VALID-S3-ROLE from: bucket to: s3://my-s3-bucket-name/prefix

static_credentials

How to use the S3 orb with static credentials.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 version: '2.1' orbs: aws-cli: circleci/aws-cli@5.1.1 aws-s3: circleci/aws-s3@4.1 jobs: build: docker: - image: cimg/base:current steps: - checkout - run: mkdir bucket && echo "lorem ipsum" > bucket/build_asset.txt - aws-cli/install - aws-s3/sync: arguments: | --acl public-read \ --cache-control "max-age=86400" from: bucket to: s3://my-s3-bucket-name/prefix - aws-s3/copy: arguments: '--dryrun' from: bucket/build_asset.txt to: s3://my-s3-bucket-name workflows: s3-example: jobs: - build: context: AWS_CREDENTIALS

sync_and_copy_with_oidc

The S3 orb allows you to "sync" directories or "copy" files to an S3 bucket. The example below shows a typical CircleCI job where a file "bucket/build_asset.txt" is created, followed by how we can both sync, and/or copy the file. It also demonstrates the use of OIDC authentication by importing the aws-cli orb and providing the aws-cli/setup command with a valid AWS role_arn and profile name. If a profile name is specified with authentication, it must be specified in the copy and sync commands.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 version: '2.1' orbs: aws-cli: circleci/aws-cli@5.1.1 aws-s3: circleci/aws-s3@4.1 jobs: sync_and_copy: docker: - image: cimg/base:current steps: - checkout - run: mkdir bucket && echo "lorem ipsum" > bucket/build_asset.txt - aws-cli/setup: profile_name: OIDC-User role_arn: arn:aws:iam::123456789012/role/VALID-S3-ROLE - aws-s3/sync: arguments: | --acl public-read \ --cache-control "max-age=86400" from: bucket profile_name: OIDC-User to: s3://my-s3-bucket-name/prefix - aws-s3/copy: arguments: '--dryrun' from: bucket/build_asset.txt profile_name: OIDC-User to: s3://my-s3-bucket-name workflows: s3-example: jobs: - sync_and_copy

Jobs

copy

A job that copies a local file or S3 object to another location locally or in S3. https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
arguments
If you wish to pass any additional arguments to the aws copy command (i.e. -sse)
No
''
string
auth
The authentication method used to access your AWS account. Import the aws-cli orb in your config and provide the aws-cli/setup command to authenticate with your preferred method. View examples for more information.
Yes
-
steps
executor
The executor to use for this job. By default, this will use the "default" executor provided by this orb.
No
default
executor
from
A local file or source s3 object
Yes
-
string
profile_name
AWS profile name to be configured.
No
''
string
to
A local target or s3 destination
Yes
-
string
when
Add the when attribute to a job step to override its default behavior and selectively run or skip steps depending on the status of the job.
No
on_success
enum

sync

A job that syncs directories and S3 prefixes. https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
arguments
If you wish to pass any additional arguments to the aws copy command (i.e. -sse)
No
''
string
auth
The authentication method used to access your AWS account. Import the aws-cli orb in your config and provide the aws-cli/setup command to authenticate with your preferred method. View examples for more information.
Yes
-
steps
executor
The executor to use for this job. By default, this will use the "default" executor provided by this orb.
No
default
executor
from
A local file or source s3 object
Yes
-
string
profile_name
AWS profile name to be configured.
No
''
string
to
A local target or s3 destination
Yes
-
string
when
Add the when attribute to a job step to override its default behavior and selectively run or skip steps depending on the status of the job.
No
on_success
enum

Commands

copy

Copies a local file or S3 object to another location locally or in S3. https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
arguments
If you wish to pass any additional arguments to the aws copy command (i.e. -sse)
No
''
string
from
A local file or source s3 object
Yes
-
string
profile_name
AWS profile name to be configured.
No
''
string
role_arn
The Amazon Resource Name (ARN) of the role that the caller is assuming. Role ARN must be configured for web identity.
No
''
string
to
A local target or s3 destination
Yes
-
string
when
Add the when attribute to a job step to override its default behavior and selectively run or skip steps depending on the status of the job.
No
on_success
enum

sync

Syncs directories and S3 prefixes. https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
arguments
Optional additional arguments to pass to the `aws sync` command (e.g., `--acl public-read`). Note: if passing a multi-line value to this parameter, include `\` characters after each line, so the Bash shell can correctly interpret the entire command.
No
''
string
from
A local *directory* path to sync with S3
Yes
-
string
profile_name
AWS profile name to be configured.
No
''
string
to
A URI to an S3 bucket, i.e. 's3://the-name-my-bucket'
Yes
-
string
when
Add the when attribute to a job step to override its default behavior and selectively run or skip steps depending on the status of the job.
No
on_success
enum

Executors

default

An AWS Docker image built to run on CircleCI that contains the AWS CLI and related tools.

Show executor Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
resource_class
Configure the executor resource class
No
medium
enum
tag
Select any of the available tags here: https://circleci.com/developer/images/image/cimg/aws.
No
'2023.05'
string

Orb Source

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 # This code is licensed from CircleCI to the user under the MIT license. # See here for details: https://circleci.com/developer/orbs/licensing version: 2.1 description: | Integrate Amazon AWS S3 with your CircleCI CI/CD pipeline easily with the aws-s3 orb. display: home_url: https://aws.amazon.com/s3/ source_url: https://github.com/CircleCI-Public/aws-s3-orb commands: copy: description: | Copies a local file or S3 object to another location locally or in S3. https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html parameters: arguments: default: "" description: If you wish to pass any additional arguments to the aws copy command (i.e. -sse) type: string from: description: A local file or source s3 object type: string profile_name: default: "" description: AWS profile name to be configured. type: string role_arn: default: "" description: | The Amazon Resource Name (ARN) of the role that the caller is assuming. Role ARN must be configured for web identity. type: string to: description: A local target or s3 destination type: string when: default: on_success description: | Add the when attribute to a job step to override its default behavior and selectively run or skip steps depending on the status of the job. enum: - on_success - on_fail - always type: enum steps: - run: command: |- #!/bin/sh ORB_EVAL_FROM="$(eval echo "${ORB_EVAL_FROM}")" ORB_EVAL_TO="$(eval echo "${ORB_EVAL_TO}")" ORB_STR_ARGUMENTS="$(echo "${ORB_STR_ARGUMENTS}" | circleci env subst)" ORB_STR_PROFILE_NAME="$(circleci env subst "${ORB_STR_PROFILE_NAME}")" if [ -n "${ORB_STR_ARGUMENTS}" ]; then IFS=' ' set -- for arg in $(echo "${ORB_STR_ARGUMENTS}" | sed 's/,[ ]*/,/g'); do set -- "$@" "$arg" done fi if [ -n "${ORB_STR_PROFILE_NAME}" ]; then set -- "$@" --profile "${ORB_STR_PROFILE_NAME}" fi set -x aws s3 cp "${ORB_EVAL_FROM}" "${ORB_EVAL_TO}" "$@" set +x environment: ORB_EVAL_FROM: <<parameters.from>> ORB_EVAL_TO: <<parameters.to>> ORB_STR_ARGUMENTS: <<parameters.arguments>> ORB_STR_PROFILE_NAME: <<parameters.profile_name>> name: S3 Copy << parameters.from >> -> << parameters.to >> when: <<parameters.when>> sync: description: | Syncs directories and S3 prefixes. https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html parameters: arguments: default: "" description: | Optional additional arguments to pass to the `aws sync` command (e.g., `--acl public-read`). Note: if passing a multi-line value to this parameter, include `\` characters after each line, so the Bash shell can correctly interpret the entire command. type: string from: description: A local *directory* path to sync with S3 type: string profile_name: default: "" description: AWS profile name to be configured. type: string to: description: A URI to an S3 bucket, i.e. 's3://the-name-my-bucket' type: string when: default: on_success description: | Add the when attribute to a job step to override its default behavior and selectively run or skip steps depending on the status of the job. enum: - on_success - on_fail - always type: enum steps: - run: command: |- #!/bin/sh ORB_EVAL_FROM="$(circleci env subst "${ORB_EVAL_FROM}")" ORB_EVAL_TO="$(circleci env subst "${ORB_EVAL_TO}")" ORB_STR_ARGUMENTS="$(echo "${ORB_STR_ARGUMENTS}" | circleci env subst)" ORB_STR_PROFILE_NAME="$(circleci env subst "${ORB_STR_PROFILE_NAME}")" if [ -n "${ORB_STR_ARGUMENTS}" ]; then IFS=' ' set -- for arg in $(echo "${ORB_STR_ARGUMENTS}" | sed 's/,[ ]*/,/g'); do set -- "$@" "$arg" done fi if [ -n "${ORB_STR_PROFILE_NAME}" ]; then set -- "$@" --profile "${ORB_STR_PROFILE_NAME}" fi set -x aws s3 sync "${ORB_EVAL_FROM}" "${ORB_EVAL_TO}" "$@" set +x environment: ORB_EVAL_FROM: <<parameters.from>> ORB_EVAL_TO: <<parameters.to>> ORB_STR_ARGUMENTS: <<parameters.arguments>> ORB_STR_PROFILE_NAME: <<parameters.profile_name>> name: S3 Sync when: <<parameters.when>> executors: default: description: | An AWS Docker image built to run on CircleCI that contains the AWS CLI and related tools. docker: - image: cimg/aws:<<parameters.tag>> parameters: resource_class: default: medium description: Configure the executor resource class enum: - small - medium - medium+ - large - xlarge - 2xlarge - 2xlarge+ type: enum tag: default: "2023.05" description: | Select any of the available tags here: https://circleci.com/developer/images/image/cimg/aws. type: string resource_class: <<parameters.resource_class>> jobs: copy: description: | A job that copies a local file or S3 object to another location locally or in S3. https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html executor: << parameters.executor >> parameters: arguments: default: "" description: If you wish to pass any additional arguments to the aws copy command (i.e. -sse) type: string auth: description: | The authentication method used to access your AWS account. Import the aws-cli orb in your config and provide the aws-cli/setup command to authenticate with your preferred method. View examples for more information. type: steps executor: default: default description: The executor to use for this job. By default, this will use the "default" executor provided by this orb. type: executor from: description: A local file or source s3 object type: string profile_name: default: "" description: AWS profile name to be configured. type: string to: description: A local target or s3 destination type: string when: default: on_success description: | Add the when attribute to a job step to override its default behavior and selectively run or skip steps depending on the status of the job. enum: - on_success - on_fail - always type: enum steps: - checkout - steps: <<parameters.auth>> - copy: arguments: <<parameters.arguments>> from: <<parameters.from>> profile_name: <<parameters.profile_name>> to: <<parameters.to>> when: <<parameters.when>> sync: description: | A job that syncs directories and S3 prefixes. https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html executor: << parameters.executor >> parameters: arguments: default: "" description: If you wish to pass any additional arguments to the aws copy command (i.e. -sse) type: string auth: description: | The authentication method used to access your AWS account. Import the aws-cli orb in your config and provide the aws-cli/setup command to authenticate with your preferred method. View examples for more information. type: steps executor: default: default description: The executor to use for this job. By default, this will use the "default" executor provided by this orb. type: executor from: description: A local file or source s3 object type: string profile_name: default: "" description: AWS profile name to be configured. type: string to: description: A local target or s3 destination type: string when: default: on_success description: | Add the when attribute to a job step to override its default behavior and selectively run or skip steps depending on the status of the job. enum: - on_success - on_fail - always type: enum steps: - checkout - steps: <<parameters.auth>> - sync: arguments: <<parameters.arguments>> from: <<parameters.from>> profile_name: <<parameters.profile_name>> to: <<parameters.to>> when: <<parameters.when>> examples: authentication_with_jobs: description: | The S3 orb allows you to "sync" directories or "copy" files to an S3 bucket. The example below demonstrates how to use the "sync" and "copy" jobs. It also demonstrates the use of OIDC authentication in a job with the required "auth" parameter. The aws-cli orb must be imported and the aws-cli/setup command must be used with a valid AWS role_arn. usage: version: "2.1" orbs: aws-cli: circleci/aws-cli@5.1.1 aws-s3: circleci/aws-s3@4.1 workflows: s3-example: jobs: - aws-s3/copy: auth: - aws-cli/setup: profile_name: OIDC-User role_arn: arn:aws:iam::123456789012/role/VALID-S3-ROLE from: PATH/TO/FILE profile_name: OIDC-User to: s3://my-s3-bucket-name - aws-s3/sync: auth: - aws-cli/setup: role_arn: arn:aws:iam::123456789012/role/VALID-S3-ROLE from: bucket to: s3://my-s3-bucket-name/prefix static_credentials: description: | How to use the S3 orb with static credentials. usage: version: "2.1" orbs: aws-cli: circleci/aws-cli@5.1.1 aws-s3: circleci/aws-s3@4.1 jobs: build: docker: - image: cimg/base:current steps: - checkout - run: mkdir bucket && echo "lorem ipsum" > bucket/build_asset.txt - aws-cli/install - aws-s3/sync: arguments: | --acl public-read \ --cache-control "max-age=86400" from: bucket to: s3://my-s3-bucket-name/prefix - aws-s3/copy: arguments: --dryrun from: bucket/build_asset.txt to: s3://my-s3-bucket-name workflows: s3-example: jobs: - build: context: AWS_CREDENTIALS sync_and_copy_with_oidc: description: | The S3 orb allows you to "sync" directories or "copy" files to an S3 bucket. The example below shows a typical CircleCI job where a file "bucket/build_asset.txt" is created, followed by how we can both sync, and/or copy the file. It also demonstrates the use of OIDC authentication by importing the aws-cli orb and providing the aws-cli/setup command with a valid AWS role_arn and profile name. If a profile name is specified with authentication, it must be specified in the copy and sync commands. usage: version: "2.1" orbs: aws-cli: circleci/aws-cli@5.1.1 aws-s3: circleci/aws-s3@4.1 jobs: sync_and_copy: docker: - image: cimg/base:current steps: - checkout - run: mkdir bucket && echo "lorem ipsum" > bucket/build_asset.txt - aws-cli/setup: profile_name: OIDC-User role_arn: arn:aws:iam::123456789012/role/VALID-S3-ROLE - aws-s3/sync: arguments: | --acl public-read \ --cache-control "max-age=86400" from: bucket profile_name: OIDC-User to: s3://my-s3-bucket-name/prefix - aws-s3/copy: arguments: --dryrun from: bucket/build_asset.txt profile_name: OIDC-User to: s3://my-s3-bucket-name workflows: s3-example: jobs: - sync_and_copy
Developer Updates
Get tips to optimize your builds
Or join our research panel and give feedback
By submitting this form, you are agreeing to ourTerms of UseandPrivacy Policy.