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-icongithub-actions-openid-connect-provider
file-type-iconguardduty-bucket
file-type-iconguardduty-multi-region
file-type-iconguardduty
file-type-iconiam-access-analyzer-multi-region
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-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf
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-icongithub-actions-openid-connect-provider
file-type-iconguardduty-bucket
file-type-iconguardduty-multi-region
file-type-iconguardduty
file-type-iconiam-access-analyzer-multi-region
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-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf
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

README.md

down

A best-practices set of IAM roles for SAML access

This module can be used to allow users authenticated via external Security Assertion Markup Language (SAML) identity providers such as Google, Amazon SSO, Microsoft Active Directory Federation Services (ADFS), Okta, and OneLogin to access your AWS accounts (saml-access). This allows you to define each environment (mgmt, stage, prod, etc) in a separate AWS account and to use SAML to assume different roles in each account.

If you're not familiar with IAM concepts, start with the Background Information section as a way to familiarize yourself with the terminology.

How do you use this module?

To set up SAML access to AWS, you need to:

  1. Create an Identity Provider in each account
  2. Create IAM roles in each of your accounts
  3. Create permissions to assume the IAM roles in other accounts

This module takes care of creating IAM roles and creating the appropriate permissions. Check out the saml-iam-roles example for a working sample code of how to use this module.

Create Identity Provider in IAM

If you want to allow users of a SAML Identity Provider (IdP) to access your AWS accounts, you will first need to create a SAML Identity Provider within IAM. You will also have to configure your IdP to send the appropriate assertions as described in the AWS Documentation.

Create IAM roles in each account

If you want to allow users from SAML IdPs to access your AWS accounts, use this module in each AWS account to create IAM roles that specify which services those users may access.

Create permissions to assume the IAM roles in other accounts

Finally, this module will also grant access to users of each SAML provider listed in the various allow_*_access_from_saml_provider_arns variables to assume the corresponding role.

Resources Created

This module creates the following IAM roles (all optional):

  • allow-read-only-access-from-saml: Users authenticated by the SAML providers in var.allow_read_only_access_from_saml_provider_arns will get read-only access to all services in this account.

  • allow-billing-access-from-saml: Users authenticated by the SAML providers in var.allow_billing_access_from_saml_provider_arns will get full (read and write) access to the billing details for this account.

  • allow-support-access-from-saml: Users authenticated by the SAML providers in var.allow_support_access_from_saml_provider_arns will get access to AWS support for this account.

  • allow-logs-access-from-saml: Users authenticated by the SAML providers in var.allow_logs_access_from_saml_provider_arns will get read access to the logs in CloudTrail, AWS Config, and CloudWatch for this account. Since CloudTrail logs may be encrypted with a KMS CMK, if var.cloudtrail_kms_key_arn is set, these users will also get permissions to decrypt using this KMS CMK.

  • allow-ssh-grunt-access-from-saml: Users authenticated by the SAML providers in var.allow_ssh_grunt_access_from_saml_provider_arns will get read access to IAM Groups and public SSH keys. This is useful to allow ssh-grunt running on EC2 Instances in other AWS accounts to validate SSH connections against IAM users defined in this AWS account.

  • allow-dev-access-from-saml:Users authenticated by the SAML providers in var.allow_dev_access_from_saml_provider_arns will get full (read and write) access to the services in this account specified in var.dev_permitted_services.

  • allow-full-access-from-saml: Users authenticated by the SAML providers in var.allow_full_access_from_saml_provider_arns will get full (read and write) access to all services in this account.

  • allow-iam-admin-access-from-saml: Users authenticated by the SAML providers in var.allow_iam_admin_access_from_saml_provider_arns will get full IAM (iam:*) access in this account.

  • allow-auto-deploy-access-from-saml: Users authenticated by the SAML providers in var.allow_read_only_access_from_saml_provider_arns will get automated deployment access to all services in this account with the permissions specified in var.auto_deploy_permissions. The main use case is to allow a CI server (e.g. Jenkins) in another AWS account to do automated deployments in this AWS account.

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?