Problems with sample code and default AWS-CLI profile


I’m an architect evaluating serverless for use in some new applications at my place of employment. I’ve previously had AWS-CLI setup and have a local credentials file setup with a default profile.

I’ve followed the instructions on the sample, and installed serverless successfully and created a node template project. When running “serverless deploy” - the deployment seems successful, with no errors - but it isn’t deploying to the region I have setup in my default config, nor does it appear in aws lambda list-functions when I look for the deployment in my deployed lambdas.

I have tried this both with the default generated serverless.yml file, and adding “profile: default” to the provider section as well with the same result. Is there further magic to having the profile picked up correctly - and where is this successful deployment going to if it’s not picking up these credentials?

Thanks in advance.

Stack trace if needed:

D:\Cloud\OneDrive\source\LearningCloud>serverless deploy
Serverless: Deprecation Notice: Starting with the next update, we will drop support for Lambda to implicitly create LogGroups. Please remove your log groups and set "provider.cfLogs: true", for CloudFormation to explicitly create them for you.
Serverless: Packaging service…
Serverless: Uploading CloudFormation file to S3…
Serverless: Uploading service .zip file to S3…
Serverless: Updating Stack…
Serverless: Checking Stack update progress…
Serverless: Stack update finished…

Service Information
service: aws-nodejs
stage: dev
region: us-east-1
api keys:
  aws-nodejs-dev-hello: arn:aws:lambda:us-east-1:490177694113:function:aws-nodejs-dev-hello

D:\Cloud\OneDrive\source\LearningCloud>serverless version

D:\Cloud\OneDrive\source\LearningCloud>aws lambda list-functions
    "Functions": []

1 Like

Update: Adding lambdas through the IAM account configured in credentials manually through the Lambda Console results in visible functions in aws lambda list-functions, so it seems to be an issue wherein my serverless configuration is not picking up credentials/config from local. I’ve checked all zones and the IAM account in question has no lambdas listed.

D:\Cloud\OneDrive\source\LearningCloud>aws lambda list-functions
    "Functions": [
            "Version": "$LATEST",
            "CodeSha256": "oYP1KFMBwZdP/EnifmgDxXwioKoiMunFLZDWPAxIe2U=",
            "FunctionName": "AddedThroughConsole",
            "MemorySize": 128,
            "CodeSize": 216,
            "FunctionArn": "arn:aws:lambda:us-west-2:490177694113:function:AddedThroughConsole",
            "Handler": "index.handler",
            "Role": "arn:aws:iam::490177694113:role/service-role/howdy",
            "Timeout": 3,
            "LastModified": "2016-11-14T18:05:23.446+0000",
            "Runtime": "nodejs4.3",
            "Description": "Added Through the Lambda Console"

I have the solution determined here now. The first issue is why Serverless deployed to a different zone than my AWS - CLI is configured to. The guide implied to me that the AWS-CLI values would be picked up, but upon further research the Serverless CLI documentation on the deploy command merely states that US-EAST-1 will be picked up as the default, and the credentials would be picked up. I would recommend clarifying that between the two documents since the guide specifically talks about configuring AWS-CLI default values, but it’s not a huge deal. It took a substantial amount of time for my function to show up in US-EAST-1, but I’m going to guess that’s a combination of some latency/propogation issues and refresh issues on my AWS account side. Once the function appeared, it ran as expected.

Yeah, this issue comes up because the AWS SDKs don’t alway respect the various values specified in the AWS CLI configuration files (i.e ~/.aws/config and ~/aws/credentials, or whatever the equivalent is on Windows). It’s pretty annoying, because it’s slightly different for the different language SDKs…

As you’ve discovered, the way to do it for Serverless is set region in the provider section of your serverless.yml.

You can always see where the service is being deployed in the summary at the end of a serverless deploy or by running serverless info - your stack trace shows us-east-1 (the default).

Yep - I noticed the US-EAST-1 in the script right off, but there was a rather large delay where the Lambda Console for US-EAST-1 didn’t show the deployment (took about 1 hour for the function to show up, which I’m assuming is just weird behavior). Thanks for the response.

1 hour!?! That would make troubleshooting difficult, but I guess you never know with us-east-1:no_mouth: