Named AWS Profiles in Hugo Deploy

I would like to specify a named AWS profile in the site deployment config file when using hugo deploy, because I have several profiles (work and personal) set up on my computer. I have done some searching online and in this forum, and it doesn’t appear to be an existing option. If it isn’t an existing option, I would like to try contributing this to the project myself, but this would be my first contribution to any open source software, so any tips would be appreciated.

Some more info:

I am using Powershell 7, and I have tried:
set AWS_PROFILE=personal
hugo deploy

but this doesn’t seem to work (403, same as just using hugo deploy).

I have also tried:
aws configure
hugo deploy

This appends a new entry to my existing aws config file which I don’t want. Also, hugo deploy still tries to use the original default credentials and fails.

The following works fine, but I really want to be able to do this using hugo deploy:
hugo -D
cd ./public
aws s3 sync . s3://mybucket --profile <my personal profile>

If I have missed something or if there is an elegant solution to this, please let me know. Thanks

1 Like

This is quite old but if anyone comes upon this, please see:

You can use named AWS profile as suggested in the earlier post by @RickCogley.

That is perfect for your personal projects. However, I would like to warn about using this in projects that involve multiple authors, as it would require that all of them use the same name for the profile as you did for CI/CD.
Even if you are using a central server for deployments, make sure that these secrets are not stored as plain text files.
For deployment to AWS S3, I would recommend using AWS Amplify or setting up a secure CI/CD pipeline.

That’s right. The team would have to decide how to run such a thing if they were using zsh functions. However, in a team it is much better to use a CI/CD workflow - Github Actions, Circle CI and so on.