Skip to content
프로젝트

fivexl/terraform-aws-sso-elevator

GitHub에서 보기

소개

Slack bot to temporary assign AWS SSO Permission set to a user

보안 및 개인정보 보호

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
기록 수집 중
in 15 days
기록 수집 중
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

FivexL

Want practical AWS infrastructure insights?

👉 Subscribe to our newsletter to get:

  • Real stories from real AWS projects
  • No-nonsense DevOps tactics
  • Cost, security & compliance patterns that actually work
  • Expert guidance from engineers in the field

=========================================================================

Terraform Module for Temporary Elevated Access via AWS IAM Identity Center (Successor to AWS Single Sign-On) and Slack

AWS IAM Identity Center has no temporary permission set assignments. Teams end up with either tightly restricted permission sets or IAM role chaining, and both make the security model complex. The better default is no access (or read-only), with more granted only when needed and only for as long as needed.

SSO Elevator does that. People request a permission set in an account, or membership in a group, from Slack or from the command line. Approvers approve in Slack. The module grants the access and removes it when the requested duration ends. Every grant, revocation and declined request is written to an S3 audit log.

AWS describes its own approach in Managing temporary elevated access to your AWS environment. SSO Elevator differs mainly in using Slack as the request and approval interface. Several AWS partners also offer temporary access for IAM Identity Center (CyberArk Secure Cloud Access, Ermetic and Okta Access Requests). If you already use one of them, check their offering first.

Watch demo Demo

How It Works

sequenceDiagram
    Requester->>Slack: submits the access form (shortcut)
    Requester->>API Gateway: or runs the elevator CLI (signed with an SSO session)
    Slack->>API Gateway: forwards the request
    API Gateway->>Access Requester: invokes the Lambda
    Access Requester->>Slack: posts the request to the channel, tags approvers
    Approver->>Slack: clicks Approve
    Slack->>Access Requester: approval (via API Gateway)
    Access Requester->>IAM Identity Center: creates a user-level assignment (or adds the user to a group)
    Access Requester->>EventBridge Scheduler: schedules the revocation
    Access Requester->>S3: writes an audit entry
    EventBridge Scheduler->>Access Revoker: fires when the duration ends
    Access Revoker->>IAM Identity Center: removes the assignment
    Access Revoker->>S3: writes an audit entry
    Access Revoker->>Slack: posts the revocation
  • Two ways to ask, one pipeline. Slack and the elevator CLI both call one REST API in front of the access-requester Lambda. CLI requests go through the same approval rules and are posted to the same Slack channel for approval. The CLI requests account access only.
  • Approval rules in Terraform (config, group_config) decide per account, permission set or group who approves, whether approval is needed, and whether people may approve their own requests.
  • Revocation. Each grant gets a one-time EventBridge Scheduler schedule that triggers the access-revoker Lambda. The revoker also runs a sweep (schedule_expression, nightly by default) that removes access nobody scheduled for removal. A check (schedule_expression_for_check_on_inconsistency, every 2 hours by default) warns about such access in Slack.
  • Audit. Grants, revocations, declined requests and approved requests that failed partway are stored in S3 and can be queried with Athena. Audit writes never block access expiry: if S3 fails, access is still revoked on time and the entry goes to CloudWatch Logs instead.
  • Optional: attribute-based group sync keeps group membership in line with Identity Store user attributes.

Important Considerations

  • The revoker removes user-level assignments it did not create. In every account named by an approval rule, it removes user-level assignments of the permission sets the rules name that have no pending revocation schedule. A rule with "Resource": "*" extends this to all accounts, and one with "PermissionSet": "*" to all permission sets. Give permanent access (read-only in production, admin in sandboxes) by assigning permission sets to groups, which the revoker never touches. Before you deploy, make sure your administrators reach the IAM Identity Center account through a group.
  • The same goes for groups. Members of a group in group_config who have no pending revocation schedule are removed, however they were added.
  • Users are matched by email. The requester's Slack email must equal the email of their IAM Identity Center user (or match it under one of secondary_fallback_email_domains). CLI callers are matched the other way: SSO username, then that user's email, then the Slack user with that email.
  • AWS Organization. The CLI route, on by default, needs the deployment account to be in an AWS Organization and admits callers from any account in it. Set enable_access_requester_cli = false if you only use Slack. See docs/cli.md.
  • Slack is required for both paths: approvals happen there.

