Skip to content

Commit

Permalink
Revert "Add sample Lambda function for periodic execution using Event…
Browse files Browse the repository at this point in the history
…Bridge and codify EventBridge infrastructure with CloudFormation"
  • Loading branch information
hiroshinishio authored Jul 1, 2024
1 parent d49fa02 commit f028588
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 79 deletions.
26 changes: 5 additions & 21 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ on:
branches:
- '*'

# Global environment variables
env:
AWS_REGION: us-west-1

jobs:
deploy_lambda:
name: Publish and Deploy
Expand All @@ -22,26 +18,24 @@ jobs:
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
aws-region: us-west-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

# LAMBDA_ARN is only used in production
- name: Set deployment environment variables
run: |
{
echo "ECR_REGISTRY=${{ steps.login-ecr.outputs.registry }}"
echo "IMAGE_TAG=${{ github.sha }}"
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "ECR_REPOSITORY=${{ secrets.PROD_LAMBDA_NAME }}"
echo "LAMBDA_NAME=${{ secrets.PROD_LAMBDA_NAME }}"
echo "LAMBDA_ARN=arn:aws:lambda:${{ env.AWS_REGION }}:${{ secrets.AWS_ACCOUNT_ID }}:function:${{ secrets.PROD_LAMBDA_NAME }}"
echo "ECR_REPOSITORY=pr-agent-prod"
echo "LAMBDA_NAME=pr-agent-prod"
echo "SLACK_WEBHOOK_URL=${{ secrets.SLACK_WEBHOOK_URL_FOR_PRD }}"
else
echo "ECR_REPOSITORY=${{ secrets.STAGE_LAMBDA_NAME }}"
echo "LAMBDA_NAME=${{ secrets.STAGE_LAMBDA_NAME }}"
echo "ECR_REPOSITORY=stage"
echo "LAMBDA_NAME=stage"
echo "SLACK_WEBHOOK_URL=${{ secrets.SLACK_WEBHOOK_URL_FOR_STG }}"
fi
} >> $GITHUB_ENV
Expand All @@ -58,16 +52,6 @@ jobs:
--function-name $LAMBDA_NAME \
--image-uri $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# Create or update the CloudFormation stack only for the main branch
- name: Deploy CloudFormation stack for scheduled event
if: github.ref == 'refs/heads/main'
run: |
aws cloudformation deploy \
--stack-name ScheduleStack \
--template-file cloudformation.yml \
--parameter-overrides LambdaFunctionName=$LAMBDA_NAME LambdaFunctionArn=$LAMBDA_ARN \
--capabilities CAPABILITY_NAMED_IAM
- name: Notify Slack of deployment status
# Execute this step even if the previous steps fail
if: always()
Expand Down
35 changes: 0 additions & 35 deletions cloudformation.yml

This file was deleted.

17 changes: 4 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

# Local imports
from config import GITHUB_WEBHOOK_SECRET, ENV, PRODUCT_NAME, UTF8
from scheduler import schedule_handler
from services.github.github_manager import verify_webhook_signature
from services.webhook_handler import handle_webhook_event

# Create FastAPI instance
app = FastAPI()

if ENV != "local":
sentry_sdk.init(
dsn="https://b7ca4effebf7d7825b6464eade11734f@o4506827828101120.ingest.us.sentry.io/4506865231200256", # noqa
Expand All @@ -23,18 +25,7 @@
traces_sample_rate=1.0,
)

# Create FastAPI instance and Mangum handler
app = FastAPI()
mangum_handler = Mangum(app=app)


# Here is an entry point for the AWS Lambda function. Mangum is a library that allows you to use FastAPI with AWS Lambda.
def lambda_handler(event, context):
if "source" in event and event["source"] == "aws.events":
schedule_handler(event=event, context=context)
return {"statusCode": 200}

return mangum_handler(event=event, context=context)
handler = Mangum(app=app)


@app.post(path="/webhook")
Expand Down
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ deprecation==2.1.0
distro==1.9.0
exceptiongroup==1.2.1
fastapi==0.111.0
gotrue==2.5.4
gotrue==2.5.2
h11==0.14.0
httpcore==1.0.5
httpx==0.27.0
idna==3.7
mangum==0.17.0
openai==1.35.7
openai==1.35.3
packaging==24.1
postgrest==0.16.8
pre-commit==3.7.1
pycparser==2.22
pydantic==2.7.4
pydantic_core==2.18.4
PyJWT==2.8.0
pylint==3.2.5
pylint==3.2.3
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
realtime==1.0.6
requests==2.32.3
sentry-sdk==2.7.1
sentry-sdk==2.6.0
six==1.16.0
sniffio==1.3.1
starlette==0.37.2
storage3==0.7.6
StrEnum==0.4.15
stripe==10.1.0
stripe==9.12.0
supabase==2.5.1
supafunc==0.4.6
tqdm==4.66.4
Expand Down
5 changes: 0 additions & 5 deletions scheduler.py

This file was deleted.

0 comments on commit f028588

Please sign in to comment.