How to set up AWS Credentials


To deploy to AWS you need to set up some AWS credentials following these steps:

  1. Create a new user in AWS IAM
    1. With “programmatic access” only
    2. “Attach existing policies directly” – choose “AdministratorAccess”
    3. Create the user but DON’T CLOSE THE CREDENTIALS SCREEN
  2. Add the credentials to your computer (AWS CLI or manually edit the file)

That’s all you need to do. Now you can make requests to your AWS account using the Serverless Framework, CDK or CLI.

If you want some more detailed steps then here they are:

Create a new user in AWS IAM

To create a user, log into your AWS console and search for IAM. Click on users on the left menu and then Add users.

Give your user profile a name and set it to have Access key - Programatic access only.

Adding a user

Click Next: Permissions and here we’re going to Attach existing policies directly choosing the AdministratorAccess policy.

Adding AdministratorAccess

Click Next until you get to the Create user screen that looks like this. Stop here and do not click close.

Getting the User Credentials

Add AWS credentials to your computer

There are two ways add your AWS Credentials via the CLI or by manually editing the file.

Adding with CLI

First you need to make sure you have the AWS CLI installed.

%: aws --version
aws-cli/2.4.13 Python/3.8.8 Darwin/21.5.0 exe/x86_64 prompt/off

If you don’t get a message like that, you need to install the AWS CLI first.

Now you can run AWS Configure. You then just copy and paste in your access key, secret access key, default region and output format.

aws configure

Optionally you can add --profile profileName to your command to give these credentials a name. This is useful if you work with multiple AWS accounts

aws configure --profile yourProfileName

Manually editing the credentials file

Another way is to open the credentials file. This file is usually found at ~/.aws/credentials. You may need to show hidden files in your file browser. For Mac press Command + Shift + .

Your file may be empty or may not even exist. If it doesn’t exist create an empty file. In that file you can now paste your credentials in this format. You can either set those credentials to be your default or give them a profile name.

[default]
aws_access_key_id=${Your access key ID}
aws_secret_access_key=${Your secret access key}

[serverlessUser]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

What Next?

The next thing to do is to start building out your API. My Ultimate Guide to Serverless is a great place to start.

Sam Williams

Sam is a Serverless Obsessive who runs Complete Coding, helping developers learn Serverless and companies make the most of the competitive advantage that Serverless gives them. Previous projects include: - Designing a chat platform that currently resolves over 250,000 customer inquiries a month for international retailers and local government - Architecting a backend system to support a 3D clothing visualisation tool - Building a solution to manage millions of dollars of communication software - Designing a "Video Editing in the Cloud" platform, enabling everyone from movie studios to indie film makers to harness the power of the Cloud - without needing to be cloud experts. - Launching a profitable Serverless Startup in under 30 days He has also been teaching cloud-based software development for 5 years and has taught Serverless development to thousands of people. The Complete Coding Youtube channel now has over 15,000 subscribers and over 1 million views

Recent Posts