Quickstart

Deploy into the IAM Identity Center management account or its delegated administrator account:

module "aws_sso_elevator" {
  source  = "fivexl/sso-elevator/aws"
  version = "5.0.2"

  slack_channel_id = "C0123456789"

  # Always required: access logging for the config bucket, and for the audit
  # bucket unless you set s3_name_of_the_existing_bucket.
  s3_logging = {
    target_bucket = "my-s3-access-logs-bucket"
    target_prefix = "sso-elevator/"
  }

  config = [
    {
      "ResourceType" : "Account",
      # One account to start. "*" makes the revoker act in every account:
      # read "Important Considerations" first.
      "Resource" : ["111111111111"],
      "PermissionSet" : "ReadOnlyAccess",
      "Approvers" : ["[email protected]"],
      "AllowSelfApproval" : true,
    },
  ]
}

output "requester_api_endpoint_url" {
  value = module.aws_sso_elevator.requester_api_endpoint_url
}

output "requester_api_endpoint_url_cli" {
  value = module.aws_sso_elevator.requester_api_endpoint_url_cli
}

Then:

  1. Create the Slack app and point it at the requester_api_endpoint_url output. Then write the bot token and signing secret to SSM: docs/slack.md.
  2. Write your approval rules: docs/configuration.md.
  3. For a fuller module block and the image options: docs/deployment.md.

Upgrading to 5.0

5.0.0 has breaking changes. It raises the Terraform and AWS provider minimums, removes inputs, moves the Slack secrets to SSM, changes the Slack and CLI URLs, and requires CLI 5.0.0 or newer. From 4.x, follow UPGRADE-5.0.md. On 3.x or older, upgrade to 4.4.3 first (UPGRADE-4.0.md).

Documentation

Terraform Docs

Requirements

Name Version
terraform >= 1.14.8
aws >= 6.28
external >= 1.0
local >= 1.0
null >= 2.0
random >= 3.0

Providers

Name Version
aws >= 6.28
null >= 2.0
random >= 3.0

Modules

Name Source Version
access_requester_alias terraform-aws-modules/lambda/aws//modules/alias 8.8.2
access_requester_slack_handler terraform-aws-modules/lambda/aws 8.8.2
access_revoker terraform-aws-modules/lambda/aws 8.8.2
attribute_syncer terraform-aws-modules/lambda/aws 8.8.2
audit_bucket fivexl/account-baseline/aws//modules/s3_baseline 2.1.9
config_bucket fivexl/account-baseline/aws//modules/s3_baseline 2.1.9
sso_elevator_dependencies terraform-aws-modules/lambda/aws 8.8.2

Resources

