Browse the Repo

file-type-icon.circleci
file-type-icon.github
file-type-icon.patcher
file-type-icon_ci
file-type-icon_docs
file-type-iconcodegen
file-type-iconexamples
file-type-iconmodules
file-type-icon_deprecated
file-type-iconauto-update
file-type-iconaws-auth
file-type-iconaws-config-bucket
file-type-iconaws-config-multi-region
file-type-iconaws-config-rules
file-type-iconaws-config
file-type-iconaws-organizations
file-type-iconcloudtrail-bucket
file-type-iconcloudtrail
file-type-iconcross-account-iam-roles
file-type-iconcustom-iam-entity
file-type-iconebs-encryption-multi-region
file-type-iconebs-encryption
file-type-iconfail2ban
file-type-icongithub-actions-iam-role
file-type-iconguardduty-multi-region
file-type-iconguardduty
file-type-iconiam-access-analyzer-multi-region
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.autogen.tf
file-type-iconvariables.tf
file-type-iconiam-groups
file-type-iconiam-policies
file-type-iconiam-user-password-policy
file-type-iconiam-users
file-type-iconip-lockdown
file-type-iconkms-cmk-replica
file-type-iconkms-grant-multi-region
file-type-iconkms-master-key-multi-region
file-type-iconkms-master-key
file-type-iconntp
file-type-iconos-hardening
file-type-iconprivate-s3-bucket
file-type-iconsaml-iam-roles
file-type-iconsecrets-manager-resource-policies
file-type-iconssh-grunt-selinux-policy
file-type-iconssh-grunt
file-type-iconssh-iam
file-type-iconssm-healthchecks-iam-permissions
file-type-icontls-cert-private
file-type-icontest
file-type-icon.editorconfig
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.adoc
file-type-iconterraform-cloud-enterprise-private-module-...

Browse the Repo

file-type-icon.circleci
file-type-icon.github
file-type-icon.patcher
file-type-icon_ci
file-type-icon_docs
file-type-iconcodegen
file-type-iconexamples
file-type-iconmodules
file-type-icon_deprecated
file-type-iconauto-update
file-type-iconaws-auth
file-type-iconaws-config-bucket
file-type-iconaws-config-multi-region
file-type-iconaws-config-rules
file-type-iconaws-config
file-type-iconaws-organizations
file-type-iconcloudtrail-bucket
file-type-iconcloudtrail
file-type-iconcross-account-iam-roles
file-type-iconcustom-iam-entity
file-type-iconebs-encryption-multi-region
file-type-iconebs-encryption
file-type-iconfail2ban
file-type-icongithub-actions-iam-role
file-type-iconguardduty-multi-region
file-type-iconguardduty
file-type-iconiam-access-analyzer-multi-region
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.autogen.tf
file-type-iconvariables.tf
file-type-iconiam-groups
file-type-iconiam-policies
file-type-iconiam-user-password-policy
file-type-iconiam-users
file-type-iconip-lockdown
file-type-iconkms-cmk-replica
file-type-iconkms-grant-multi-region
file-type-iconkms-master-key-multi-region
file-type-iconkms-master-key
file-type-iconntp
file-type-iconos-hardening
file-type-iconprivate-s3-bucket
file-type-iconsaml-iam-roles
file-type-iconsecrets-manager-resource-policies
file-type-iconssh-grunt-selinux-policy
file-type-iconssh-grunt
file-type-iconssh-iam
file-type-iconssm-healthchecks-iam-permissions
file-type-icontls-cert-private
file-type-icontest
file-type-icon.editorconfig
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.adoc
file-type-iconterraform-cloud-enterprise-private-module-...
ssh-grunt

ssh-grunt

Manage SSH access to EC2 Instances using groups in AWS IAM or your Identity Provider (e.g., ADFS, Google, Okta, etc).

Code Preview

Preview the Code

mobile file icon

core-concepts.md

down

Background

What is the AWS IAM Access Analyzer?

