Skip to content

Commit

Permalink
CMDCT-4184 - fixing build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
peoplespete committed Feb 3, 2025
1 parent 7a7b2be commit b542ca6
Show file tree
Hide file tree
Showing 9 changed files with 481 additions and 5,338 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
SKIP_PREFLIGHT_CHECK: true
- id: endpoint
run: |
APPLICATION_ENDPOINT=$(./output.sh ui ApplicationEndpointUrl $STAGE_PREFIX$branch_name)
APPLICATION_ENDPOINT=$(./output.sh seds-$STAGE_PREFIX$branch_name CloudFrontUrl)
echo "application_endpoint=$APPLICATION_ENDPOINT" >> $GITHUB_OUTPUT
echo "## Application Endpoint" >> $GITHUB_STEP_SUMMARY
echo "<$APPLICATION_ENDPOINT>" >> $GITHUB_STEP_SUMMARY
Expand Down
8 changes: 0 additions & 8 deletions deployment/stacks/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,6 @@ export function createApiComponents(props: CreateApiComponentsProps) {
tables: dataConnectTables,
});

new Lambda(scope, "exportToExcel", {
entry: "services/app-api/export/exportToExcel.js",
handler: "main",
path: "/export/export-to-excel",
method: "POST",
...commonProps,
});

new Lambda(scope, "getUserById", {
entry: "services/app-api/handlers/users/get/getUserById.js",
handler: "main",
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
"test": "tests"
},
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"cdk": "cdk",
"build": "tsc",
"watch": "tsc -w",
"cdk": "cdk",
Expand Down Expand Up @@ -65,6 +62,7 @@
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"constructs": "^10.3.0",
"jsonpath": "^1.1.0",
"readline-sync": "^1.4.10"
"readline-sync": "^1.4.10",
"source-map-support": "^0.5.21"
}
}
2 changes: 1 addition & 1 deletion run
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ fi

# build and run run.ts
# tsc is configured to build what we expect in tsconfig.json
./node_modules/.bin/tsc && node ./build_dev/run.js "${ARGS[@]-}"
./node_modules/.bin/tsc && node ./build_dev/src/run.js "${ARGS[@]-}"
8 changes: 4 additions & 4 deletions services/app-api/libs/authorization.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SSMClient, GetParameterCommand } from "@aws-sdk/client-ssm";
import jwt_decode from "jwt-decode";
import { jwtDecode } from "jwt-decode";
import { CognitoJwtVerifier } from "aws-jwt-verify";
import * as logger from "./debug-lib.js";
import { SimpleJwksCache } from "aws-jwt-verify/jwk";
Expand All @@ -9,10 +9,10 @@ export async function getUserDetailsFromEvent(event) {
await verifyEventSignature(event);
const apiKey = event?.headers?.["x-api-key"];

// TODO, it seems that jwt_decode and verifier.verify may return the same object?
// Maybe we can remove the jwt_decode dependency.
// TODO, it seems that jwtDecode and verifier.verify may return the same object?
// Maybe we can remove the jwtDecode dependency.

const token = jwt_decode(apiKey);
const token = jwtDecode(apiKey);
const role = mapMembershipToRole(token["custom:ismemberof"]);

return {
Expand Down
22 changes: 4 additions & 18 deletions services/output.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@

set -e

help='This script is run with the format ./output.sh <target service name> <serverless output variable name> <stage name (optional, default dev)>'
example='ex. ./output.sh ui CloudFrontEndpointUrl'
help='This script is run with the format ./output.sh <target stack name> <cloudformation output variable name>'
example='ex. ./output.sh seds-cmdct-4184-cdk CloudFrontUrl'

: ${1?ERROR: 'You must specify the target service.'
$help
$example}
: ${2?ERROR: "You must specify the variable you want to fetch from serverless' output"
$help
$example}

service=${1}
stack_name=${1}
output=${2}
stage=${3}

if [ $output == "url" ]; then
output="CloudFrontEndpointUrl"
fi

cd $service
serverless info --stage $stage --json | jq --raw-output --arg output $output '.outputs[] | select(.OutputKey == $output) | .OutputValue'
cd ..
aws cloudformation describe-stacks --stack-name $stack_name --query "Stacks[0].Outputs[?OutputKey=='$output'].OutputValue" --output text
12 changes: 12 additions & 0 deletions services/ui-auth/handlers/createUsers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import {
SSMClient,
GetParameterCommand,
} from "@aws-sdk/client-ssm";
import * as cognitolib from "../libs/cognito-lib.js";
const userPoolId = process.env.userPoolId;
import users from "../libs/users.json" assert { type: "json" };

export async function handler(_event, _context, _callback) {
const command = new GetParameterCommand({
Name: process.env.bootstrapUsersPasswordArn,
WithDecryption: true,
});
const ssmClient = new SSMClient({});
const result = await ssmClient.send(command);
const password = result.Parameter?.Value;

for (let user of users) {
var poolData = {
UserPoolId: userPoolId,
Expand Down
2 changes: 1 addition & 1 deletion src/write-ui-env-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function writeUiEnvFile(stage: string, local = false) {
LOCAL_LOGIN: "false",
SKIP_PREFLIGHT_CHECK: "true",
API_REGION: region,
API_URL: deploymentOutput.apiGatewayRestApiUrl.slice(0, -1),
API_URL: deploymentOutput.apiGatewayRestApiUrl,
COGNITO_REGION: region,
COGNITO_IDENTITY_POOL_ID: deploymentOutput.identityPoolId,
COGNITO_USER_POOL_ID: deploymentOutput.userPoolId,
Expand Down
Loading

0 comments on commit b542ca6

Please sign in to comment.