Skip to main content

Configure AWS Credentials

What you’ll learn
  • how to configure your AWS credentials for programmatic access

This article guides you through configuring your AWS credentials for programmatic access. At the end of the tutorial, you will have your API keys and region configured to successfully deploy Webiny to your AWS cloud.

If you prefer the video version, check out our YouTube video below:


Step 1: Create Your AWS Account#

Already have an account?

In that case skip to step 2 to create your programmatic user.

To create your AWS account and set up your IAM credentials we should first navigate to the AWS Console page:

aws-sign-in

Next click on Create a new AWS account:

aws-login

Now input your credentials and create your account:

aws-register


Step 2: Create a User for Programmatic Access#

Once you're registered, login and head to the AWS Management Console and select IAM under Security, Identity & Compliance:

aws-iam-selection

Click on IAM and select Users under Access Management:

aws-iam-users

Click on Add user to create the account with the IAM credentials:

aws-create-user

Here you enter a 5-step process, and the first step is to create a User name for the credentials.

Programmatic access

Make sure to select the Programmatic access checkbox before moving to the next step.

aws-user-details

In the next step you define the access level for the new user. Select Attach existing Policies from the three options that are available. Then select the AdministratorAccess role by marking the checkbox next to it. When ready, click the Next:Tags button:

info

Because Webiny creates different resources on your AWS account, it has to have administration-level access to many of the resources. If you feel this is a blocker for your project, get in touch via our community slack and we'll help you out.

aws-user-permissions

In case you don't want to add any tags to your new user, you can just skip this step and click the Next:Review button.

aws-user-tags

After all the steps are complete, you'll see a Review page. It should look something similar to this. If everything is correct, click the Create user button.

aws-user-review

Lastly, you will receive a success message with your Access key ID and Secret access key. You need to copy these strings and keep them safe as you need them for the next step.

Save the credentials

Once you navigate off this screen, you will not be able to see the credentials any more. If you lose them, you will need to delete the user and create a new one.

aws-user-created

Step 3: Configure the Programmatic Access#

Now that you have the Access key ID and Secret access key it's time to store them on your development machine.


Unix setup#

If you're on UNIX, create a folder named .aws inside your user folder, that's ~/.aws. Inside that folder place a file called credentials. So the full path is ~/.aws/credentials.

Windows setup#

On Windows machines, navigate to your user folder. That's C:\Users\USERNAME\ (replace USERNAME with your actual username). Inside create a new folder named .aws, and inside the .aws folder create a file named credentials. The full path should be like this: C:\Users\USERNAME\.aws\credentials.


Now that we have our credentials file, edit the file and populate it like so:

[default]
aws_access_key_id = PASTE_ACCESS_KEY_ID_HERE
aws_secret_access_key = PASTE_SECRET_ACCESS_KEY_HERE

The word default inside the square brackets is your profile name. If you don't explicitly configure a profile name, the default profile is used by AWS CLI and SDK.

And that's it! You now have your AWS credentials, your default region, and you're ready to deploy Webiny.

Using a Different AWS Profile Name#

If you would like to use a different name for your AWS profile, you can do that too.

But do note that you will need to specify it before executing Webiny deployment-related commands, otherwise the default profile will be used.

You can do that via the AWS_PROFILE environment variable, which you can set in a couple of ways. The easiest way to do it would be via the .env file, located in your project root, for example:

AWS_PROFILE=my-profile

Apart from that, the AWS_PROFILE environment variable can also be specified using a terminal of your choice, and a command that's available on your operating system. For example, on Linux or MacOS, you can use the export command:

export AWS_PROFILE=my-profile

On Windows, you can utilize the set and setx commands, for example:

setx AWS_PROFILE my-profile
info

Read more about profiles and how to set them up in the official AWS documentation article.

Once the AWS_PROFILE has been properly set via one of the shown methods, you can proceed with the deployment of your Webiny project.

FAQ#

Is there a way to check if my profile was set properly?#

If you have the AWS CLI installed on your system, you can run the following command:

aws sts get-caller-identity

This should give an output similar to the following:

{
"Account": "x",
"UserId": "y",
"Arn": "arn:aws:iam::x:user/z"
}
Last updated on by Adrian Smijulj