Resolution
If the Upload a package to an AWS S3 bucket step fails with The specified bucket is not valid and the bucket name field contains an Octopus variable, the step is most likely receiving a bucket name that isn't plain text. To confirm it, replace the variable with the literal bucket name, create a new release, and deploy. If that deployment succeeds, the problem is limited to how the variable reaches the step. To keep deploying while you fix it, leave the literal name in place, or change the variable so it holds the final bucket name as plain text. To find out what the step actually received, print the evaluated variables to the task log.
Symptom
The step fails before any file is uploaded, and the task log shows:
Error | Amazon.S3.AmazonS3Exception: The specified bucket is not valid.
Error | ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.
...
Error | at Amazon.S3.Util.AmazonS3Util.DoesS3BucketExistV2Async(IAmazonS3 s3Client, String bucketName)
Error | at Calamari.Aws.Deployment.Conventions.CreateS3BucketConvention.EnsureBucketExists(Func`1 clientFactory, String bucketName)
...
Fatal | The remote script failed with exit code 100
You may also see one or more of the following:
- The step succeeds with a literal bucket name and fails when the field uses a variable that holds the same value.
- A release that deployed successfully before now fails on the same step, with no change to the AWS account, the bucket, or the permissions.
- The log never shows the line
Bucket <name> exists in region <region>. Skipping creation.In a successful run, that line appears at the start of the step and tells you the name the step used.
Scope: when this is the right article
Use this article when all of the following are true:
- The failing step is Upload a package to an AWS S3 bucket.
- The error is
The specified bucket is not valid. - The bucket name field uses a variable, such as
#{S3.BucketName}.
This isn't the right article when:
-
The error is a permissions or region error.
Forbidden, access denied, or theAWS-S3-ERROR-0001toAWS-S3-ERROR-0003codes point to the account, the policy, or the region. See the error messages in the S3 step documentation and the AWS permissions Octopus requires. - The error is about bucket creation or ownership. If the name is valid but the account can't create or use the bucket, you see a permissions error instead. Check the policy examples in the S3 step documentation.
- The literal name also fails. If the hard-coded name fails with the same error, the problem isn't variable substitution. Check the name against the AWS rules in the diagnosis steps below.
Cause
The step evaluates the bucket name field with variable substitution at deployment time. AWS rejects a bucket name that doesn't follow its naming rules, and it reports that as The specified bucket is not valid. The error is about the value the step sent, not about the bucket you meant. The value is usually invalid for one of these reasons:
-
The variable wasn't resolved. The step sent the literal text, for example
#{S3.BucketName}, because the reference is misspelled, the variable isn't scoped to the environment being deployed to, or the release snapshot doesn't contain the variable. - The value resolved to something malformed. It has uppercase characters, underscores, a trailing space or newline, or a chain of references in which a variable resolves to another unresolved reference.
- The value is empty. An undefined reference evaluates to an empty string.
Diagnosis and fix
1. Confirm the failure is in the bucket name
- Open the failed task and select Task log, then turn on Verbose.
- Find the failing step. Confirm that the error is raised before any
Attempting to uploadlines, and that noBucket <name> exists in region <region>line appears. - If you see
Forbidden, anAWS-S3-ERRORcode, or an access error right after an upload, don't worry. Your bucket name is fine. This is an access issue, and the Error messages section of the S3 step documentation walks you through how to fix it.
2. Test with a literal bucket name
- In the step, replace the variable in the bucket name field with the literal bucket name. Save the process.
- Create a new release. A release keeps a snapshot of the process, so a deployment of an existing release still uses the variable.
- Deploy to one environment.
If the deployment succeeds, the problem is specific to variable substitution in this field. Continue with step 3. If it fails with the same error, the name itself is invalid. Go to step 4.
3. Check the value the step received
- Add the project variables
OctopusPrintVariablesandOctopusPrintEvaluatedVariableswith the valueTrue, or select the debug mode option when you create the deployment. See Debug problems with Octopus variables for the exact steps. - Create a new release, or update the variable snapshot of the existing release, then deploy with Verbose enabled.
- In the log for the failing step, find your bucket name variable in the evaluated variables, and compare it with the name you expect:
| What you see | What it means |
|---|---|
Text that still contains #{
|
The reference wasn't resolved. Check the spelling and the scoping, and check that the variable is in the release snapshot. |
| An empty value, or no entry for the variable | The variable is undefined, or isn't scoped to this environment, tenant, or channel. |
| A value with spaces, a line break, or uppercase characters | The value resolved but is malformed. Fix the variable value. |
| A valid name that differs from the bucket you expected | A different variable or scope won. Review the variable's values and scopes in the variable documentation. |
| The exact bucket name you expect, and it's valid | The variable resolved correctly. Go to step 4. |
Turn the two print variables off when you finish. They increase the size of the log and can slow deployments.
4. Check the name against the AWS rules
An evaluated value can look right and still be invalid. The AWS bucket naming rules are the source of truth. The most common problems are:
- The name isn't 3 to 63 characters long.
- It contains uppercase letters, underscores, spaces, or other characters besides lowercase letters, numbers, periods, and hyphens.
- It doesn't start and end with a letter or number, or it contains two adjacent periods.
- It's formatted like an IP address.
- It uses a prefix or suffix that AWS reserves.
A name that follows the rules, but is rejected with The specified bucket is not valid only when it comes from a variable, points to variable evaluation rather than the name.
Known issues
- Known product defect. In May 2026, a defect stopped the bucket name field from evaluating variables correctly. It caused the symptoms in this article for variables that were correct. If your literal-name test succeeds, your variable looks correct in the evaluated variables, and your instance was upgraded around that time, check GitHub issue 10008 for the affected and fixed versions. Octopus Cloud instances upgrade during their maintenance window, so check the version your instance is running before you open a ticket.
- Missing built-in capability. If you need behavior the step doesn't offer, such as building the bucket name from several values at deployment time without a variable chain, the step can't be made to do it with this troubleshooting. Use a script step, as described in step 5, and see the S3 step documentation for what the step supports.
Information to gather before contacting support
If the literal name works, the evaluated value looks valid, and the issue isn't the known defect, send Octopus Support:
- The task ID (
ServerTasks-###) of a failed deployment, and of a successful one that used the literal name. - The Octopus Server version and the Calamari version from the Verbose log, and whether the instance is Octopus Cloud or self-hosted.
- The Verbose task log with the evaluated variables for the failing step. Remove sensitive values before you send it.
- A JSON export of the step from the deployment process, and the scopes of the bucket name variable.
Verify
- Deploy a new release to the environment that failed.
- In the Verbose task log, confirm the step prints
Bucket <name> exists in region <region>followed byAttempting to uploadlines. - Confirm that the bucket name in that line is the one you expected.
- If you used a workaround, deploy to every environment that uses the step, because each environment can resolve a different value.
- Turn off
OctopusPrintVariablesandOctopusPrintEvaluatedVariablesif you added them.
Related
- Upload a package to an AWS S3 bucket: how the step is configured, upload behavior, and the step's error messages.
-
Variable substitutions: the syntax Octopus uses to evaluate
#{Variable}references. - Debug problems with Octopus variables: how to print evaluated variables to the task log.
- Create an AWS S3 bucket: the built-in step for creating a bucket with specific settings.
- AWS account variables: how the step authenticates, if the failure is about credentials instead.
- AWS bucket naming rules: the complete list of rules AWS enforces.
- GitHub issue 10008: the tracked product defect for bucket name variables.