Skip to content

Perun-Engineering/ssm-just-in-time-access

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Disclaimer: This project is a Proof of Concept (POC), entirely generated by AI. It has not been audited for production use. Review all code, configurations, and IAM permissions thoroughly before deploying to any environment handling real workloads.

SSM Access Manager

A Slack-integrated system for managing temporary AWS Systems Manager (SSM) document access with approval workflows.

Overview

SSM Access Manager allows users to request temporary access to AWS resources through Slack. Access requests require two-tier approval from configured Slack user groups (security and manager), and the system automatically creates time-limited SSM documents with ABAC (Attribute-Based Access Control) tags.

Key Features

  • πŸ” Slack-based Access Requests - Users request access via /ssm-access command
  • βœ… Two-Tier Approval Workflow - Security and manager approvals via Slack user groups
  • πŸ‘₯ Group-based Approvals - Manage approvers through Slack user groups
  • πŸ”„ Real-time Updates - Approval messages update instantly for all group members
  • ⏰ Time-based Expiration - Documents automatically expire and are cleaned up
  • 🏒 Multi-Account Support - Manage access across multiple AWS accounts
  • πŸ“Š Audit Trail - All actions logged to CloudWatch with structured logging
  • πŸ”’ ABAC Tags - Documents tagged with user identity for fine-grained access control

Quick Start

Get up and running in ~1 hour:

# 1. Build Lambda functions
./scripts/build.sh

# 2. Deploy infrastructure
./scripts/deploy.sh test us-east-1

# 3. Configure Slack app with endpoints from Terraform output

# 4. Add yourself as administrator
./scripts/add-user.sh test YOUR_USER_ID your.name your@email.com administrator us-east-1

# 5. Create Slack user groups and configure approval groups
/ssm-admin add-approval-group group_id=YOUR_SECURITY_GROUP_ID name="Security Team" type=security
/ssm-admin add-approval-group group_id=YOUR_MANAGER_GROUP_ID name="Manager Team" type=manager

# 6. Test in Slack
/ssm-admin help
/ssm-access

Full setup guide: See QUICKSTART.md

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Slack     β”‚
β”‚   Users     β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚ /ssm-access
       β”‚ /ssm-admin
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         API Gateway                      β”‚
β”‚  /slack/command  /slack/admin           β”‚
β”‚  /slack/interaction  /admin             β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Lambda Functions                 β”‚
β”‚  β€’ Request Handler                       β”‚
β”‚  β€’ Approval Handler                      β”‚
β”‚  β€’ Admin Slack Handler                   β”‚
β”‚  β€’ Document Creator                      β”‚
β”‚  β€’ Expiration Cleanup                    β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         DynamoDB Tables                  β”‚
β”‚  β€’ Access Requests                       β”‚
β”‚  β€’ SSM Documents                         β”‚
β”‚  β€’ Users (Administrators)                β”‚
β”‚  β€’ AWS Accounts                          β”‚
β”‚  β€’ Approval Groups                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Target AWS Accounts                   β”‚
β”‚  β€’ Assume IAM Role                       β”‚
β”‚  β€’ Create/Delete SSM Documents           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

User Roles

  • User: Can request access via /ssm-access
  • Approval Group Member: Can approve/deny requests (managed via Slack user groups)
  • Administrator: Can manage approval groups, administrators, and accounts via /ssm-admin

Slack Commands

For All Users

/ssm-access

Opens a modal to request temporary access to a resource. Fill in:

  • Host (hostname or IP)
  • Port (default: 22)
  • AWS Account (dropdown)
  • Manager Group (dropdown)
  • Expiration Date (optional, defaults to 14 days)

For Administrators

/ssm-admin add-approval-group group_id=<id> name=<name> type=<security|manager>  # Add approval group
/ssm-admin list-approval-groups                                                   # List approval groups
/ssm-admin add-admin @user                                                        # Add an administrator
/ssm-admin remove-admin @user                                                     # Remove an administrator
/ssm-admin list-admins                                                            # List all administrators
/ssm-admin approve-request <request_id>                                           # Approve a request
/ssm-admin deny-request <request_id> <reason>                                     # Deny a request
/ssm-admin help                                                                   # Show all commands

Documentation

Getting Started

User Guides

Operations

Prerequisites

  • AWS CLI configured with admin credentials
  • Terraform >= 1.0
  • Go >= 1.25
  • Slack workspace with app installation permissions
  • At least one AWS account for target resources

Customization

Document Prefix

Customize the SSM document naming prefix to match your organization's conventions:

# In Terraform variables
export TF_VAR_document_prefix="ACME"  # Default: "PF" (PortForwarding)

Documents will be named: {PREFIX}-{username}-{host}-{port}

  • Default: PF-john.doe-db.example.com-5432
  • Custom: ACME-john.doe-db.example.com-5432

The prefix must:

  • Start with an alphanumeric character
  • Contain only alphanumeric, hyphens, and underscores
  • Be 20 characters or less

Technology Stack

  • Language: Go 1.25+
  • Infrastructure: Terraform
  • Cloud: AWS (Lambda, DynamoDB, API Gateway, SSM, IAM)
  • Integration: Slack API
  • Logging: CloudWatch with structured JSON logs

Security Features

  • Slack signature verification for all requests
  • Two-tier approval system (security + manager)
  • Group-based access control via Slack user groups
  • Time-limited access with automatic expiration
  • ABAC tags on SSM documents for fine-grained control
  • Audit trail in CloudWatch logs
  • PII sanitization in logs
  • IAM role assumption with credential caching

Project Structure

.
β”œβ”€β”€ cmd/                    # Lambda function handlers
β”‚   β”œβ”€β”€ request-handler/    # /ssm-access command
β”‚   β”œβ”€β”€ approval-handler/   # Approval button interactions
β”‚   β”œβ”€β”€ admin-slack-handler/# /ssm-admin command
β”‚   β”œβ”€β”€ document-creator/   # SSM document creation
β”‚   β”œβ”€β”€ expiration-cleanup/ # Cleanup expired documents
β”‚   └── admin-handler/      # Admin REST API
β”œβ”€β”€ internal/               # Internal packages
β”‚   β”œβ”€β”€ models/            # Data models
β”‚   β”œβ”€β”€ repository/        # DynamoDB repositories
β”‚   β”œβ”€β”€ service/           # Business logic
β”‚   β”œβ”€β”€ slack/             # Slack client
β”‚   β”œβ”€β”€ validation/        # Input validation
β”‚   └── logging/           # Structured logging
β”œβ”€β”€ infrastructure/        # Terraform configurations
β”‚   └── terraform/
β”œβ”€β”€ scripts/               # Helper scripts
β”œβ”€β”€ docs/                  # Documentation
└── QUICKSTART.md         # Quick start guide

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is licensed under the Apache License 2.0.

Support

  • Issues: Report bugs or request features via GitHub Issues
  • Documentation: See docs/ directory for detailed guides
  • Logs: Check CloudWatch logs for troubleshooting

Acknowledgments

Built with:

About

A Slack-integrated system for managing temporary AWS Systems Manager (SSM) document access with approval workflows.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors