Skip to content

Commit

Permalink
Update README.md: enhance overview and system integration sections, r…
Browse files Browse the repository at this point in the history
…emove outdated local development instructions
  • Loading branch information
Your Name committed May 19, 2025
1 parent c89406c commit 788a9b0
Showing 1 changed file with 28 additions and 87 deletions.
115 changes: 28 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Template Automation Lambda

## Description
## Overview

This repository contains source code and supporting files for a serverless Lambda container application.
The application uses an AWS Lambda function to process JSON input and write it to a cloned repository.
The changes are then committed and pushed to your GitHub Enterprise Server, creating a new repository
with custom configurations from your template.
This repository contains the Python code for the Lambda function that automates the creation and configuration of new repositories from templates. It is a core part of a four-repository system for automated infrastructure provisioning and repository bootstrapping.

## System Integration

This repository works together with the following:

1. **template-repos-lambda-deployment**: Contains Terraform code to deploy this Lambda function, manage IAM roles, permissions, and environment variables in AWS.
2. **terraform-aws-template-automation**: Provides reusable Terraform modules for deploying and managing the Lambda and related infrastructure. Used by the deployment repository.

## Current Deployment

- **AWS Account**: csvd-dev-ew
- **AWS Region**: us-gov-west-1

## Architecture

Expand All @@ -16,18 +25,20 @@ with custom configurations from your template.

## Repository Structure

This project is split into two repositories:

1. **template-automation-lambda** (this repository)
- Contains the Lambda function source code
- Builds the container image with Packer
- Publishes the image to ECR

2. **terraform-aws-template-automation**
- Terraform module that deploys the Lambda infrastructure
- Creates and configures all required AWS resources
- Manages GitHub-specific configuration via SSM parameters
- Handles permissions, API Gateway, and other infrastructure
```
template-automation-lambda/
├── template_automation/ # Python code for the Lambda function
│ ├── __init__.py
│ ├── app.py # Main application file
│ ├── config.py # Configuration handling
│ ├── github_integration.py # GitHub API interactions
│ └── requirements.txt # Python dependencies
├── tests/ # Unit and integration tests
│ ├── __init__.py
│ └── test_app.py # Tests for the application
├── packer.pkr.hcl # Packer configuration for the Lambda image
└── README.md # This README file
```

## Prerequisites

Expand Down Expand Up @@ -70,25 +81,6 @@ module "template_automation" {
}
```

## Local Development

1. Clone this repository:
```sh
git clone <your-github-enterprise-url>/template-automation-lambda.git
cd template-automation-lambda
```

2. Install Python dependencies:
```sh
cd template_automation
pip install -r requirements.txt
```

3. Configure AWS credentials either through environment variables or AWS CLI profile

4. Store your GitHub PAT in AWS Systems Manager Parameter Store. The parameter name should match the
value of `GITHUB_TOKEN_SECRET_NAME` in `eks_automation/app.py`

## Deployment

The project uses GitHub Actions for automated deployments. On push to main:
Expand Down Expand Up @@ -116,57 +108,6 @@ For manual deployment:
packer build -var "repository_uri=$(terraform output -raw repository_uri)" -var "tag=latest" packer.pkr.hcl
```

## Testing

The Lambda function accepts JSON input in the following format:

```json
{
"project_name": "string",
"template_settings": {
"attrs": {
"account_name": "my-account",
"aws_region": "us-east-1",
"team_contact": "someone@example.com",
"project_name": "my-project",
"environment": "development",
"environment_abbr": "dev",
"organization": "my-org:my-division:my-team",
"project_id": "proj_001",
"domain_name": "dev.example.com"
},
"tags": {
"slim:schedule": "8:00-17:00"
}
}
}
```

### Unit Tests
To run the unit tests:
```sh
cd eks_automation
python -m pytest tests/ -v -m "not integration"
```

### Integration Tests
The integration tests require real GitHub API access. To run them:

1. Set up the required environment variables:
```sh
export GITHUB_TOKEN="your-github-token"
export GITHUB_API="https://api.github.com" # or your GitHub Enterprise URL
export GITHUB_ORG="your-org-name"
```

2. Run the integration tests:
```sh
cd eks_automation
python -m pytest tests/ -v -m integration
```

Note: Integration tests will create temporary repositories in your GitHub organization. These repositories will be archived (not deleted) after the tests complete. To implement full cleanup, the test code would need to be modified to delete repositories instead of archiving them.

## Resources

- [AWS Lambda Container Images](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html)
Expand Down

0 comments on commit 788a9b0

Please sign in to comment.