Skip to content

Commit

Permalink
Deploy Lambda with updated secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
atxtechbro committed Sep 7, 2024
1 parent d64d83f commit 62a90ae
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/deploy-to-lambda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy to AWS Lambda

on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install AWS SAM CLI
run: |
pip install aws-sam-cli
- name: Deploy to AWS Lambda
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
sam deploy \
--template-file packaged.yaml \
--stack-name hue-lighting-stack \
--capabilities CAPABILITY_IAM \
--parameter-overrides BridgeIP=${{ secrets.BRIDGE_IP }} HueUsername=${{ secrets.HUE_USERNAME }} \
--no-confirm-changeset
32 changes: 32 additions & 0 deletions template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: Hue API Lambda function template

Parameters:
BridgeIP:
Type: String
Description: "IP address of the Hue Bridge"
HueUsername:
Type: String
Description: "Username for the Hue Bridge API"

Resources:
HueLightingFunction:
Type: AWS::Serverless::Function
Properties:
Handler: lambda_function.lambda_handler
Runtime: python3.12
CodeUri: .
MemorySize: 128
Timeout: 3
Environment:
Variables:
BRIDGE_IP: !Ref BridgeIP
HUE_USERNAME: !Ref HueUsername
Policies:
- AWSLambdaBasicExecutionRole
- Statement:
- Effect: Allow
Action: lambda:InvokeFunction
Principal: apigateway.amazonaws.com
Resource: arn:aws:lambda:<YOUR_REGION>:<YOUR_ACCOUNT_ID>:function:<LAMBDA_FUNCTION_NAME>

0 comments on commit 62a90ae

Please sign in to comment.