Getting started with AWS
Published: 2023-07-10 15:17:10

This is a part of a [series](https://riemer.ai/blog). [Contact me](https://riemer.ai/contact) if you find any mistakes or for any other input or questions

## Introduction

Some of you might ask: why AWS? Can't we use [Digital Ocean](https://www.digitalocean.com) or [any other generic cloud provider]? You can use basically any cloud provider (or even on-prem) to deploy your solution. I like AWS because you get everything from one single provider. It is also not as expensive as one might assume comparing it to other providers like [Digital Ocean](https://www.digitalocean.com), [Vultr](https://www.vultr.com) and others, once you understand the pricing structure and things like saving plans, reserved instances. AWS also has a great support for startups in their [partner program](https://aws.amazon.com/partners/programs/) and many more.

## Types of AWS accounts

AWS offers several ways of managing your accounts. The first and easiest is to "just create an account". If you are just playing around or only have one product, that is the best way to start.

If you should have a company and several clients or products, you can create sub-accounts called "Organisations". I personally like to create one account per client and product as you receive a separate invoice for each account. To make the payment easier, AWS offers [consolidated billing](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/consolidated-billing.html), so you are only charged once each month for all accounts together.

For the sake of this series I have set up one "billing account" and one sub-account for this project (aka. "project account"). The billing account will receive the invoice each month, but we will set up all resources in the project account. AWS lets you share credits and saving plans across accounts, so it is a great tool to separate costs and access control without having any financial downsides. If you decide for one account only, it has no effect on the rest of this series. Everything will work equally with both account set-ups.

## Creating a new sub-account

If you are creating a new account, it will take up to 48 hours after verification until you can use all services. There is no need to contact the support, it always takes one or two days. For the case that you already have an AWS account and want to go the path of sub-accounts; first thing is to create an organisation which requires you to verify your email address (again).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o5vsqo2e0jywqlg330u3.png)

After you have verified your email address, you can create a new organisation. If you had another AWS account under the entered email address, there will be no direct validation error. It will silently fail and show you the error in the overview later. If you have used the email address before and have closed the AWS organisation, you cannot re-use the same email for a new account, unless you contact the AWS support.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9wu8cd7is3qhd8wbmh23.png)

The "IAM role name" is a role that will be created in the sub-account to allow the parent account to access certain resources. One example is the consolidated billing. As you will receive a consolidated bill from the parent account, it needs to access all required information for this. We will deep-dive into roles and cross-account sharing in a later part of our series.

## Basic security

Using the administrator account for daily operations is dangerous. You know that from other systems like *NIX, so I won't go into details here. Before we create a new user for our daily usage, we want to define a password policy and force new users to use MFA (I am recommending to use a password manager for this. Great choices are tools like [1Password](https://1password.com) or [Bitwarden](https://bitwarden.com)). AWS makes both very easy.
Password Policy
Browse to IAM > Account settings. You should make the password policy as secure as possible. The users will use a password manager in anyway to store the passwords, but you can adjust the settings based on your requirements (e.g. [HIPAA](https://www.hhs.gov/hipaa/for-professionals/security/laws-regulations/index.html), [SOC-II](https://www.forbes.com/sites/forbesbusinesscouncil/2022/09/28/soc-2-certificationthe-everything-guide/?sh=62bfac16531c)).

### MFA enforcement

Next, we are going to create an IAM policy to force the user to change their password on first login and activate MFA. Therefor simply create a new policy. I have created a public gist as the policy JSON is quiet long:

[ChangeUser & MFA IAM Policy](https://gist.github.com/patrickriemer/e510214cf601f114cf4afdc7898272d1)

When you create a new user you can assign this policy or you can create a group and assign the policy to the group (e.g. developers, finance, admins).

Next we need a policy that wraps the administrator privileges. Create a new role with a name like "admin" and assign it the "AdministratorAccess" permission. After this create a new policy "AssumeAdminRole" with the following JSON:

[Assume Admin Role](https://gist.github.com/patrickriemer/1bf9c757785ca8719950298fdc938192)

In a last step we will create a new user for our daily usage. Assign the two policies we have created above to the new user. The user will then:

- Log in at a specific URL for your account
- Have to change their password on the first login
- Have to activate MFA before using the account
- Have no privileges at all after logging in
- Only gaining access by assuming our administrator role (more on that later)

### Identify Center

At the point of writing this, AWS has release a new way to manage IAM users - called "Identity Center". We will proceed with the "classical" approach throughout the series and talk about the advantages and how-to's of the Identity Center later on. If you have several AWS organisations and have to access several of them on a daily basis, [you should check it out directly](https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html).

## Afterthoughts

Use your new user for daily usage. It is missing a few functionalities like billing, but you can easily add this in or create a dedicated role for it for the case that you have a department handling these things.

If you have concerns that this will cause problems with using the CLI, you are right. It will break the simple IAM user access, but the AWS CLI does support assuming roles, it's just a one-time configuration and worth the extra security. A lot of IDEs like [PHPStorm](https://www.jetbrains.com/phpstorm/) support AWS profiles via plugins.