From d618087aac9fa6166f410be5079b0e6a1e1b788e Mon Sep 17 00:00:00 2001 From: Delong Yang Date: Fri, 11 Apr 2025 08:22:20 -0400 Subject: [PATCH] Clean up code, add comments, and update README.md --- README.md | 12 +++++++----- eks_automation/app.py | 15 +++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index a9dc341..7ac5932 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ ## Description This repository contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. -The application uses a Lambda function to process JSON input data and create a new GitHub repo for **Census EKS CI/CD pipeline**. +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 the Census GitHub Enterprise Server, creating a new repository +for the Census EKS CI/CD pipeline. ## Getting Started @@ -15,8 +17,8 @@ is required to access the Census GitHub Enterprise Server. The `PAT` must be securely stored in `AWS Systems Manager Parameter Store`. The parameter name must match the value of the "SECRET_NAME" constant defined in the `eks_automation/app.py` file. -To access the Census GitHub Enterprise Server, a VPC with private subnets connected to the server must also be attached. -The VPC configuration is set in the `template.yaml` file. Change the `Subnet IDs` and `Security Group IDs` as needed. +To access the Census GitHub Enterprise Server, a VPC with private subnets and a route to the server must be attached. +The VPC configuration is set in the `template.yaml` file. Update the `Subnet IDs` and `Security Group IDs` as needed. You may also want to adjust other settings (API Usage Plan, tags, etc.) in the `template.yaml` file. @@ -83,7 +85,7 @@ You may need to submit a support ticket to request the installation of these too - Test: - The input `JSON` payload is in the following format: + The `JSON` input payload is in the following format: ```json { @@ -140,7 +142,7 @@ You may need to submit a support ticket to request the installation of these too ' ``` - Replace `{API Key}` with the result of the last command and `{API Gateway endpoint URL}` with the value saved from the `sam deploy` command output. + Replace `{API Key}` with the API key we just retrieved, and `{API Gateway endpoint URL}` with the value saved from the `sam deploy` command output. ## Resources diff --git a/eks_automation/app.py b/eks_automation/app.py index 5af1ddf..dcd50ff 100644 --- a/eks_automation/app.py +++ b/eks_automation/app.py @@ -1,8 +1,9 @@ -################################################################## -# Script -# @usage python main.py -################################################################## -# from __future__ import print_function +#################################################################################### +# This Lambda function takes JSON input, processes it using a Jinja2 template, +# and writes the output to a file in a cloned GitHub repository. +# The changes are then committed and pushed to the Census GitHub Enterprise Server, +# creating a new repository for the Census EKS CI/CD pipeline. +#################################################################################### import os import stat @@ -10,8 +11,6 @@ import shutil import logging -# import requests - import json from jinja2 import Environment, FileSystemLoader @@ -36,7 +35,7 @@ # Initialize the logger logger = logging.getLogger() -logger.setLevel("INFO") +logger.setLevel("INFO") # Set to "ERROR" to reduce logging messages. # pylint: disable=unused-argument