Published On Aug 26, 2024
Tired of manually managing AWS IAM users?
In this video, we dive into a real-world business scenario and demonstrate how to leverage the AWS CLI (Command Line Interface) to streamline your workflow.
We'll also walk you through installing AWS Tools for PowerShell and show you how to write scripts to automate tasks like checking MFA device configuration for all your IAM users.
Say goodbye to tedious manual checks and hello to efficient AWS management.
Install and configure AWS CLI in your machine before start this exercise, watch this video
• എന്താണ് JSON data format - Quick over...
Please be familiar with JSON format to understand CLI response effectively, watch this video
• How to use AWS CLI - AWS cloud comput...
AWS CLI command reference
https://docs.aws.amazon.com/cli/latest/
AWS Tool for PowerShell, windows installation guide
https://docs.aws.amazon.com/powershel...
AWS Tools for PowerShell cmdlet reference
https://docs.aws.amazon.com/powershel...
AWS Tool for PowerShell installation commands
Insteller
Install-Module -Name AWS.Tools.Installer
IAM module installation
Install-AWSToolsModule AWS.Tools.IdentityManagement -CleanUp
Automation script to check 2 best practices in AWS IAM
1. MFA device is configured for all IAM users
2. Access keys are rotated in last 90 days or not
Script Starts
$iamUsers = Get-IAMUserList
foreach ($user in $iamUsers) {
Write-Host "User: $($user.UserName)"
$mfaDevices = Get-IAMMFADevice -UserName $user.UserName
if ($mfaDevices.Count -gt 0) {
Write-Host "MFA: enabled."
} else {
Write-Host "MFA: not enabled."
}
$accessKeys = Get-IAMAccessKey -UserName $username
$thresholdDate = (Get-Date).AddDays(-90)
foreach ($key in $accessKeys) {
if ($key.CreateDate -gt $thresholdDate) {
Write-Host "AccessKey: created within the last 90 days."
} else {
Write-Host "Access key: NOT created within the last 90 days."
}
}
Write-Host ""
}
Script Ends
If you have any doubts or suggestions, please mail me in [email protected]
#AWS #AWSCloud #CloudComputing #CloudTechnology #TechTutorial #TutorialMalayalam #AWSMalayalam #cloudcomputingmalayalam #awstutorialforbeginners #awstutorial #learnaws #awscourse #cloudcomputingcourse #cloudcomputingaws