hugo deploy fails with 'Failed to create deployment target' on S3 despite valid credentials
0 reputation · 02 Feb 2024, 21:51 UTC
0 reputation · 02 Feb 2024, 21:51 UTC
The hugo deploy command returns 'Failed to create deployment target' when attempting to deploy to an S3 bucket, even though AWS credentials are properly configured and the bucket exists with correct permissions. This error occurs consistently across multiple Hugo versions (0.80+) when using the standard S3 deployment target configuration in config.toml.
The deployment configuration includes the required [deployment] section with S3 target parameters, environment variables for credentials are properly expanded, and the same credentials work for manual AWS CLI deployments to the same bucket. Running hugo config shows the deployment settings are being parsed correctly, and hugo deploy --verbose confirms the target creation step fails without additional diagnostic information.
This suggests the issue may be related to how Hugo validates or initializes deployment targets, potentially involving credential resolution timing, region configuration, or a mismatch between Hugo's deployment target expectations and the actual S3 bucket configuration.
Hugo's Failed to create deployment target message is produced before any S3 API call is made. The deployment subsystem validates the target definition locally, so working aws CLI credentials and correct bucket permissions do not prevent this failure. The most common cause is a missing or malformed required field in the [deployment.targets] table—most often region.
Confirmed: Hugo parses the [deployment] section at startup and constructs the target from that configuration. If a required key is absent or has the wrong type, target creation fails immediately. The AWS SDK for Go bundled with Hugo does not reliably inherit a default region from ~/.aws/config for this step; Hugo expects the region to be present in the deployment target itself.
Likely explanation: Your credentials are valid, but the S3 target is missing an explicit region, or the bucket name and region pair are not recognized by the AWS SDK version bundled with your Hugo release.
Temporarily replace your deployment target with the smallest valid definition and run hugo deploy --verbose:
[deployment]
[[deployment.targets]]
name = "s3"
provider = "S3"
bucket = "your-bucket-name"
region = "us-east-1"
If the wrapped error disappears and the upload proceeds, the original failure was a missing or malformed field in your previous configuration.
Hugo uses the standard AWS SDK credential chain. If the AWS CLI works from the same shell but Hugo does not, confirm that the same environment variables and credential files are visible to the Hugo process:
env | grep AWS
ls -l ~/.aws/credentials
Inside containers or IDE terminals, ~ may resolve to a different home directory, or AWS_* variables may not be exported.
Target creation does not call S3, so permission changes will not affect this error. IAM permissions such as s3:PutObject matter only after the target is created and the upload begins.
Hugo's deployment schema and the bundled AWS SDK have changed across releases. If the minimal target above still fails, the exact Hugo version becomes the deciding diagnostic detail—share it to pinpoint a schema mismatch.
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 03 Feb 2024, 06:37 UTC
When encountering the 'Failed to create deployment target' error in Hugo for S3, verifying the S3 region is a critical, often overlooked step.
The region configured within the Hugo deployment settings must precisely match the actual region of the target S3 bucket in the AWS console. A mismatch can cause initialization failures even if credentials and bucket existence are confirmed via the AWS CLI.