forked from aws-samples/serverless-rds-proxy-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
configure sample to work with LocalStack (#16)
* changes to make the sample run against LS * modify proxy yaml files for load testing * change the database used from mysql to postgres * remove connection print statement * create iam user for postgres * add makefile * add the deployment script * install artillery package * update README * update README with PostgreSQL * update readme file with yq and jg * add contributing section * update the architecture image * add github actions * update job name * update actions with jq and yq * uncomment start localstack gh action * uncomment start localstack gh action (#4) * update jq and yq in gh actions * Update jq and yq setup in gh actions (#5) * install requirements.txt dependencies * add requirements.txt file * update gitignore * update README * add services being used in README * add github actions to readme * Remove print statements from app file * Remove extra space from create-user script * remove print statements from rds app file * add static db name * Update CONTRIBUTING.md * update LICENSE and README * update README * update License * improve the README --------- Co-authored-by: Anca G <[email protected]> Co-authored-by: HarshCasper <[email protected]>
- Loading branch information
1 parent
2686ff5
commit af50aaf
Showing
19 changed files
with
397 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
name: Create Infra on LocalStack | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- 'README.md' | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
schedule: | ||
# “At 00:00 on Sunday.” | ||
- cron: "0 0 * * 0" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
serverless: | ||
name: Setup infrastructure using Serverless Framework | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Setup Nodejs | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Setup SAM | ||
uses: aws-actions/setup-sam@v2 | ||
with: | ||
use-installer: true | ||
|
||
- name: Setup SAM-Local | ||
run: | | ||
pip install aws-sam-cli-local | ||
samlocal --help | ||
- name: Install yq | ||
run: | | ||
sudo add-apt-repository ppa:rmescandon/yq | ||
sudo apt update | ||
sudo apt install yq -y | ||
- name: Install jq | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install jq -y | ||
- name: Install dependencies | ||
run: | | ||
make install | ||
- name: Start LocalStack | ||
env: | ||
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} | ||
DNS_ADDRESS: 0 | ||
run: | | ||
docker pull localstack/localstack-pro:latest | ||
# Start LocalStack in the background | ||
LS_LOG=trace localstack start -d | ||
# Wait 30 seconds for the LocalStack container to become ready before timing out | ||
echo "Waiting for LocalStack startup..." | ||
localstack wait -t 15 | ||
echo "Startup complete" | ||
- name: Deploy the application | ||
run: | | ||
make deploy | ||
- name: Check deployed resources | ||
run: | | ||
sleep 20 | ||
samlocal list stack-outputs --stack-name sam-app --region us-east-1 --output json | ||
- name: Send a Slack notification | ||
if: failure() || github.event_name != 'pull_request' | ||
uses: ravsamhq/notify-slack-action@v2 | ||
with: | ||
status: ${{ job.status }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
notification_title: "{workflow} has {status_message}" | ||
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" | ||
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>" | ||
notify_when: "failure" | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
|
||
- name: Generate a Diagnostic Report | ||
if: failure() | ||
run: | | ||
curl -s localhost:4566/_localstack/diagnose | gzip -cf > diagnose.json.gz | ||
- name: Upload the Diagnostic Report | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: diagnose.json.gz | ||
path: ./diagnose.json.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,3 +246,5 @@ $RECYCLE.BIN/ | |
/.idea/ | ||
/samconfig.toml | ||
/samconfig-rds.toml | ||
/output-app.json | ||
/output-infra.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ information to effectively respond to your bug report or contribution. | |
|
||
We welcome you to use the GitHub issue tracker to report bugs or suggest features. | ||
|
||
When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already | ||
When filing an issue, please check existing open or recently closed issues to make sure somebody else hasn't already | ||
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: | ||
|
||
* A reproducible test case or series of steps | ||
|
@@ -21,11 +21,11 @@ reported the issue. Please try to include as much information as you can. Detail | |
|
||
|
||
## Contributing via Pull Requests | ||
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: | ||
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure the following: | ||
|
||
1. You are working against the latest source on the *main* branch. | ||
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. | ||
3. You open an issue to discuss any significant work - we would hate for your time to be wasted. | ||
2. You check existing open and recently merged pull requests to make sure someone else hasn't addressed the problem already. | ||
3. You open an issue to discuss any significant work - we would hate to waste your time. | ||
|
||
To send us a pull request, please: | ||
|
||
|
@@ -36,7 +36,7 @@ To send us a pull request, please: | |
5. Send us a pull request, answering any default questions in the pull request interface. | ||
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. | ||
|
||
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and | ||
GitHub provides additional documents on [forking a repository](https://help.github.com/articles/fork-a-repo/) and | ||
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/). | ||
|
||
|
||
|
@@ -45,15 +45,9 @@ Looking at the existing issues is a great way to find something to contribute on | |
|
||
|
||
## Code of Conduct | ||
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). | ||
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact | ||
[email protected] with any additional questions or comments. | ||
|
||
|
||
## Security issue notifications | ||
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. | ||
Please review the adopted [code of conduct](CODE_OF_CONDUCT.md) and make sure you follow the guidelines. | ||
|
||
|
||
## Licensing | ||
|
||
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. | ||
See the [LICENSE](LICENSE) file for our project's licensing. By contributing, you agree that your contributions will be licensed under the existing license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
export AWS_ACCESS_KEY_ID ?= test | ||
export AWS_SECRET_ACCESS_KEY ?= test | ||
export AWS_DEFAULT_REGION=us-east-1 | ||
SHELL := /bin/bash | ||
|
||
## Show this help | ||
usage: | ||
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | ||
|
||
## Install dependencies | ||
install: | ||
@which localstack || pip install localstack | ||
@which samlocal || pip install aws-sam-cli-local | ||
@which artillery || npm install -g artillery@latest | ||
pip install -r requirements.txt | ||
|
||
## Deploy the RDS Serverless Application to LocalStack | ||
deploy: | ||
bash deploy.sh | ||
|
||
## Start LocalStack in detached mode | ||
start: | ||
localstack start -d | ||
|
||
## Stop the Running LocalStack container | ||
stop: | ||
@echo | ||
localstack stop | ||
|
||
## Make sure the LocalStack container is up | ||
ready: | ||
@echo Waiting on the LocalStack container... | ||
@localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1) | ||
|
||
## Save the logs in a separate file, since the LS container will only contain the logs of the last sample run. | ||
logs: | ||
@localstack logs > logs.txt | ||
|
||
.PHONY: usage install deploy start stop ready logs |
Oops, something went wrong.