AWS IAM Access analyzer is a regional service that analyzes the trust policies of resources in your AWS account or a given AWS organization. This helps users identify potential risks & review the "findings" of the analysis to manage unintended resource access.

For the IAM Access Analyzer to work, it needs to be enabled in your AWS organization or an individual AWS account and every region that it's desired to operate in. Enabling it for an organization or a single account means that the analyzer will treat that entity as its "zone of trust".

The access analyzer works by examining the trust & access policies for your resources that allows access to the resource from an external entity (outside of the "zone of trust"), even if that resource has not been accessed.

Note: Please note that the AWS IAM Access Analyzer does not scan all available AWS resources in your AWS account. For an explicit list of which resources will be scanned by the IAM Access Analyzer, please refer to the section "What resources does this service analyze?".

For more guidance and information on the IAM Access Analyzer, please refer to the official AWS docs.

What is an external entity?

An external entity is considered to be any of the following:

  • another AWS account;
  • a root user;
  • an IAM user or role;
  • a federated user;
  • an AWS service;
  • an anonymous user;
  • any other entity that can be used to access AWS resources.

Please refer to the AWS docs for more details on the above.

What resources does IAM Access Analyzer analyze?

AWS IAM Access Analyzer scans and generates "findings" on the resources in a given region of an AWS account or organization, only when the service is enabled.

The following resource types are listed as supported on the AWS docs:

  • Amazon Simple Storage Service buckets
  • AWS Identity and Access Management roles
  • AWS Key Management Service keys
  • AWS Lambda functions and layers
  • Amazon Simple Queue Service queues

Cost

AWS does not explicitly cover pricing for this feature, as it's part of the IAM offering. Based on this, it can safely be assumed that enabling this module across your AWS accounts will come at no extra price.

Operations

Required IAM permissions for managing Access Analyzer

If the IAM Access Analyzer is set to type "Organization", then the management account of that organization has the appropriate access by using a Service Linked role to set up the analyzer (this role is created automatically when a new analyzer is created).

When not using the Service linked role, the user setting up the Analyzer in a management account might require the "IAMAccessAnalyzerFullAccess" policy attached to the its permissions. This user can then set up, delete and use the IAM Access Analyzer, and can also choose a "delegated administrator" as one of member accounts of the organization. The "delegated administrator" would have the same privileges as the user that's used to set up the IAM Access Analyzer originally.

This would allow both the management account and the "delegated administrator" to resolve, archive and filter findings across the IAM Access analyzers.

For more details, please read the AWS docs on Settings for the IAM Access Analyzer.

What to do with the access analyzer findings?

When the Access Analyzer reports a finding, your action depends on whether or not the access was intentional. A finding can be dealt with in two ways - by resolving it or by archiving it.

  • If the access was intentional, you can archive the finding:
    • You can review and "archive" the findings manually via the CLI or the web console. When archiving findings manually, this might result in the Analyzer generating the finding again next time it runs a scan.
    • Therefore, automating the archiving process is a good way to mitigate repetition of the same findings.
    • In this repo's module & example we do not create or provide guidance on how to create Archive rules using infrastructure as code, as this is not yet supported by terraform (as of December 2020). For best guidance on how to create Archive rules, please refer to AWS's docs.
  • If the access was not intended, you can resolve the finding:
    • You will need to update the configuration on your IAM entities to prevent this access in the future.
    • This can be done by updating the trust policy on the IAM entity that violated the access.
    • Wait for the Access Analyzer to re-scan your resources, or trigger a new scan yourself via the CLI.
    • It can take up to 30 minutes for the changes to take effect and the IAM Access Analyzer to update it's findings list.
  • In the case of an error finding:
    • In some cases, when the Access Analyzer cannot access a supported resource it's supposed to scan, it will generate an error finding.
    • Resolving the issue of the Analyzer accessing the resource, will result in the error finding being removed from the list of findings instead of being marked as resolved.

For more details and guidance on "Working with findings", please refer to the dedicated AWS docs page.

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?