https://serverless-stack.com/ logo
#help
Title
# help
r

Ross Gerbasi

03/09/2022, 8:23 PM
Does
sst deploy
read from
env
files early enough to set a profile? Just checking out the docs here, https://docs.serverless-stack.com/packages/cli#aws-profile realizing I would like to swap profiles. If I have a
AWS_PROFILE
in my
.env
or
.env.production
will that get picked up or does it need to get set prior to running the command
AWS_PROFILE=production npx sst deploy
t

thdxr

03/09/2022, 8:45 PM
I believe people have profile in their .env
r

Ross Gerbasi

03/09/2022, 9:19 PM
so does that mean that
.env.local
would work? seems like its not.
sst start
or
sst deploy
another dev is testing here actually haha doesnt look like its working
Looks like it will pick up the
AWS_PROFILE
if its an existing environmental variable, but doesnt look like dotenv loading is going applied
so @thdxr or @Frank I am curious what your thoughts are on this. We have finally moved from using our personal AWS accounts to per user company sandboxes. So each dev has a default profile already, likely hooked to their personal AWS account. However now everyone will want to swap over to their company sandbox when working on company specific projects. Do you recommend we all use the AWS CLI and swap profiles there (global AWS_PROFILE swapping) or is there a way within a SST project to let is know which profile to use? The docs talk about using
AWS_PROFILE
in commands, however this doesn't work great as most commands are in a
package.json
as a script. Each developer will have a different profile name so we can't put this in there and have it in source control. I would think if
AWS_PROFILE
in
.env.local
worked that might be the cleanest way.
t

thdxr

03/10/2022, 2:23 AM
can you have everyone follow a convention that names their personal profile as
AWS_PROFILE=company-personal
the nice thing about that is it prevents people from having to think about .env files and accidentally doing sst start in the wrong env
Copy code
[profile ironbay-dev]
sso_start_url = <https://ironbay.awsapps.com/start>
sso_region = us-east-2
sso_account_id = 280826753141
sso_role_name = AdministratorAccess
region = us-east-2
credential_process = aws-sso-util credential-process --profile ironbay-dev
This is my personal aws account but I still give it a generic
ironbay-dev
name
instead of
ironbay-thdxr
which is what it actually is
r

Ross Gerbasi

03/10/2022, 2:25 AM
Alright that's fair, another possible solution is to try to standardize profile names.
So in that case we would then be forcing that profile in all our package.json scripts ?
t

thdxr

03/10/2022, 2:27 AM
yeah that's what I do
r

Ross Gerbasi

03/10/2022, 2:28 AM
Do you know how would that play in with seed deploys? We just started down that path so I am not too experienced. Does it do
npm run deploy
or do all its own
npx sst
commands
t

thdxr

03/10/2022, 2:52 AM
I believe for sst projects it calls sst directly
but @Frank knows for sure, I'm less familiar with seed
r

Ross Gerbasi

03/10/2022, 2:53 AM
Alright, so this may not be horrible. if devs want to use a different profile they could just call
sst
commands directly with
npx
and baking profile into scripts will keep people from deploying to the wrong place. just need everyone to make a profile to follow a standard. Probably the simplest solution.