How to set user?

I created a user, assigned admin access and configured key in my local, but when I run sls deploy command I am getting error.

ServerlessError: User: arn:aws:iam::660841947412:user/vagrant is not authorized to perform: cloudformation:DescribeStacks on resource: arn:aws:cloudformation:us-east-1:660841947412:stack/simple-dev/*

I don’t know why I am getting the error because the key, and secret I set has admin access. And why user name is user/vagrant, because the user associated with key, and secret has different name on aws. how do I change it ?

It sounds like Serverless isn’t using the user you expect for deployments. How are you telling Serverless which user to use for deployments?

I set aws credentials in credentials file as per serverless documentation.
and then running sls deploy command.
I am begineer with serverless, I don’t know how to specify user during deployment. I believe it is using credentails set but user name is not correct. How do I set that ?

Can I assume this means you’re setting the default profile then running sls deploy without specifying a profile on the command line or setting profile inside your serverless.yml? The Serverless Framework uses the AWS SDK and it’s mechanism for selecting which profile to use unless you specify it. The chances are it’s being overridden by an environment variable somewhere. Trying renaming the profile in your credentials file then deploy using

sls deploy --aws-profile YOUR_PROFILE_NAME
1 Like

Hi buggy,

Thank you very much for your quick response. Yes, I have set only one profile which is default one. I’ll try your suggestion. Thanks :slight_smile:

mentioning profile name explicitly worked “sls deploy --aws-profile default”. But don’t know why it is not used without mentioning it. Thanks @buggy

If you don’t explicitly set the profile then the AWS SDK has a process for determining which one to use. If you want to understand more then read the AWS Guide.

My best guess is you’re setting the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables somewhere.

1 Like

Thanks buggy. Yes, that was the case, I forgot that I had set key and secret in env var for an another project. :slight_smile: