Question

Securely provide credentials with aws-sdk/client-s3

I am working with a Laravel/Vue/Inertia project and trying to upload many pdfs/mp3s multi-part. I am trying to upload these using javascript and the aws sdk.

https://docs.digitalocean.com/products/spaces/how-to/use-aws-sdks/ I read through this article and it is loading a secret key through the node env vars. I would have to use vite env vars, I think. This isn’t secure.

How can I provide the credentials in a secure way?

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
August 23, 2024

Heya,

A common and secure approach is to generate pre-signed URLs on the server side (Laravel), which your frontend (Vue.js with Inertia) can then use to upload files directly to DigitalOcean Spaces. This way, your sensitive credentials never touch the client-side code.

Regards

Spot on about env vars! While Vite env vars are convenient, they’re not ideal for secrets. Consider using a library like dotenv to load environment variables from a separate .env file that you exclude from version control.

I will take a different approach

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
Animation showing a Droplet being created in the DigitalOcean Cloud console