amazon-archives / aws-serverless-auth-reference-app

Serverless reference app and backend API, showcasing authentication and authorization patterns using Amazon Cognito, Amazon API Gateway, AWS Lambda, and AWS IAM.
Other
752 stars 194 forks source link

Where do I set credentials for deployment? #1

Closed paulfryer closed 7 years ago

paulfryer commented 7 years ago

Where should I set credentials for the deployment? I followed all the install steps for the API and am now trying to run "gulp deploy", getting a "missing credentials error". Console output:

paulfryer:~/workspace/api (master) $ gulp deploy
[01:47:53] Using gulpfile ~/workspace/api/gulpfile.js [01:47:53] Starting 'deploy'... [01:47:53] Starting 'create_cloudformation_stack'... [2016-12-18T01:47:53.628Z] INFO: spacefinder/2703 on paulfryer-serverless-4171287: Creating CloudFormation stack... [2016-12-18T01:47:54.678Z] ERROR: spacefinder/2703 on paulfryer-serverless-4171287: step failed { [CredentialsError: Missing credentials in config] message: 'Missing credentials in config', code: 'CredentialsError', errno: 'ECONNREFUSED', syscall: 'connect', address: '169.254.169.254', port: 80, time: Sun Dec 18 2016 01:47:54 GMT+0000 (UTC), originalError: { message: 'Could not load credentials from any providers', code: 'CredentialsError', errno: 'ECONNREFUSED', syscall: 'connect', address: '169.254.169.254', port: 80, time: Sun Dec 18 2016 01:47:54 GMT+0000 (UTC), originalError: { code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', address: '169.254.169.254', port: 80, message: 'connect ECONNREFUSED 169.254.169.254:80' } } } [01:47:54] 'create_cloudformation_stack' errored after 1.05 s [01:47:54] Error: connect ECONNREFUSED 169.254.169.254:80 at Object.exports._errnoException (util.js:907:11) at exports._exceptionWithHostPort (util.js:930:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1077:14) [01:47:54] 'deploy' errored after 1.2 s

justonian commented 7 years ago

Hi Paul-

We probably need to make this more clear in the readme, but the credentials are read from the AWS credentials file. Assuming you're using a Mac or Linux machine, this is typically in the ~/.aws/credentials file. The easiest way to set this up is to install the AWS CLI using the pip tool and then type "aws configure." Assuming you want to use your default profile for the CLI, no other changes are required to deploy the project.

Let us know if that works for you.

Justin

paulfryer commented 7 years ago

I'm trying to get this demo running in a Cloud9 dev environment, which I'm not super familiar with. When I do this:

paulfryer:~/workspace (master) $ sudo pip install awscli --upgrade --force-reinstall

I get this error:

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c ext/_yaml.c -o build/temp.linux-x86_64-2.7/ext/_yaml.o
ext/_yaml.c:4:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
compilation terminated.

Full log attached here:

install-awscli-log.txt

It looks like the main Python file is missing? Perhaps I'm running this from the wrong location? I do have python installed, verified by doing this:

paulfryer:~/workspace (master) $ python --version Python 2.7.6

justonian commented 7 years ago

For Cloud9 workspaces, you first need to install some additional Python development tools to allow the CLI to install correctly. This issue for AWS CLI installation on Cloud9 is documented #https://community.c9.io/t/error-when-installing-aws-cli-on-ubuntu-workspace/11398

You'll need to uninstall the half-installed CLI, then re-install the AWS CLI after installing the extra python dependencies, then run "aws configure." This will prompt you for your AWS access key and AWS secret access key while will then be stored in your AWS credentials file at ~/.aws/credentials. Once this file is created, you can simply run "gulp deploy" and it will pick up the local credentials.

Let us know if you're able to get the deployment to succeed after resolving the AWS CLI installation issue.

justonian commented 7 years ago

To provide the full perspective, though the CLI's generated credentials file is the recommended way to save credentials to local disk securely, there are several options that would work as this project uses the Node.js JavaScript SDK. All options possible are documented at http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html.

paulfryer commented 7 years ago

@justonian Thanks for the info, I did get this deployment working on my local Mac after installing the AWS CLI. I'll try to get Cloud9 working next.