Search code examples
amazon-web-servicesaws-lambdaserverless-framework

AWS profile doesn't seem to be configured! Serverless framework error?


Background:-I have a gateway account( with no permissions) in which users are created and in order to access aws resources we use roles having admin access.

config file

[profile gateway]
region = ap-southeast-1
output = json

[profile DA]

region = ap-south-1
output = json
role_arn = arn:aws:iam::xxxxxxxxxxxxx:role/jatin
mfa_serial = arn:aws:iam::xxxxxxxxxx:mfa/atin
source_profile = gateway

credentials file

[gateway]
aws_access_key_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
aws_secret_access_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Now I am trying to deploy my lambda using serverless deploy --aws-profile "DA", it says AWS profile "DA" doesn't seem to be configured

however, if I run aws s3 ls --profile "DA" its works perfectly, so i guess there is no problem with the configuration of profiles and credentials


Solution

  • This is a known issue with Serverless, Serverless only checks ~/.aws/credentials for the profile and not ~/.aws/config.

    There are multiple Serverless forum posts about this, e.g. this one.

    Change your ~/.aws/credentials file to this and it should work:

    [gateway]
    aws_access_key_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    aws_secret_access_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    
    [DA]
    aws_access_key_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    aws_secret_access_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    role_arn = arn:aws:iam::xxxxxxxxxxxxx:role/jatin
    mfa_serial = arn:aws:iam::xxxxxxxxxx:mfa/atin
    source_profile = gateway