Skip to content

Automatically generate your AWS account configurations through AWS Organizations

License

Notifications You must be signed in to change notification settings

XargsUK/switchroles-lambda

Repository files navigation

Switch Roles Lambda

Automatically generate your AWS account configurations through AWS Organizations

Python GitHub%20Actions


Quick Links


Overview

The switchroles-lambda project leverages AWS Lambda to streamline the generation of AWS configurations for accounts in Organizations. It provides a flexible and scalable solution for managing AWS resources across multiple accounts and regions. It is designed with AWS Extend Switch Roles and AESR S3 Config Sender in mind.


Getting Started

Requirements

Ensure you have the following dependencies installed on your system:

  • Python: version 3.10.12
  • boto3: version 1.34.43

Installation

  1. Clone the switchroles-lambda repository:
git clone [email protected]:XargsUK/switchroles-lambda.git
  1. Change to the project directory:
cd switchroles-lambda
  1. Install the dependencies:
pip install -r requirements.txt

Running switchroles-lambda

This python script can be run locally or deployed as an AWS Lambda function.

Name Description Example
S3_BUCKET The name of the S3 bucket where the configurations will be stored (if not running locally). awsconfigs-bucket
ASSUME_ROLE The role name to be assumed in each payer account. AccountSwitcherLambdaRole
ROLE_NAMES Comma-separated role names for which the configurations will be generated. Admin,Developer,ReadOnly
SESSION_NAME The session name to use when assuming roles. RoleSwitcherLambdav2
PAYER_ACCOUNT_IDS Comma-separated AWS payer account IDs. 123456789012,210987654321
OU_OVERRIDES JSON string of organizational unit (OU) ID to name mappings for overrides. {"ou-xyz1-abcdefgh":"Engineering","ou-xyz2-abcdefgh":"Marketing"}
running_locally Set true for Local execution, false for Lambda. true
AWS_REGION The AWS region to use for the Lambda function. us-west-2
AWS_PROFILE The AWS profile to use for the Lambda function. default

Local Execution

Start by setting your environment variables:

export running_locally=true
export S3_BUCKET=S3_BUCKET_NAME
...

Once you've set your environment variables the following command to run switchroles-lambda:

python lambda_handler.py

Contributing

Contributions are welcome! Here are several ways you can contribute:

Contributing Guidelines

  1. Fork the Repository: Start by forking the project repository to your local account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone `repo_url`
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to GitHub: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.

Once your PR is reviewed and approved, it will be merged into the main branch.


License

This project is protected under the MIT License.


About

Automatically generate your AWS account configurations through AWS Organizations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages