aws s3api create-bucket: Create an S3 Bucket in CI
Create a new S3 bucket, with the region quirk that trips up every first-timer.
aws s3api create-bucket provisions a bucket. Outside us-east-1 you must pass --create-bucket-configuration LocationConstraint=<region> matching --region, or the call fails. In CI, prefer Terraform for durable buckets; this command suits one-off or test buckets.
Common flags
--bucket- the globally unique bucket name (required)--region- target region--create-bucket-configuration LocationConstraint=<region>- required outside us-east-1--acl- canned ACL (often rejected when ACLs are disabled by default)
Example in CI
Create a regional bucket for ephemeral test data.
shell
aws s3api create-bucket --bucket ${TEST_BUCKET} --region eu-west-1 --create-bucket-configuration LocationConstraint=eu-west-1Common errors in CI
- An error occurred (BucketAlreadyExists) - the name is taken globally
- An error occurred (BucketAlreadyOwnedByYou) - you already created it (often safe to ignore)
- IllegalLocationConstraintException - LocationConstraint does not match --region
- An error occurred (InvalidLocationConstraint) - LocationConstraint passed for us-east-1
Key takeaways
- create-bucket needs LocationConstraint matching --region outside us-east-1.
- BucketAlreadyOwnedByYou is often idempotent-safe in CI scripts.
- For durable infrastructure, manage buckets with Terraform, not the CLI.
Related guides
aws s3 cp: Copy Files to S3 in CIaws s3 cp copies files and directories to and from S3. Learn the recursive, exclude, and ACL flags plus a CI…
aws s3 ls: List S3 Buckets and Objects in CIaws s3 ls lists buckets, prefixes, and objects in S3. Learn the recursive, human-readable, and summarize flag…
aws cloudformation deploy: Deploy a Stack in CIaws cloudformation deploy creates or updates a stack via change sets. Learn the parameter-overrides and capab…