Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move management UI into this repo #25

Merged
merged 13 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
AadValidClientId="39c28870-94e4-47ee-b4fb-affe0bf96c9f"
AadClientSecret=""
RunEnvironment="dev"
JwtSigningKey="YOUR_RANDOM_STRING HERE"
JwtSigningKey="YOUR_RANDOM_STRING HERE"
VITE_RUN_ENVIRONMENT="local-dev"
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/**/*.d.ts
/**/*.d.ts
vite.config.ts
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
},
{
"files": ["src/ui/*", "src/ui/**/*"], // Or *.test.js
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off"
}
}
]
}
35 changes: 34 additions & 1 deletion .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
deploy-dev:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.event.repository.name }}-dev
group: ${{ github.event.repository.name }}-dev-aws
cancel-in-progress: false
environment: "AWS DEV"
name: Deploy to AWS DEV
Expand Down Expand Up @@ -56,11 +56,44 @@ jobs:
- run: make deploy_dev
env:
HUSKY: "0"
deploy-cf-pages-dev:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.event.repository.name }}-dev-cf
cancel-in-progress: false
permissions:
contents: read
deployments: write
needs:
- test-unit
name: Deploy to Cloudflare Pages DEV
environment: "Cloudflare Pages"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node LTS
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build
run: corepack enable && yarn && yarn run build
env:
VITE_RUN_ENVIRONMENT: dev
- name: Publish
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: management-ui-dev
directory: dist/ui/
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: main
test:
runs-on: ubuntu-latest
name: Run Live Integration Tests
needs:
- deploy-dev
- deploy-cf-pages-dev
concurrency:
group: ${{ github.event.repository.name }}-dev
cancel-in-progress: false
Expand Down
68 changes: 66 additions & 2 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
deploy-dev:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.event.repository.name }}-dev
group: ${{ github.event.repository.name }}-dev-aws
cancel-in-progress: false
environment: "AWS DEV"
name: Deploy to AWS DEV
Expand Down Expand Up @@ -56,11 +56,43 @@ jobs:
- run: make deploy_dev
env:
HUSKY: "0"
deploy-cf-pages-dev:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.event.repository.name }}-dev-cf
cancel-in-progress: false
permissions:
contents: read
deployments: write
needs:
- test-unit
name: Deploy to Cloudflare Pages DEV
environment: "Cloudflare Pages"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node LTS
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build
run: corepack enable && yarn && yarn run build
env:
VITE_RUN_ENVIRONMENT: dev
- name: Publish
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: management-ui-dev
directory: dist/ui/
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
test:
runs-on: ubuntu-latest
name: Run Live Integration Tests
needs:
- deploy-dev
- deploy-cf-pages-dev
concurrency:
group: ${{ github.event.repository.name }}-dev
cancel-in-progress: false
Expand All @@ -82,7 +114,7 @@ jobs:
runs-on: ubuntu-latest
name: Deploy to AWS PROD
concurrency:
group: ${{ github.event.repository.name }}-prod
group: ${{ github.event.repository.name }}-prod-aws
cancel-in-progress: false
needs:
- test
Expand Down Expand Up @@ -110,6 +142,38 @@ jobs:
- run: make deploy_prod
env:
HUSKY: "0"
deploy-cf-pages-prod:
runs-on: ubuntu-latest
needs:
- test
permissions:
contents: read
deployments: write
concurrency:
group: ${{ github.event.repository.name }}-prod-cf
cancel-in-progress: false
name: Deploy to Cloudflare Pages Prod
environment: "Cloudflare Pages"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node LTS
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build
run: corepack enable && yarn && yarn run build
env:
VITE_RUN_ENVIRONMENT: prod
- name: Publish
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: management-ui-prod
directory: dist/ui/
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: main
health-check-prod:
runs-on: ubuntu-latest
name: Confirm services healthy
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
yarn run lint-staged
yarn lint --fix
7 changes: 1 addition & 6 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
{
"*.ts": [
"yarn run prettier:write",
"yarn run lint --fix"
]
}
{ "src/**/*.{ts,js,tsx,jsx}": ["yarn run lint --fix", "yarn run prettier:write"] }
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ check_account_dev:
clean:
rm -rf .aws-sam
rm -rf node_modules/
rm -rf src/dist/
rm -rf src/build/
rm -rf src/api/node_modules/
rm -rf src/ui/node_modules/
rm -rf dist/

build: src/ cloudformation/ docs/
yarn -D
yarn build:lambda
yarn build
sam build --template-file cloudformation/main.yml

local:
Expand Down
46 changes: 5 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@
# ACM @ UIUC Core API

## Run Locally
1. Copy `.env.sample` as `.env` and set the `JwtSigningKey` to a random string.
2. Enable Tailscale VPN so you can reach the development database in AWS
3. Log into AWS with `aws configure sso` so you can retrieve the AWS secret and configuration.
4. `yarn -D`
5. `make check_account_dev` - If this fails make sure that AWS is configured.
6. `make local`

## Build for AWS Lambda
1. `make clean`
2. `make build`

## Deploy to AWS env

1. Get AWS credentials with `aws configure sso`
2. Ensure AWS profile is set to the right account (DEV or PROD).
3. Run `make deploy_dev` or `make deploy_prod`.

## Generating JWT token

Create a `.env` file containing your `AadClientSecret`.

```bash
node --env-file=.env get_msft_jwt.js
```

## Configuring AWS

SSO URL: `https://acmillinois.awsapps.com/start/#`

```
aws configure sso
```

Log in with SSO. Then, export the `AWS_PROFILE` that the above command outputted.

```bash
export AWS_PROFILE=ABC-DEV
```
# ACM @ UIUC Core
This repository is split into two:
* `src/api/` for the API source code
* `src/ui/` for the UI source code
* `src/common/` for common modules between the two (such as types)
4 changes: 4 additions & 0 deletions cloudformation/iam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ Resources:
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-events-ticketing-metadata
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-merchstore-metadata/*
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-merchstore-metadata
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-iam-userroles
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-iam-userroles/*
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-iam-grouproles
- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-iam-grouproles/*

PolicyName: lambda-dynamo
Outputs:
Expand Down
36 changes: 34 additions & 2 deletions cloudformation/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ Resources:
DependsOn:
- AppLogGroups
Properties:
CodeUri: ../dist/src/
CodeUri: ../dist
AutoPublishAlias: live
Runtime: nodejs20.x
Description: !Sub "${ApplicationFriendlyName} API Lambda"
FunctionName: !Sub ${ApplicationPrefix}-lambda
Handler: lambda.handler
Handler: api/lambda.handler
MemorySize: 512
Role: !GetAtt AppSecurityRoles.Outputs.MainFunctionRoleArn
Timeout: 60
Expand All @@ -105,6 +105,38 @@ Resources:
Path: /{proxy+}
Method: ANY

IamGroupRolesTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: "Retain"
Properties:
BillingMode: 'PAY_PER_REQUEST'
TableName: infra-core-api-iam-grouproles
DeletionProtectionEnabled: true
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: false
AttributeDefinitions:
- AttributeName: groupUuid
AttributeType: S
KeySchema:
- AttributeName: groupUuid
KeyType: HASH

IamUserRolesTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: "Retain"
Properties:
BillingMode: 'PAY_PER_REQUEST'
TableName: infra-core-api-iam-userroles
DeletionProtectionEnabled: true
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: false
AttributeDefinitions:
- AttributeName: userEmail
AttributeType: S
KeySchema:
- AttributeName: userEmail
KeyType: HASH

EventRecordsTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: "Retain"
Expand Down
Loading
Loading