Can SLS component deploys use AWS profiles?

While I have been using the serverless framework since it’s inception, I am trying out components for the first time this weekend.

I work with numerous clients and have my IAM credentials for each configured in ~/.aws/credentials. This has always worked well for SLS Lambda functions as I can deploy with sls deploy --aws-profile {profile-name} as documented in https://serverless.com/framework/docs/providers/aws/guide/credentials#using-the-aws-profile-option.

However, when I try the same for deploying a component I get

Error: Forbidden: Invalid credentials or this AWS S3 bucket name may already be taken

Does Serverless component deployment support AWS profiles? Or do I have to add my secret and key to an .env file? As long as I remember to add .env to .gitignore it should be safe, but the risk is still greater than using the AWS profile. I also have built up over time a series of bash scripts for automating my flow that make heavy use of profiles. It would be a shame to have to start rewriting those just so I can use Serverless components.

Yes you can, assuming you are on mac or linux you can set the AWS_PROFILE environment variable

AWS_PROFILE=profile-name sls deploy

Thanks @apsoto_wurl but unfortunately that’s not quite what I was asking. Both the AWS CLI and SLS CLI (for functions) allow the profile to be set using a --profile flag. Since we switch between so many client accounts throughout the day we have built a bash framework around a lot of the common task, and that framework expects and passes the --profile flag. For some reason Serverless component management does not accept that flag.

@tforster ok, I recall trying --profile and it not working, so my example above is what I figured out as my work around.

Good luck, and please post back if you find a way for it to work.