Name Type
aws_api_gateway_deployment.requester resource
aws_api_gateway_integration.cli resource
aws_api_gateway_integration.slack resource
aws_api_gateway_method.cli resource
aws_api_gateway_method.slack resource
aws_api_gateway_method_settings.cli resource
aws_api_gateway_method_settings.slack resource
aws_api_gateway_request_validator.slack resource
aws_api_gateway_resource.cli resource
aws_api_gateway_resource.slack resource
aws_api_gateway_rest_api.requester resource
aws_api_gateway_rest_api_policy.requester resource
aws_api_gateway_stage.requester resource
aws_cloudwatch_event_rule.attribute_sync_schedule resource
aws_cloudwatch_event_rule.sso_elevator_check_on_inconsistency resource
aws_cloudwatch_event_rule.sso_elevator_scheduled_revocation resource
aws_cloudwatch_event_target.attribute_sync_schedule resource
aws_cloudwatch_event_target.check_inconsistency resource
aws_cloudwatch_event_target.sso_elevator_scheduled_revocation resource
aws_cloudwatch_log_group.api_access_logs resource
aws_cloudwatch_log_group.waf resource
aws_iam_role.eventbridge_role resource
aws_iam_role_policy.eventbridge_policy resource
aws_lambda_function_event_invoke_config.access_requester_live resource
aws_lambda_permission.api_gateway resource
aws_s3_object.approval_config resource
aws_scheduler_schedule_group.one_time_schedule_group resource
aws_sns_topic.dlq resource
aws_sns_topic_subscription.dlq resource
aws_ssm_parameter.slack_bot_token resource
aws_ssm_parameter.slack_signing_secret resource
aws_wafv2_web_acl.requester resource
aws_wafv2_web_acl_association.requester resource
aws_wafv2_web_acl_logging_configuration.requester resource
null_resource.attribute_sync_validation resource
random_string.random resource
aws_caller_identity.current data source
aws_iam_policy_document.attribute_syncer data source
aws_iam_policy_document.read_slack_secrets data source
aws_iam_policy_document.revoker data source
aws_iam_policy_document.schedule_access data source
aws_iam_policy_document.slack_handler data source
aws_organizations_organization.current data source
aws_partition.current data source
aws_region.current data source
aws_ssoadmin_instances.all data source

Inputs

