%%{init: {'theme': 'base', 'look': 'classic', 'themeVariables': {'fontFamily': 'monospace'}}}%%
graph TD
AWS(["AWS<br>Account"]) --"create"--> Groups("IAM Groups")
AWS --"create"--> Users("IAM Users")
Policy[/"IAM Policies"/]
Policy --"attach"--> Groups
Groups --"inherit"--> Users
style Policy fill:#5B8C5A,stroke:#000000,stroke-width:1px,color:#ffffff
style AWS fill:#E8A33D,stroke:#000000,stroke-width:1px,color:#ffffff
style Groups fill:#1B2A41,stroke:#000000,stroke-width:1px,color:#ffffff
style Users fill:#2A6F77,stroke:#000000,stroke-width:1px,color:#ffffff
Getting started with AWS
This chapter covers creating AWS users and groups, attaching policies, creating access keys, and configuring the AWS command line interface (CLI).
AWS set up
First, you’ll need to log into AWS. This is separate from your regular Amazon account, and comes with different tiers. I highly recommend turning on the MFA and using something like the Microsoft Authenticator app to login.
When you first access AWS, your landing page will look something like this:
This is your AWS Console, where you’ll launch new instances, select storage devices, containers, etc. We’ll start with Identity and Access Management (IAM) in the Console. Then we’ll install and configure the AWS CLI.
Identity and Access Management (IAM)
Back in the AWS Console, we need to create a group, attach policies to this group, then create a user.
Creating Groups
In the AWS Console, we’ll navigate to:
IAM > IAM User groups > Create group
Give the group a meaningful name: dev-deploy-group
Under Attach permissions policies, search and select the following:
AmazonEC2FullAccessAmazonS3FullAccess
Down the road, we should replace these with scoped custom policies later, but for now it will get us up and running.
Click Create Group and you should see something like:
As we can see, this group doesn’t have any users, so we’ll create and add them next.
Creating Users
Back in AWS Console, we’ll navigate to:
IAM Users > Create User
We’ll give the user a meaningful username: mjfrigaard-cli
We have the option to check “Provide user access to the AWS Management Console”. Right now mjfrigaard-cli only needs the CLI, so we’ll leave it unchecked and give the user only the access it uses. A user without a Console password can’t sign in to the Console, so there’s one less credential to protect. We can turn Console access on later without recreating the user (see Console access for mjfrigaard-cli).
Now, under Add user to group, we select dev-deploy-group and click Next
At this point, we’re given a chance to review our selections before confirming, which is also a great opportunity to quickly cover AWS IAM users and groups.
IAM: Core concepts
AWS IAM is somewhat like Linux users and groups, but instead of file permissions, IAM uses policies to control who can do what, and where. Three core concepts to know about AWS IAM:
- A
useris an identity (a person or a service).1
- A
groupis a collection ofusersthat share permissions.2
- A
policyis a JSON document that says what actions are allowed on what resources3
Users don’t get permissions directly, they inherit permissions from the groups they belong to. If you’ve worked with Linux groups and file permissions before, the table below might be helpful for mapping the AWS IAM concepts.
| AWS IAM concept | Linux user/groups analog |
|---|---|
| IAM User | User |
| IAM Group | Group |
| IAM Policy (JSON file) | File permissions (rwx) |
| IAM Users list | /etc/passwd |
| Elevated permissions granted by attached policy | sudo |
| Access via access key ID + secret access key | SSH keys |
So far, we’ve created or logged into our AWS account. Then, from the AWS Console, we 1) created an IAM group, 2) attached IAM policies to the IAM group, 3) created an IAM user, and 4) assigned that user to the IAM group.
Policies determine permissions
For example, say we have a new developer, Alice (alice). Alice wouldn’t get any permissions herself, but she’d be a member of the devs group, which has a S3ReadWrite policy attached, which allows Alice access to the my-data bucket.
%%{init: {'theme': 'base', 'look': 'classic', 'themeVariables': {'fontFamily': 'monospace'}}}%%
graph LR
Policy[/"Policy:<br><code>S3ReadWrite</code>"/]
Groups("IAM Group:<br><code>devs</code>")
Users("IAM User:<br><code>alice</code>")
Resource[("S3 Bucket:<br><code>my-data</code>")]
Policy --> Groups --> Users --> Resource
style Policy fill:#5B8C5A,stroke:#000000,stroke-width:1px,color:#ffffff
style Resource fill:#D2562B,stroke:#000000,stroke-width:1px,color:#ffffff
style Groups fill:#1B2A41,stroke:#000000,stroke-width:1px,color:#ffffff
style Users fill:#2A6F77,stroke:#000000,stroke-width:1px,color:#ffffff
A policy is like a permissions file. It specifies an effect (allow or deny), an action (what operation, like s3:PutObject), and the resource (what it applies to, i.e., a specific bucket).4
%%{init: {'theme': 'base', 'look': 'classic', 'themeVariables': {'fontFamily': 'monospace'}}}%%
graph LR
Policy[/"Policy<br>Document"/] --> Effect("<strong>Effect</strong>:<br><em>Allow</em>")
Policy --> Action("<strong>Action:</strong><br><em>s3:PutObject</em>")
Policy --> Resource[("<strong>Resource:</strong><br><em>arn:aws:s3:::my-bucket/*</em>")]
style Policy fill:#5B8C5A,stroke:#000000,stroke-width:1px,color:#ffffff
style Effect fill:#3E2A1E,stroke:#000000,stroke-width:1px,color:#ffffff
style Action fill:#3E2A1E,stroke:#000000,stroke-width:1px,color:#ffffff
style Resource fill:#D2562B,stroke:#000000,stroke-width:1px,color:#ffffff
What about multiple groups?
Like a Linux user being in multiple groups (sudo, docker, www-data), an IAM user can belong to multiple IAM groups. Consider the user alice below:
%%{init: {'theme': 'base', 'look': 'classic', 'themeVariables': {'fontFamily': 'monospace'}}}%%
graph TD
Users(["<strong>alice</strong>"]) --"In Group"--> DevGroup("<strong>devs</strong>")
Users --"In Group"--> OpsGroup("<strong>ops</strong>")
DevGroup --> S3Policy[/"<strong>Policy</strong>:<br><em>S3 Access</em>"/]
OpsGroup --> EC2Policy[/"<strong>Policy</strong>:<br><em>EC2 Access</em>"/]
S3Policy --> S3[("S3<br>Buckets")]
EC2Policy --> EC2["EC2<br>Instances"]
style Users fill:#2A6F77,stroke:#000000,stroke-width:1px,font-size:14px,text-align:center,font-family:monospace,color:#ffffff
style DevGroup fill:#1B2A41,stroke:#000000,stroke-width:1px,font-size:14px,text-align:center,font-family:monospace,color:#ffffff
style OpsGroup fill:#1B2A41,stroke:#000000,stroke-width:1px,font-size:14px,text-align:center,font-family:monospace,color:#ffffff
style S3Policy fill:#5B8C5A,stroke:#000000,stroke-width:1px,color:#ffffff
style EC2Policy fill:#5B8C5A,stroke:#000000,stroke-width:1px,color:#ffffff
style S3 fill:#D2562B,stroke:#000000,stroke-width:1px,color:#ffffff
style EC2 fill:#D2562B,stroke:#000000,stroke-width:1px,color:#ffffff
Alice ends up with the combined permissions of both devs and ops groups (just like a Linux user inheriting from multiple group memberships).
Identities
In AWS, identities can be human users (i.e., people like alice logging in via console or CLI). But identities can also be service/automation users, which are things like GitHub Actions or applications that need programmatic access (like a system account or a service account key).
%%{init: {'theme': 'base', 'look': 'classic', 'themeVariables': {'fontFamily': 'monospace'}}}%%
graph TD
AWS(["AWS<br>Account"]) --"IAM User<br>(human)"--> Human("<strong>alice</strong>")
AWS --"IAM User<br>(service)"--> Service("<strong>gha-bot</strong>")
Human --> ConsoleAccess["Console Login +<br> CLI Keys"]
Service --> Keys["Access Keys Only,<br>No Console"]
style AWS fill:#E8A33D,stroke:#000000,stroke-width:1px,color:#ffffff
style Human fill:#2A6F77,stroke:#000000,stroke-width:1px,font-size:14px,text-align:center,font-family:monospace,color:#ffffff
style Service fill:#2A6F77,stroke:#000000,stroke-width:1px,font-size:14px,text-align:center,font-family:monospace,color:#ffffff
style ConsoleAccess fill:#3E2A1E,stroke:#000000,stroke-width:1px,color:#ffffff
style Keys fill:#3E2A1E,stroke:#000000,stroke-width:1px,color:#ffffff
IAM: Recap
Below is a full picture of IAM users, groups, policies and resources. We’ll be using all of these to stand up an EC2 instance, put our model data into an S3 bucket, and give GitHub Actions access to that bucket.
%%{init: {'theme': 'base', 'look': 'classic', 'themeVariables': {'fontFamily': 'monospace'}}}%%
graph TD
AWS(["AWS<br>Account"])
AWS --> Users("IAM Users")
AWS --> Groups("IAM Groups")
AWS --> Policies[/"IAM Policies"/]
AWS --> Roles["<em>IAM Roles<br>(optional, for cross<br>service access)</em>"]
Users --> Groups
Groups --> Policies
Roles --> Policies
Policies --> Resources["AWS Resources:<br>S3, EC2, etc"]
style AWS fill:#E8A33D,stroke:#000000,stroke-width:1px,color:#ffffff
style Policies fill:#5B8C5A,stroke:#000000,stroke-width:1px,color:#ffffff
style Roles fill:#3E2A1E,stroke:#000000,stroke-width:1px,color:#ffffff
style Groups fill:#1B2A41,stroke:#000000,stroke-width:1px,color:#ffffff
style Users fill:#2A6F77,stroke:#000000,stroke-width:1px,color:#ffffff
style Resources fill:#D2562B,stroke:#000000,stroke-width:1px,color:#ffffff
IAM Roles (not covered in depth here) are like temporary identities that services assume. For example, an EC2 instance can assume a role to access S3 without any stored credentials. This is the more secure long-term pattern, but access keys are the simpler starting point.
Creating Access Keys
In the IAM users dashboard, we can see:
- the
dev-deploy-group,
- the policies we attached to this group (
AmazonEC2FullAccessandAmazonS3FullAccess), and
- the new user we just created (
mjfrigaard-cli)
In the Summary section, there is an option to Create access key:
We want to click on Create access key under the Security credentials tab. The Use case we want is the Command Line Interface (CLI):
Follow the steps in the documentation (be sure to store the Access Key ID and Secret Access Key pair somewhere safe!).
Next we’ll cover installing the AWS Command Line Interface (CLI) on our local machine. This will allow us to control AWS from the command line.
Install AWS CLI
First we run the standard apt update:
sudo apt updateNext we download the latest version via the official installer:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"Install an unzip utility:
sudo apt install unzip -yUse unzip on the downloaded awscliv2.zip file:
unzip awscliv2.zipFinally, we install aws:
sudo ./aws/installYou should see:
You can now run: /usr/local/bin/aws --versionVerify install
aws --versionaws-cli/2.35.15 Python/3.14.5 Linux/7.2.15-76070215-generic exe/x86_64.pop.24Logging in
Use the aws login command to log in with the Terminal:
aws loginSelect a region by pressing Enter:
No AWS region has been configured. The AWS region is the geographic location of
your AWS resources.
If you have used AWS before and already have resources in your account, specify
which region they were created in. If you have not created resources in your
account before, you can pick the region closest to you:
https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-regions.html.
You are able to change the region in the CLI at any time with the command "aws
configure set region NEW_REGION".
AWS Region [us-east-1]:Then the browser opened and I was able to log in as the root user:
I logged in as root here because it’s the only identity with Console access so far (we skipped Console access when we created mjfrigaard-cli). The root user has unrestricted access to the entire account, so going forward I recommend using the mjfrigaard-cli IAM user and saving root for the few tasks that require it. Signing in as mjfrigaard-cli needs a Console password, which we add in Console access for mjfrigaard-cli. We’ll configure the access keys for mjfrigaard-cli in the CLI Configuration section below.
AWS Terminology Review
We’ve just created a new group, user, access key ID, and secret access key. Let’s review these before going forward, because it got confusing for me the first time I completed this lab.
1. What is an ARN?
ARN = Amazon Resource Name. You may have noticed this under the Summary section for the mjfrigaard-cli user:
The ARN is a unique identifier for a specific AWS resource (a user, bucket, instance, policy, etc).5 ARNs are similar to fully qualified file paths, but for AWS resources.
This is how it works:
arn:aws:iam::ACCOUNT_ID:user/mjfrigaard-cli| Part | Value | Meaning |
|---|---|---|
arn |
arn | Fixed prefix |
aws |
aws | Partition (the standard AWS, not something like GovCloud or China) |
iam |
iam | Service |
| (blank) | none | Region (IAM is global, so it doesn’t specify a region) |
ACCOUNT_ID |
Account ID | Which AWS account owns this user |
user/mjfrigaard-cli |
Resource | this is an IAM user named mjfrigaard-cli |
%%{init: {'theme': 'base', 'look': 'classic', 'themeVariables': {'fontFamily': 'monospace'}}}%%
graph LR
ARN["ARN"] --"Partition"--> Partition("<strong>aws</strong>")
ARN --"Service"--> Service("<strong>iam<br>s3<br>ec2</strong>")
ARN --"Region"--> Region("<strong>us-east-1 </strong>")
ARN --"Account ID"--> Account("<strong>ACCOUNT_ID</strong>")
ARN --"Resource Path"--> Resource("<strong>user/mjfrigaard-cli</strong>")
style ARN fill:#E8A33D,stroke:#000000,stroke-width:1px,font-size:14px,text-align:left,font-family:monospace,color:#ffffff
style Partition fill:#5B8C5A,stroke:#000000,stroke-width:1px,font-size:14px,text-align:left,font-family:monospace,color:#ffffff
style Region fill:#3E2A1E,stroke:#000000,stroke-width:1px,font-size:14px,text-align:left,font-family:monospace,color:#ffffff
style Service fill:#1B2A41,stroke:#000000,stroke-width:1px,font-size:14px,text-align:left,font-family:monospace,color:#ffffff
style Account fill:#2A6F77,stroke:#000000,stroke-width:1px,font-size:14px,text-align:left,font-family:monospace,color:#ffffff
style Resource fill:#D2562B,stroke:#000000,stroke-width:1px,font-size:14px,text-align:left,font-family:monospace,color:#ffffff
In plain English: “IAM user named mjfrigaard-cli in AWS account ACCOUNT_ID.”
Should I keep my ARN a secret?
No. ARNs are not credentials. They are identifiers, similar to a username or a URL. It’s safe to share, log, or put in documentation. It does not grant access by itself (they just identify a resource).
However, you should keep the Access Key ID + Secret Access Key secret, because these are used to authenticate.
2. IAM Account IDs/Aliases
By default, our AWS account is identified with a 12-digit number (called an Account ID). An Account ID is not secret like access keys (alone it can’t grant access to anything), but don’t share it unnecessarily. You may have seen the option to log in with an IAM account alias instead. An account alias is a human-readable name you can set to work in place of the Account ID.
To create an account alias, use the following command:
aws iam create-account-alias --account-alias my-company-nameThis adds a second Console sign in URL. The original URL with the Account ID still works:
https://ACCOUNT_ID.signin.aws.amazon.com/consoleThe new URL uses the alias:
https://my-company-name.signin.aws.amazon.com/consoleThis is a purely cosmetic change; it doesn’t affect permissions or ARNs.
CLI Configuration
Back in the Terminal, we’re going to configure a dev-deploy profile with the access keys for the IAM user in dev-deploy-group:
aws configure --profile dev-deployThis will prompt you for:
- Access Key ID
- Secret Access Key
- Region (
us-east-1) - Output format (
json)
The command above only creates a named credential profile, stored locally in the files below (nothing was sent to AWS yet):
~/.aws/credentials (keys)
~/.aws/config (region/output format)We can test our configuration with:
aws sts get-caller-identity --profile dev-deployThis asks AWS: “Using these credentials, who am I?”
It returns the following:
{
"UserId": "USER_ID",
"Account": "ACCOUNT_ID",
"Arn": "arn:aws:iam::ACCOUNT_ID:user/mjfrigaard-cli"
}AWS’s security token service (STS) validated our keys and returned:
UserId: unique internal ID for this IAM user (not the access key ID)Account: AWS account numberArn: confirms we are authenticated asmjfrigaard-cli
%%{init: {'theme': 'base', 'look': 'classic', 'themeVariables': {'fontFamily': 'monospace'}}}%%
graph LR
CLI(["CLI<br>(stored keys)"])
STS("<strong>get-caller-identity</strong>")
CLI --"Security<br>Token<br>Service"--> STS
STS --Returns--> Response("<strong>UserId<br>Account<br>Arn</strong>")
style CLI fill:#5B8C5A,stroke:#000000,stroke-width:1px,color:#ffffff
style STS fill:#2A6F77,stroke:#000000,stroke-width:1px,font-size:14px,text-align:left,font-family:monospace,color:#fff
style Response fill:#D2562B,stroke:#000000,stroke-width:1px,font-size:14px,text-align:left,font-family:monospace,color:#ffffff
This is the standard way to confirm our CLI credentials are valid and check which identity they belong to.
Console access for mjfrigaard-cli
When we created mjfrigaard-cli, we skipped Console access because the user only needed the CLI. That changes once aws login or the Console asks for an IAM user sign in.
The IAM user screen asks for an account ID or alias, an IAM username, and a password, and mjfrigaard-cli doesn’t have a password yet.
When we log into the Console as root, we can see the IAM users dashboard shows this.
The Password age column for mjfrigaard-cli is empty (-) and Console access is Disabled, which means the user has never had a Console password. There’s nothing to reset, so we enable Console access instead. Sign in to the Console as root one last time and:
Go to IAM > IAM users and click
mjfrigaard-cli.Open the Security credentials tab.
Under Console sign-in, click Enable console access.
Choose Custom password and enter a strong password. Leave “User must create a new password at next sign-in” unchecked, because this is our own account.
Click Enable console access. The confirmation shows the Console sign-in URL with the account ID or alias.
From here on, sign in as the IAM user with the account ID or alias, mjfrigaard-cli, and the new password. Save root for the few tasks that require it: billing, changing the root email or password, closing the account, or restoring access if every IAM admin is locked out.
Rotating access keys
The access key we created for mjfrigaard-cli is a long-term credential. It never expires on its own, so anyone who finds it can use it until we delete it. The IAM users dashboard shows the key’s age in the Active key age column, and it flags keys older than 90 days with a warning icon.
Rotating means replacing the key with a new one on a schedule. An IAM user can hold two access keys at once, which lets us rotate without downtime. We create the new key, switch everything over, and only then retire the old one.
Checking the current keys
Start by listing the user’s keys and checking when each one was last used. These commands need IAM permissions. We attach IAMFullAccess to dev-deploy-group in Stand up an EC2 instance, and after that the dev-deploy profile can run them:
aws iam list-access-keys \
--user-name mjfrigaard-cli \
--profile dev-deploy{
"AccessKeyMetadata": [
{
"UserName": "mjfrigaard-cli",
"AccessKeyId": "OLD_ACCESS_KEY_ID",
"Status": "Active",
"CreateDate": "2026-07-04T07:01:27+00:00"
}
]
}mjfrigaard-cli has one active key. Copy its AccessKeyId; the next command and step 4 of the rotation use it as OLD_ACCESS_KEY_ID.
aws iam get-access-key-last-used \
--access-key-id OLD_ACCESS_KEY_ID \
--profile dev-deploy{
"UserName": "mjfrigaard-cli",
"AccessKeyLastUsed": {
"LastUsedDate": "2026-11-19T06:47:00+00:00",
"ServiceName": "ec2",
"Region": "us-east-1"
}
}list-access-keys returns each key’s ID, status, and creation date. get-access-key-last-used returns the last date, service, and region the key was used. A key that hasn’t been used in months can be deleted without rotating. Ours was used recently for EC2, so it’s still in use and we rotate it instead.
Rotating the key
The rotation takes five steps, and the old key keeps working until the fourth:
Create a second key. Copy the secret from the output; AWS won’t show it again.
aws iam create-access-key \ --user-name mjfrigaard-cli \ --profile dev-deployPut the new key everywhere the old one lives. For this book that’s only the local
dev-deployprofile. GitHub Actions doesn’t use this key (GitHub Actions and S3 uses a role instead), so there’s nothing to update there.aws configure --profile dev-deployConfirm the new key works:
aws sts get-caller-identity --profile dev-deploy{ "UserId": "USER_ID", "Account": "ACCOUNT_ID", "Arn": "arn:aws:iam::ACCOUNT_ID:user/mjfrigaard-cli" }The
Arnends inuser/mjfrigaard-cli, so the profile now signs in with the new key.Deactivate the old key. A deactivated key can be turned back on if something still depended on it.
aws iam update-access-key \ --user-name mjfrigaard-cli \ --access-key-id OLD_ACCESS_KEY_ID \ --status Inactive \ --profile dev-deployAfter a few days with nothing broken, delete it:
aws iam delete-access-key \ --user-name mjfrigaard-cli \ --access-key-id OLD_ACCESS_KEY_ID \ --profile dev-deployList the keys again to confirm only the new one is left:
aws iam list-access-keys \ --user-name mjfrigaard-cli \ --profile dev-deploy{ "AccessKeyMetadata": [ { "UserName": "mjfrigaard-cli", "AccessKeyId": "NEW_ACCESS_KEY_ID", "Status": "Active", "CreateDate": "2026-11-20T05:59:13+00:00" } ] }
Rotation best practices
The five steps above work for any long-term key, but I’ve found the order matters more than the commands. Each step leaves a way back until the old key is gone. The diagram below shows the full cycle, including what to do when something breaks:
%%{init: {'theme': 'base', 'look': 'classic', 'themeVariables': {'fontFamily': 'monospace'}}}%%
graph TD
Start(["<strong>Key reaches 90 days</strong>"])
Create("Create a<br>second key")
Update("Update every place<br>the old key lives")
Works{"New key<br>works?"}
Deact("Deactivate<br>the old key")
Broken{"Anything break<br>in a few days?"}
React("Reactivate the old key<br>and find what used it")
Delete("Delete<br>the old key")
Done(["<strong>One active key</strong>"])
Start -->|"i. create"| Create
Create -->|"ii. switch"| Update
Update -->|"iii. verify"| Works
Works -->|"no"| Update
Works -->|"yes, iv. deactivate"| Deact
Deact --> Broken
Broken -->|"yes"| React
React --> Update
Broken -->|"no, v. delete"| Delete
Delete --> Done
style Start fill:#E8A33D,stroke:#000000,stroke-width:1px,color:#ffffff
style Create fill:#2A6F77,stroke:#000000,stroke-width:1px,color:#ffffff
style Update fill:#2A6F77,stroke:#000000,stroke-width:1px,color:#ffffff
style Works fill:#1B2A41,stroke:#000000,stroke-width:1px,color:#ffffff
style Deact fill:#2A6F77,stroke:#000000,stroke-width:1px,color:#ffffff
style Broken fill:#1B2A41,stroke:#000000,stroke-width:1px,color:#ffffff
style React fill:#D2562B,stroke:#000000,stroke-width:1px,color:#ffffff
style Delete fill:#2A6F77,stroke:#000000,stroke-width:1px,color:#ffffff
style Done fill:#5B8C5A,stroke:#000000,stroke-width:1px,color:#ffffff
These habits keep each rotation safe and on schedule:
- Rotate every 90 days: this matches the IAM dashboard warning and most security guidance. A calendar reminder works better than waiting for the warning icon.
- Keep one active key: the second slot is for rotation, not for a spare. Two active keys means two secrets to protect.
- List where the key lives before you start: for this book it’s only
~/.aws/credentials. A key you forgot to update is the most common reason a rotation breaks something. - Verify before you deactivate:
aws sts get-caller-identityshould return themjfrigaard-cliARN with the new key. If it doesn’t, the old key still works, so nothing is lost. - Deactivate before you delete: a deactivated key can be turned back on, but a deleted key is gone for good.
Cleaning up the old key
Before deleting the old key, check that nothing used it after we deactivated it. An inactive key can’t sign requests, so its last used date should stay the same:
aws iam get-access-key-last-used \
--access-key-id OLD_ACCESS_KEY_ID \
--profile dev-deployCopies of the old key can also outlive it in notes, scripts, or shell history. Search for the old key ID and remove any copies you find (-I skips binary files, and -l prints only the file names):
grep -rIl "OLD_ACCESS_KEY_ID" ~ 2>/dev/nullWhen a key leaks
A leaked key changes the order. Deactivate it right away, even if something still depends on it, then create the new key and update each place it’s used. A few minutes of downtime is better than leaving a working key in someone else’s hands.
Key management practices
Rotation limits how long a leaked key stays useful, but a few habits keep keys from leaking at all:
- Never commit keys: they belong in
~/.aws/credentialsor a secrets store (like GitHub secrets), never in code,.envfiles under version control, or chat messages. - Delete unused keys:
get-access-key-last-usedshows which ones are safe to remove. - Prefer short-lived credentials where you can:
aws loginand IAM Identity Center issue credentials that expire on their own. GitHub Actions can assume an IAM role through OpenID Connect (OIDC) instead of storing keys at all (we set this up in GitHub Actions and S3).
Recap
We created the
dev-deploy-groupIAM group, attached theAmazonEC2FullAccessandAmazonS3FullAccesspolicies, and added themjfrigaard-cliuser to it. The user has no permissions of its own; it inherits them from the group.We created an access key for
mjfrigaard-cliwith the Command Line Interface (CLI) use case. The Access Key ID and Secret Access Key authenticate requests, so they stay private (ARNs, by contrast, are identifiers and safe to share).We installed the AWS CLI with the official installer, confirmed it with
aws --version, and stored the keys in adev-deployprofile withaws configure. Runningaws sts get-caller-identity --profile dev-deployreturned themjfrigaard-cliARN, which confirms the credentials work.We enabled Console access for
mjfrigaard-cli, so everyday sign ins use the IAM user instead ofroot.We rotate the access key every 90 days by creating a second key, switching the
dev-deployprofile to it, then deactivating and deleting the old one.
In the next section, we’re going to cover launching an EC2 instance.
Read more about AWS IAM users↩︎
Read more about AWS IAM user groups↩︎
Read more about AWS IAM policies↩︎
This is conceptually similar to a Linux ACL entry, but scoped to AWS API actions instead of filesystem operations.↩︎
Read more about AWS ARNs in the official documentation.↩︎



















