Skip to content

Commit

Permalink
feat(iam): add health check endpoint
Browse files Browse the repository at this point in the history
- also re-add https listener now that our ssl certificate is approved :)
  • Loading branch information
shavinac committed May 2, 2022
1 parent 63451d1 commit 6b57200
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 31 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/cd-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ name: Deploy IAM Server to Review
# trigger: on push to `main` branch, AND only on changes to `iam/*` files
on:
push:
branches: [main]
paths:
- "iam/*"
# branches: [main] // TODO temporarily trigger on push to wip branch
branches: [github-actions]
# paths:
# - "iam/*"

jobs:
build-and-test:
Expand Down
10 changes: 10 additions & 0 deletions iam/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ app.use(cors());
const errorRes = async (res: Response, error: string): Promise<Response> =>
await new Promise((resolve) => resolve(res.status(400).json({ error })));

// health check endpoint
app.get("/health", (req, res) => {
const data = {
message: "Ok",
date: new Date(),
};

res.status(200).send(data);
});

const key = process.env.IAM_JWK || DIDKit.generateEd25519Key();

// get DID from key
Expand Down
41 changes: 13 additions & 28 deletions infra/review/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,30 +189,22 @@ const certificateValidation = new aws.acm.CertificateValidation(
{ customTimeouts: { create: "30s", update: "30s" } }
);

// Create the listener for the application
const listener = new awsx.lb.ApplicationListener("app", {
port: 443,
protocol: "HTTPS",
vpc: cluster.vpc,
certificateArn: certificateValidation.certificateArn,
});

// Creates an ALB associated with our custom VPC.
const alb = new awsx.lb.ApplicationLoadBalancer(`gitcoin-service`, { vpc });

// Listen to HTTP traffic on port 80 and redirect to 443
// const httpListener = alb.createListener("web-listener", {
// port: 80,
// protocol: "HTTP",
// defaultAction: {
// type: "redirect",
// redirect: {
// protocol: "HTTPS",
// port: "443",
// statusCode: "HTTP_301",
// },
// },
// });
const httpListener = alb.createListener("web-listener", {
port: 80,
protocol: "HTTP",
defaultAction: {
type: "redirect",
redirect: {
protocol: "HTTPS",
port: "443",
statusCode: "HTTP_301",
},
},
});

// Target group with the port of the Docker image
const target = alb.createTargetGroup("web-target", { vpc, port: 80 });
Expand Down Expand Up @@ -372,14 +364,7 @@ const service = new awsx.ecs.FargateService("dpopp-iam", {
iam: {
image: dockerGtcDpoppImage,
memory: 1024,
portMappings: [
// httpsListener, // TODO - map this too
{
hostPort: 80,
protocol: "tcp",
containerPort: 80,
},
],
portMappings: [httpsListener],
environment: environment,
links: [],
secrets: [
Expand Down

0 comments on commit 6b57200

Please sign in to comment.