Name Description Type Default Required
api_gateway_access_logs_enabled If true, the module creates a CloudWatch log group and enables access logging on the requester API stage. Requires the account's API Gateway CloudWatch Logs role (aws_api_gateway_account) to be set already; the module does not manage it. bool false no
api_gateway_name The name of the API Gateway for SSO Elevator's access-requester Lambda string "sso-elevator-access-requster" no
api_gateway_throttling_burst_limit The maximum number of requests that API Gateway allows in a burst. number 5 no
api_gateway_throttling_rate_limit The maximum number of requests that API Gateway allows per second. number 1 no
approver_renotification_backoff_multiplier The multiplier applied to the wait time for each subsequent notification sent to the approver. Default is 2, which means the wait time will double for each attempt. number 2 no
approver_renotification_initial_wait_time The initial wait time before the first re-notification to the approver is sent. This is measured in minutes. If set to 0, no re-notifications will be sent. number 15 no
attribute_sync_enabled Enable attribute-based group sync feature. When enabled, users will be automatically added to groups based on their Identity Store attributes. bool false no
attribute_sync_event_rule_name Name for the EventBridge rule that triggers the attribute syncer. string "sso-elevator-attribute-sync" no
attribute_sync_lambda_memory Memory allocation for attribute syncer Lambda (MB). Increase for large user/group sets. number 512 no
attribute_sync_lambda_timeout Timeout for attribute syncer Lambda (seconds). Increase for large user/group sets. number 300 no
attribute_sync_managed_groups List of group names to manage via attribute sync. Only these groups will be monitored and modified by the sync process. list(string) [] no
attribute_sync_manual_assignment_policy Policy for handling manual assignments (users in managed groups who don't match any rules): 'warn' only logs and notifies, 'remove' automatically removes them. string "remove" no
attribute_sync_rules Attribute mapping rules for group sync. Each rule specifies a group name and the attribute conditions that must be met for a user to be added to that group.
Example:
[
{
group_name = "Engineering"
attributes = {
department = "Engineering"
userType = "Employee"
}
}
]
list(object({
group_name = string
attributes = map(string)
}))
[] no
attribute_sync_schedule Schedule expression for attribute sync (e.g., 'rate(1 hour)' or 'cron(0 * * * ? *)'). Determines how often the sync runs. string "rate(1 hour)" no
attribute_syncer_lambda_name Name for the attribute syncer Lambda function. string "attribute-syncer" no
aws_sns_topic_subscription_email value for the email address to subscribe to the SNS topic string "" no
cache_enabled Enable caching of AWS accounts, permission sets, and Identity Store users (names, usernames, emails) in S3, as a fallback if the live AWS API call fails. If set to false, caching is disabled but the S3 bucket will still be created for future config storage. bool true no
config value for the SSO Elevator config any [] no
config_bucket_kms_key_arn ARN of the KMS key to use for config S3 bucket encryption. If not provided, uses AES256 encryption. string null no
config_bucket_name Name of the S3 bucket for storing configuration and cache data (accounts, permission sets, and future config files) string "sso-elevator-config" no
ecr_owner_account_id In what account is the ECR repository located. string "222341826240" no
ecr_repo_name The name of the ECR repository. string "aws-sso-elevator" no
ecr_repo_tag The tag of the image in the ECR repository. string "5.0.2" no
enable_access_requester_cli If true, adds a POST /access-requester-cli route to the requester REST API so the elevator CLI can submit requests directly, signed with the caller's own AWS credentials, instead of only through Slack. Only principals in this AWS Organization can call it. Requires the deployment account to be in an AWS Organization and organizations:DescribeOrganization for the principal running Terraform, plus more Organizations read permissions in the management account or a delegated administrator (see https://github.com/fivexl/terraform-aws-sso-elevator/blob/main/docs/cli.md#requirements). Set to false if you only use Slack. bool true no
event_bridge_check_on_inconsistency_rule_name value for the event bridge check on inconsistency rule name string "sso-elevator-check-on-inconsistency" no
event_bridge_scheduled_revocation_rule_name value for the event bridge scheduled revocation rule name string "sso-elevator-scheduled-revocation" no
group_config value for the SSO Elevator group config any [] no
identity_store_id The Identity Store ID. If not provided and sso_instance_arn is also not provided, it will be automatically discovered. string "" no
lambda_architecture The instruction set architecture for Lambda functions. Valid values are 'x86_64' or 'arm64'. Use 'arm64' for better price/performance on Graviton2. string "x86_64" no
lambda_memory_size Amount of memory in MB your Lambda Function can use at runtime. Valid value between 128 MB to 10,240 MB (10 GB), in 64 MB increments. number 256 no
lambda_timeout The amount of time your Lambda Function has to run in seconds. number 30 no
log_level value for the log level string "INFO" no
logs_retention_in_days The number of days you want to retain log events in the log group for both Lambda functions and API Gateway. number 365 no
max_permissions_duration_time Maximum duration (in hours) for permissions granted by Elevator. Max number - 48 hours.
Due to Slack's dropdown limit of 100 items, anything above 48 hours will cause issues when generating half-hour increments
and Elevator will not display more then 48 hours in the dropdown.
number 24 no
permission_duration_list_override An explicit list of duration values to appear in the drop-down menu users use to select how long to request permissions for.
Each entry in the list should be formatted as "hh:mm", e.g. "01:30" for an hour and a half. Note that while the number of minutes
must be between 0-59, the number of hours can be any number.
If this variable is set, the max_permission_duration_time is ignored.
Note for the CLI (enable_access_requester_cli): the CLI is not restricted to these specific entries the way the Slack dropdown
is -- it accepts any whole number of minutes up to the highest value in this list, treating the list as a ceiling rather than
an exact set of allowed durations. For example, an override of ["00:30", "08:00"] lets the CLI request any duration from 1
minute up to 8 hours, not just those two values.
list(string) [] no
request_expiration_hours After how many hours should the request expire? If set to 0, the request will never expire. number 8 no
requester_lambda_name value for the requester lambda name string "access-requester" no
revoker_lambda_name value for the revoker lambda name string "access-revoker" no
revoker_post_update_to_slack Should revoker send a confirmation of the revocation to Slack? bool true no
s3_bucket_name_for_audit_entry The name of the S3 bucket that will be used by the module to store logs about every access request.
If s3_name_of_the_existing_bucket is not provided, the module will create a new bucket with this name.
string "sso-elevator-audit-entry" no
s3_bucket_partition_prefix The prefix for the S3 audit bucket object partitions.
Don't use slashes (/) in the prefix, as it will be added automatically, e.g. "logs" will be transformed to "logs/".
If you want to use the root of the bucket, leave this empty.
string "logs" no
s3_bucket_policy_for_audit_entry Custom bucket policy JSON for the audit entry bucket created by this module.
Merged into the s3_baseline bucket policy. Use this to grant extra principals read access on the bucket policy.
Applied only when the module creates the bucket. Ignored when s3_name_of_the_existing_bucket is set.
string null no
s3_logging Map containing access bucket logging configuration.
Required, with at least the target_bucket key: the module always creates the config bucket with access logging,
and also uses it for the audit bucket when it creates that one (s3_name_of_the_existing_bucket unset).
map(string) {} no
s3_mfa_delete Whether to enable MFA delete for the S3 bucket bool false no
s3_name_of_the_existing_bucket Name of an existing S3 bucket to use for storing SSO Elevator audit logs.
An audit log bucket is mandatory.
If you specify this variable, the module will use your existing bucket.
Otherwise, if you don't provide this variable, the module will create a new bucket named according to the "s3_bucket_name_for_audit_entry" variable.
Either way, s3_logging is required (see its description).
string "" no
s3_object_lock Enable object lock bool false no
s3_object_lock_configuration Object lock configuration any
{
"rule": {
"default_retention": {
"mode": "GOVERNANCE",
"years": 2
}
}
}
no
schedule_expression recovation schedule expression (will revoke all user-level assignments unknown to the Elevator) string "cron(0 23 * * ? *)" no
schedule_expression_for_check_on_inconsistency how often revoker should check for inconsistency (warn if found unknown user-level assignments) string "rate(2 hours)" no
schedule_group_name value for the schedule group name string "sso-elevator-scheduled-revocation" no
schedule_role_name value for the schedule role name string "sso-elevator-event-bridge-role" no
secondary_fallback_email_domains Value example: ["@new.domain", "@second.domain"]. Every entry MUST start with "@": SSO Elevator appends the entry
directly to the local part of the Slack email ("john.doe" + "@new.domain"), so a bare "new.domain" never matches.
WARNING:
This feature is STRONGLY DISCOURAGED because it can introduce security risks and open up potential avenues for abuse.

SSO Elevator uses Slack email addresses to find users in AWS SSO. In some cases, the domain of a Slack user's email
(e.g., "[email protected]") differs from the domain defined in AWS SSO (e.g., "[email protected]"). By setting
these fallback domains, SSO Elevator will attempt to replace the original domain from Slack with each secondary domain
in order to locate a matching AWS SSO user.

Use Cases:
- This mechanism should only be used in rare or critical situations where you cannot align Slack and AWS SSO domains.

Use Case Example:
- Slack email: [email protected]
- AWS SSO email: [email protected]

Without fallback domains, SSO Elevator cannot find the SSO user due to the domain mismatch. By setting
secondary_fallback_email_domains = ["@new.domain"], SSO Elevator will swap out "@old.domain" for "@new.domain"
(and any other domain in the list) and attempt to locate "[email protected]" in AWS SSO.

Security Risks & Recommendations:
- If multiple SSO users share the same local-part (before the "@") across different domains, SSO Elevator may
grant permissions to the wrong user.
- Disable or remove entries in this variable as soon as you no longer need domain fallback functionality
to restore a more secure configuration.

IN SUMMARY:
Use "secondary_fallback_email_domains" ONLY if absolutely necessary. It is best practice to maintain
consistent, verified email domains in Slack and AWS SSO. Remove these fallback entries as soon as you
resolve the underlying domain mismatch to minimize security exposure.

Notes:
- SSO Elevator always prioritizes the primary domain from Slack (the Slack user's email) when searching for a user in AWS SSO.
- SSO Elevator adds a one-line :warning: to the request message in Slack if it uses a secondary fallback domain to find a user in AWS SSO.
- The secondary domain feature works ONLY for the requester, approvers in the configuration must have the same email domain as in Slack.
list(string) [] no
send_dm_if_user_not_in_channel If the user is not in the SSO Elevator channel, Elevator will send them a direct message with the request status
(waiting for approval, declined, approved, etc.) and the result of the request.
Using this feature requires the following Slack app permissions: "channels:read", "groups:read", and "im:write".
Please ensure these permissions are enabled in the Slack app configuration.
bool true no
slack_bot_token_ssm_parameter_name Name of the SSM SecureString parameter holding the Slack bot token, read by every Lambda. The module creates it with a placeholder; set the real value with aws ssm put-parameter --overwrite (see https://github.com/fivexl/terraform-aws-sso-elevator/blob/main/docs/slack.md). string "/sso-elevator/slack-bot-token" no
slack_channel_id value for the Slack channel ID string n/a yes
slack_signing_secret_ssm_parameter_name Name of the SSM SecureString parameter holding the Slack signing secret, read by the access-requester Lambda. The module creates it with a placeholder; set the real value with aws ssm put-parameter --overwrite (see https://github.com/fivexl/terraform-aws-sso-elevator/blob/main/docs/slack.md). string "/sso-elevator/slack-signing-secret" no
snap_start Enable Lambda SnapStart on the requester Lambda (see https://github.com/fivexl/terraform-aws-sso-elevator/blob/main/docs/api-gateway.md#snapstart). Set false where Lambda doesn't offer SnapStart for this runtime and package type; apply fails there. bool true no
sso_instance_arn value for the SSO instance ARN string "" no
tags A map of tags to assign to resources. map(string) {} no
use_pre_created_image If true, the image will be pulled from the ECR repository. If false, the image will be built using Docker from the source code. bool true no
waf_enabled If true, the module creates a REGIONAL AWS WAF web ACL (per-IP rate limit plus the AWS managed Common, Known Bad Inputs and Amazon IP Reputation rule sets), associates it with the requester API stage, and logs to the CloudWatch log group aws-waf-logs-<api_gateway_name>. Cannot be combined with waf_web_acl_arn. Leave both unset when AWS Firewall Manager associates a web ACL for you. bool false no
waf_rate_limit Requests per 5 minutes a single IP may send before the module-created web ACL blocks it. All Slack traffic comes from Slack's shared IPs and one access request is about 5 calls, so keep it well above your peak request rate. Used only when waf_enabled is true. number 1000 no
waf_web_acl_arn ARN of an existing REGIONAL AWS WAF web ACL to associate with the requester API stage, for organizations that manage a central web ACL. Cannot be combined with waf_enabled. string null no

Outputs

Name Description
attribute_sync_schedule_rule_arn The ARN of the EventBridge rule that triggers the attribute syncer.
attribute_syncer_lambda_arn The ARN of the attribute syncer Lambda function.
attribute_syncer_lambda_name The name of the attribute syncer Lambda function.
config_s3_bucket_arn The ARN of the S3 bucket for storing configuration and cache data.
config_s3_bucket_name The name of the S3 bucket for storing configuration and cache data.
requester_api_endpoint_url The full URL to invoke the API. Pass this URL into the Slack App manifest as the Request URL.
requester_api_endpoint_url_cli The full URL for the CLI's access-request route. Pass this to elevator configure --endpoint (or set as ELEVATOR_ENDPOINT). null when enable_access_requester_cli is false.
requester_api_execution_arn_cli The execute-api ARN of the CLI's access-request route. Callers in other accounts need execute-api:Invoke on this ARN in their permission set. null when enable_access_requester_cli is false.
requester_api_id The id of the requester REST API. CLI users behind a custom domain pass it to elevator configure --api-id.
sso_elevator_bucket_id The name of the SSO elevator bucket.
waf_web_acl_arn ARN of the web ACL associated with the requester API: the module-created one (waf_enabled) or waf_web_acl_arn. null when neither is set.

More Info

관련 프로젝트 살펴보기

불러오는 중…