Package: airiam
AirIAM is an AWS IAM to least privilege Terraform execution framework. It compiles AWS IAM usage and leverages that data to create a least-privilege IAM Terraform that replaces the exiting IAM management method.AirIAM was created to promote immutable and version-controlled IAM management to replace today's manual and error prone methods.Table of contentsTable of contentsIntroductionFeaturesCommandsUsageData FlowExamplesGetting StartedInstallationUsing PipUsing brew (MacOS Only)Recommended flowFAQAlternativesAWS IAM Cleanup ToolsAWS IAM Policy Management ToolsMigration of AWS to Terraform ToolsContributingSupportIntroductionAirIAM scans existing IAM usage patterns and provides a simple method to migrate IAM configurations into a right-sized
Terraform plan. It identifies unused users, roles, groups, policies and policy attachments and replaces them with a
Least Privileges Terraform code modelled to manage AWS IAM.By moving all IAM configurations into Terraform code, admins can start tracking, auditing and modifying IAM configurations as part of their standard infrastructure-as-code development provisioning processes.AirIAM is battle-tested and is recommended for use in Dev, QA and test environments that have been previously managed by humans. It is design to result in minimal impact on existing workloads.If you are interested in migrating a Prod account, contact us atinfo@bridgecrew.iofor some helpful tips.FeaturesDetects unused IAM resources using native AWS andAmazon Access AdvisorAPIs.Provides scripts to remove unused entities en-masse.Effortless migration of existing IAM configurations into a simple Least Privileges Terraform model.Integrates withCheckov, a static-code analysis tool for Terraform, to track unwanted configuration changes and configuration drift.Commandsfind_unused- Detects unused users, roles, groups, policies and policy attachments. It also adds links to automation scripts that could remove these entities entirely using Bridgecrew Community.Learn more
about these scripts and automation.usage:airiamfind_unused[-h][-pPROFILE][-lLAST_USED_THRESHOLD][--no-cache][-o{cli}]optionalarguments:-h,--helpshowthishelpmessageandexit-pPROFILE,--profilePROFILEAWSprofiletobeused(default:None)-lLAST_USED_THRESHOLD,--last-used-thresholdLAST_USED_THRESHOLD"Last Used"threshold,indays,foranentitytobeconsideredunused(default:90)--no-cacheGenerateafreshsetofdatafromAWSIAMAPIcalls(default:False)-o{cli},--output{cli}Outputformat(default:OutputFormat.cli)recommend_groups- Identifies what permissions are in use and creates 3 generalized groups according to that usage. Supported groups:Admins - Users who have the AdministratorAccess policy attached. It will be added to the admins group which will have the managed policyarn:aws:iam::aws:policy/AdministratorAccessattached.PowerUsers - Users who have write access toanyof the services. In case of more than 10 policies being attached to that group, a number of groups will be created for PowerUsers, and the relevant users will be members of all of them.ReadOnly - Users who only have read access to the account. Will be members of the readonly group which will have the managed policyarn:aws:iam::aws:policy/ReadOnlyAccessattached.usage:airiamrecommend_groups[-h][-pPROFILE][-o{cli}][-lLAST_USED_THRESHOLD][--no-cache]optionalarguments:-h,--helpshowthishelpmessageandexit-pPROFILE,--profilePROFILEAWSprofiletobeused(default:None)-o{cli},--output{cli}Outputformat(default:OutputFormat.cli)-lLAST_USED_THRESHOLD,--last-used-thresholdLAST_USED_THRESHOLD"Last Used"threshold,indays,foranentitytobeconsideredunused(default:90)--no-cacheGenerateafreshsetofdatafromAWSIAMAPIcalls(default:False)terraform- Creates Terraform files based on the outputs and the transformations applied by the optional arguments supplied.usage:airiamterraform[-h][-pPROFILE][-dDIRECTORY][--without-unused][--without-groups][-lLAST_USED_THRESHOLD][--no-cache][--without-import]optionalarguments:-h,--helpshowthishelpmessageandexit-pPROFILE,--profilePROFILEAWSprofiletobeused(default:None)-dDIRECTORY,--directoryDIRECTORYPathwheretheoutputterraformcodeandstatewillbestored(default:results)--without-unusedCreateterraformcodewithoutunusedentities(default:False)--without-groupsCreateterraformcodewithoutrecommendationforusergroups(default:False)-lLAST_USED_THRESHOLD,--last-used-thresholdLAST_USED_THRESHOLD"Last Used"threshold,indays,foranentitytobeconsideredunused(default:90)--no-cacheGenerateafreshsetofdatafromAWSIAMAPIcalls(default:False)--without-importImporttheresultingentitiestoterraform'sstatefile.Note-thismighttakealongtime(default:False)Important notes forterraformcommand:a. AirIAM replaces all hardcoded values with the matching terraform references, which results in replacements of all group memberships and policy attachments.
If this is run using a user, please make sure the user has the relevant privileges directly attached. A matching warning will be displayed if relevant.c. AirIAM tags all the resources it touched so it will be easy to identify the entities which are not managed through AirIAM. This results in terraform modifying the relevant entities by adding these tags.d. By default, AirIAM will import the currently existing IAM entities and their relationships, which might take a while depending on the number of configurations.UsageThe three commands above run sequentially, and in-sync, as seen in the diagram below.When executing, AirIAM starts by scanning a selected AWS account using the specified profile.
Iffind_unusedis specified, the results are printed and the execution completes.
Ifrecommend_groupsis specified, after the stage of group recommendation the results are printed and the execution completes.
If theterraformcommand is specified it takes all the results and creates the Terraform code and state file required to replace the existing IAM configuration.Data FlowExamplesGetting StartedInstallationUsing Pippip3 install airiam --userUsing brew (MacOS Only)brew tap bridgecrewio/airiam https://github.com/bridgecrewio/airiam
brew update
brew install airiamRecommended FlowThe recommended workflow for using this tool is as follows:Run thefind_unusedcommand and delete the unused access keys + unused console logins - these cannot be migrated to terraform because they hold secrets known only to the relevant user - his password and private credentials.Run theterraformcommand without any flags, creating a terraform setup that mirrors your existing IAM setup. This will take a while as all of the entities will be imported to your state fileCommit the terraform files (without the state file) to a new repository.Run the terraform command again, this time with the flag--without-importand--without-unused. This will edit the .tf files to contain only the entities that are in use.Create a new branch and commit the new terraform files.Create a Pull Request / Merge Request from this branch to the default branch. Check out the differences and make sure all the changes are good. Consult relevant stakeholders in your organization if necessary.After approval - merge the PR and apply the changes using terraform apply. Please note this action will require Admin IAM access to the account.FAQIf you run into the following error:airiam is not recognized as an internal or external commandPlease make sure python is in yourPATHby running the following command:export PATH="/Users//Library/Python/3.7/bin:$PATH"AlternativesAWS IAM Cleanup ToolsFor AWS IAM usage scanners check outCloudTracker,Trailscraper,Aadvark&Repokid.
The main difference between these tools and AirIAM is that AirIAM also moves the problem into static terraform code form, which allows an entire set of code analysis tools to manage and identify deviations and changes.AWS IAM Policy Management ToolsFor static IAM policy linting, check outParliament. Parliament is actually integrated into AirIAM, and is run on the policies it gets from your AWS account.For automatically creating IAM policies and managing them as code, check outaws-iam-generator,PolicySentry.Cloudsplainingis another tool from salesforce that analyzes existing IAM set-up
and identifies risky / over privileged roles.These tools help create better policies, but do not help with existing AWS IAM set-up.Migration of AWS to Terraform ToolsFor other tools that help migrate existing AWS IAM set-up to terraform, check outterracognitaandterraforming.
AirIAM is the only tool which supports migrating all relevant IAM entities to terraform v0.12.ContributingContribution is welcomed!We would love to hear about other IAM governance models for additional use cases as well as new ways to identify over-permissive IAM resources.SupportBridgecrewbuilds and maintains AirIAM to encourage the adoption of IAM-as-code and enforcement of IAM Rightsizing and Least Privileges best practices in policy-as-code.Start with ourDocumentationfor quick tutorials and examples.If you need direct support you can contact us atinfo@bridgecrew.io.