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

feat: notification lambdas #536

Merged
merged 47 commits into from
Nov 29, 2022
Merged

Conversation

prestonlimlianjie
Copy link
Contributor

@prestonlimlianjie prestonlimlianjie commented Oct 18, 2022

Problem

Adding both success and failure notification lambdas

@kishore03109 kishore03109 force-pushed the feat/notification-lambdas branch from 8bcd47f to bb91c6a Compare November 6, 2022 23:50
@kishore03109 kishore03109 changed the base branch from develop to feat/site-launch-microservice November 7, 2022 00:06
@kishore03109 kishore03109 changed the base branch from feat/site-launch-microservice to feat/domain-validation-and-primary-domain-lambdas November 7, 2022 00:23
@kishore03109 kishore03109 force-pushed the feat/notification-lambdas branch from bb91c6a to cde6ac1 Compare November 7, 2022 00:24
@kishore03109 kishore03109 force-pushed the feat/domain-validation-and-primary-domain-lambdas branch from f1ac8a9 to 4eb0c81 Compare November 7, 2022 01:28
@kishore03109 kishore03109 force-pushed the feat/notification-lambdas branch from cde6ac1 to d020b4c Compare November 7, 2022 01:31
@kishore03109 kishore03109 requested review from kishore03109, dcshzj, alexanderleegs and seaerchin and removed request for kishore03109 November 7, 2022 01:50
@kishore03109 kishore03109 marked this pull request as ready for review November 7, 2022 01:51
@kishore03109 kishore03109 self-requested a review November 7, 2022 01:52
}): Promise<APIGatewayProxyResult> => {
const { Cause } = event

// const sqs = new SQS()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like an extra comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5695304

// const sqs = new SQS()
const sqs = new SQS({ region: AWS_REGION })
const messageParams = {
QueueUrl: INCOMING_QUEUE_URL || "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this be a guaranteed error if the env var is not defined? we could probably just throw + log here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5695304

Comment on lines 21 to 23
console.log("Error", err)
} else {
console.log("Success", data.MessageId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given that this seems to be a function error, we might be able to enable retries (from here); alternatively, we could just log this to cloudwatch/slack - not entirely sure console.log would be useful here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ccf910a

@@ -77,6 +77,6 @@ export const generalDomainValidation = async (
}
} catch (error) {
console.error(error)
throw error
throw new Error(JSON.stringify({ ...event, success: false }))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could i just double-check what's the difference in behaviour here? it should still be identical as it is a lambda and errors are ephemeral, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey sorry - this is buggy actually, have reverted this back to just throw error - please ignore! :(

export const successNotification = async (
event: APIGatewayProxyEvent
): Promise<APIGatewayProxyResult> => {
console.log(event)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be logger?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d500020

Comment on lines 19 to 24
console.log("Error", err)
} else {
console.log("Success", data.MessageId)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be logger?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d500020

@kishore03109 kishore03109 force-pushed the feat/domain-validation-and-primary-domain-lambdas branch from 8ff2574 to f04740c Compare November 18, 2022 03:55
@kishore03109 kishore03109 force-pushed the feat/notification-lambdas branch from d020b4c to 80a1725 Compare November 21, 2022 01:53
@kishore03109 kishore03109 force-pushed the feat/domain-validation-and-primary-domain-lambdas branch from f85fdb6 to 76b7e7b Compare November 29, 2022 03:33
kishore03109 and others added 24 commits November 29, 2022 11:48
@kishore03109 kishore03109 force-pushed the feat/notification-lambdas branch from d500020 to a7a978b Compare November 29, 2022 03:56
@kishore03109 kishore03109 changed the base branch from feat/domain-validation-and-primary-domain-lambdas to feat/site-launch November 29, 2022 03:57
@kishore03109 kishore03109 merged commit 9f848cb into feat/site-launch Nov 29, 2022
@mergify mergify bot deleted the feat/notification-lambdas branch November 29, 2022 03:58
kishore03109 added a commit that referenced this pull request Jan 17, 2023
* Feat/site launch db (#562)

* feat(launches table): migrations + table for launches

* feat(redirections): redirections table + migration

* fix(redirections table): remove redundant column

* fix(site launch models): add forign key references

* feat(site launch models): add default values for created at and updated at

* fix(launches): change  type to number

* fix(launches FK): typo in FK for launches table

* feat(site launch db): site associations for db

* fix(site launch models ): correct usage of model associations

* style(serverless): add .serveless files to git ignore

* feat(site model): include has one association to launch

* fix(db tests): add launches and redirections to test folder

* feat(site launch db): add assocations for user - launch & launch - redir

* fix(site launch sequalize): fix typos

* Feat/site launch backend services (#558)

* feat(launches table): migrations + table for launches

* feat(redirections): redirections table + migration

* fix(launches): change  type to number

* feat(site launch db): site associations for db

* fix(site launch models ): correct usage of model associations

* feat(site launch db): add assocations for user - launch & launch - redir

* fix(site launch sequalize): fix typos

* feat(site launch): add logic to parse and process site launch form

* fix(site launch): fix attribute name typo

* feat(launch client): add a launch client

* feat(launch Client): add method to send createDomainAssociation

* refactor(launch client): remove unnecessary async

* feat(launch service): add launch service

* chore(deployment client ): remove unused imports

* feat(site launch): creation of domain assocaitaion in amplify

* feat(site launch): getting dns redirections info from amplify

* fix(launches model): fix incorrect types for launches model

* fix(launches and redirections models): tables should be paranoid, and have

* fix(redirections table): fix typo in migrations during table drop

* feat(site launch): remove hardcoded params when updating db

* chore(formsg site launch): temp hardcode of variables for easier dev

* feat(site launch): pushing messages to local queue

* feat(site launch): add localstack to docker container

* feat(site launch): ability to add and read + rm messages from queues

* feat(site launch): [wip] updating db after successful launch

* feat(site launch): define shape of message

ability to write into db after successful launch

* refactor(QueueClient): remove hardcoded queue url

* feat(sitelaunch): standarise shape of message sent to outgoing queue

* fix(site launch): preventing race condition when 2 sites launched...

at the same time. Originally, LaunchesService had instance variables to
cache results from the db, rather than keep re-pining the db for the
siteId + appId. But, this might lead to a race condition if two forms
were submitted back-to-back. As such, data is passed back to the parent
to be reused, rather than storing it within the singular object
 being created during runtime.

* feat(site launch): add support for 'www' redirection domain

* feat(site launch): support for adding redirection into outgoing queue

* refactor(queue service): change code style to prevent inner functions

* fix(site launch): prevent weird  bug when polling for the

incomming queue. For more details:
aws/aws-sdk-js#2793

* feat(site launch): ability to update redirections table

* chore(site launch): remove unused imports

* fix(incoming queue poller): fix undeterministic bug with regards HTTP push

* style(redirections table): add in enums for type of redirections

* style(site launch): add in comments for clarity

-change  to

* refactor(site launch): renames for clairty

* refactor(site launch): dependency injection pattern design

* fix(redirections model): drop enum in teardown

Note: code from here: https://stackoverflow.com/questions/48730477/seque
lize-migration-queryinterface-removecolum-fails-to-work

* fix(teardown db): drop all possible enums if exists during teardown

* style(launches service): using pick vs partial for clarity

* fix(launches service): use aws sdk v3

* style(launches service): fix tyop

* feat(launches service): introduce enums for redirections

* refactor(launches service): move waiting code to parent function

* fix(launches service): make update params partial rather than pick

* feat(infra service): introduce dependency injection for queue service

* style(infra service ): use destructuring assignment

* chore(site launch ): remove hardcoded params

* feat(infraservice): destructuring assignment

* chore(site launch): remove unnecessary comment

* style(formsg site launch): rename method for clarity

* feat(site launch): send email to ops if no agency email input

* fix(site launch): uncaught error when site launch step fails

* refactor(site launch ): change send launch error method signature

* refactor(site launch): remove unnecessary try catch block

* fix(site launch success): send to both requester and agency if success

* refactor(site launch): return errors rather than throw

* feat(site launch): remove unused params in launchSite method

* chore(launch client): remove unnecessary logging

* chore(launch client): remove unused methods

* chore(launches service): remove unnecessary types

* refactor(launches service): use never throw

* refactor(launches service ): only use async await rather than promise chaining

* refactor(site launch): use never throw instead

* feat(launches service): stricter API defination to mandate id

* fix(queue service ): delete all valid messages to prevent q congestion

* feat(QueueService): abstract out method for parsing message

* refactor(infraservice ): change level of granularity of error reporting ...

for missing cert

* fix(InfraService): remove usage of async/await in higher order func

* refactor(infraservice ): remove unwanted try catch

* feat(site launch): email admin if requester was not input properly

send res eariler

* refactor(launch client): remove env var and replace as constant

* chore(launch client): rename params + fix typo

* chore(queue client ): remove unnecessary async

* chore(queue client): clearer comments regarding undeterministic bug

* chore(infra service): returning error for parseDnsRecords()

+ clearer errors to throw

* fix(site launch): fix typo

* feat(infra service ): type validation for urls + clearer logging

* refactor(site launch): refactor method to send res first, and then ...

trigger site launch process

* refactor(queue client): clearer log messages

* style(site launch backend): add return types for functions

* Feat/site launch microservice (#559)

* build: add deps

* feat: add basic lambda fns

* feat: add basic step function workflow

* feat: wire it up with serverless.yml

Co-authored-by: Preston Lim <prestonlimlianjie@gmail.com>

* Feat/domain validation and primary domain lambdas (#560)

* feat(launches table): migrations + table for launches

* feat(redirections): redirections table + migration

* fix(launches): change  type to number

* feat(site launch db): site associations for db

* fix(site launch models ): correct usage of model associations

* feat(site launch db): add assocations for user - launch & launch - redir

* fix(site launch sequalize): fix typos

* feat(site launch): creation of domain assocaitaion in amplify

* feat(site launch): getting dns redirections info from amplify

* feat(site launch): remove hardcoded params when updating db

* feat(site launch): pushing messages to local queue

* feat(site launch): ability to add and read + rm messages from queues

* feat(site launch): [wip] updating db after successful launch

* feat(site launch): define shape of message

ability to write into db after successful launch

* refactor(QueueClient): remove hardcoded queue url

* feat(sitelaunch): standarise shape of message sent to outgoing queue

* fix(site launch): preventing race condition when 2 sites launched...

at the same time. Originally, LaunchesService had instance variables to
cache results from the db, rather than keep re-pining the db for the
siteId + appId. But, this might lead to a race condition if two forms
were submitted back-to-back. As such, data is passed back to the parent
to be reused, rather than storing it within the singular object
 being created during runtime.

* feat(site launch): support for adding redirection into outgoing queue

* refactor(queue service): change code style to prevent inner functions

* fix(site launch): prevent weird  bug when polling for the

incomming queue. For more details:
aws/aws-sdk-js#2793

* feat(site launch): ability to update redirections table

* fix(incoming queue poller): fix undeterministic bug with regards HTTP push

* style(site launch): add in comments for clarity

-change  to

* refactor(site launch): renames for clairty

* refactor(site launch): dependency injection pattern design

* refactor(launches service): move waiting code to parent function

* fix(launches service): make update params partial rather than pick

* chore(site launch ): remove hardcoded params

* refactor(launches service): use never throw

* feat(launches service): stricter API defination to mandate id

* fix(queue service ): delete all valid messages to prevent q congestion

* fix(InfraService): remove usage of async/await in higher order func

* refactor(infraservice ): remove unwanted try catch

* feat(site launch): email admin if requester was not input properly

send res eariler

* chore(launch client): rename params + fix typo

* feat(site launch): creation of domain assocaitaion in amplify

* fix(launches and redirections models): tables should be paranoid, and have

* fix(launches and redirections models): tables should be paranoid, and have

* feat: add gen and pri domain validation lambdas

* docs: update comment

* fix(generl domain validation): throw error if inital parameters are not defined

* refactor(general and primary domain lambdas): use env var for aws region

* fix(general domain validation): remove unused key

* refactor(primary and general domain validation): using logger than console.log()

* feat(logger): add transport for logger

* style(general domain validation ): remove logging of errors since this is done in ...

failure lambda either ways

Co-authored-by: Preston Lim <prestonlimlianjie@gmail.com>

* feat: notification lambdas (#536)

* feat(launches table): migrations + table for launches

* feat(redirections): redirections table + migration

* fix(launches): change  type to number

* feat(site launch db): site associations for db

* fix(site launch models ): correct usage of model associations

* feat(site launch db): add assocations for user - launch & launch - redir

* fix(site launch sequalize): fix typos

* feat(site launch): getting dns redirections info from amplify

* feat(site launch): remove hardcoded params when updating db

* feat(site launch): pushing messages to local queue

* feat(site launch): ability to add and read + rm messages from queues

* feat(site launch): [wip] updating db after successful launch

* feat(site launch): define shape of message

ability to write into db after successful launch

* refactor(QueueClient): remove hardcoded queue url

* feat(sitelaunch): standarise shape of message sent to outgoing queue

* fix(site launch): preventing race condition when 2 sites launched...

at the same time. Originally, LaunchesService had instance variables to
cache results from the db, rather than keep re-pining the db for the
siteId + appId. But, this might lead to a race condition if two forms
were submitted back-to-back. As such, data is passed back to the parent
to be reused, rather than storing it within the singular object
 being created during runtime.

* feat(site launch): support for adding redirection into outgoing queue

* refactor(queue service): change code style to prevent inner functions

* fix(site launch): prevent weird  bug when polling for the

incomming queue. For more details:
aws/aws-sdk-js#2793

* feat(site launch): ability to update redirections table

* fix(incoming queue poller): fix undeterministic bug with regards HTTP push

* style(site launch): add in comments for clarity

-change  to

* refactor(site launch): renames for clairty

* refactor(site launch): dependency injection pattern design

* refactor(launches service): move waiting code to parent function

* fix(launches service): make update params partial rather than pick

* chore(site launch ): remove hardcoded params

* refactor(launches service): use never throw

* feat(launches service): stricter API defination to mandate id

* fix(queue service ): delete all valid messages to prevent q congestion

* fix(InfraService): remove usage of async/await in higher order func

* refactor(infraservice ): remove unwanted try catch

* feat(site launch): email admin if requester was not input properly

send res eariler

* chore(launch client): rename params + fix typo

* feat(site launch): creation of domain assocaitaion in amplify

* feat: add basic lambda fns

* feat: add basic step function workflow

* feat: add gen and pri domain validation lambdas

* fix(launches and redirections models): tables should be paranoid, and have

* feat: extend InfraService to handle failure resp

* feat: add success and failure lambdas

* refactor: get rid of dummy lambdas

* fix: set success true in success notif lambda

* fix(failure lambda ): throw error when URL is not defined

* style(notification lambda ): logger errors in cloudwatch

* style(success notification): log to cloudwatch

* fix(site launch): remove duplicated function calls after rebase

Co-authored-by: Kishore <e0323826@u.nus.edu>

* Feat: step function trigger lambda (#538)

* feat(launches table): migrations + table for launches

* feat(redirections): redirections table + migration

* fix(launches): change  type to number

* feat(site launch db): site associations for db

* fix(site launch models ): correct usage of model associations

* feat(site launch db): add assocations for user - launch & launch - redir

* fix(site launch sequalize): fix typos

* feat(site launch): getting dns redirections info from amplify

* feat(site launch): remove hardcoded params when updating db

* feat(site launch): pushing messages to local queue

* feat(site launch): ability to add and read + rm messages from queues

* feat(site launch): [wip] updating db after successful launch

* feat(site launch): define shape of message

ability to write into db after successful launch

* refactor(QueueClient): remove hardcoded queue url

* feat(sitelaunch): standarise shape of message sent to outgoing queue

* fix(site launch): preventing race condition when 2 sites launched...

at the same time. Originally, LaunchesService had instance variables to
cache results from the db, rather than keep re-pining the db for the
siteId + appId. But, this might lead to a race condition if two forms
were submitted back-to-back. As such, data is passed back to the parent
to be reused, rather than storing it within the singular object
 being created during runtime.

* feat(site launch): support for adding redirection into outgoing queue

* refactor(queue service): change code style to prevent inner functions

* fix(site launch): prevent weird  bug when polling for the

incomming queue. For more details:
aws/aws-sdk-js#2793

* feat(site launch): ability to update redirections table

* fix(incoming queue poller): fix undeterministic bug with regards HTTP push

* style(site launch): add in comments for clarity

-change  to

* refactor(site launch): renames for clairty

* refactor(site launch): dependency injection pattern design

* refactor(launches service): move waiting code to parent function

* fix(launches service): make update params partial rather than pick

* chore(site launch ): remove hardcoded params

* refactor(launches service): use never throw

* feat(launches service): stricter API defination to mandate id

* fix(queue service ): delete all valid messages to prevent q congestion

* fix(InfraService): remove usage of async/await in higher order func

* feat(site launch): email admin if requester was not input properly

send res eariler

* chore(launch client): rename params + fix typo

* feat(site launch): creation of domain assocaitaion in amplify

* feat: add basic lambda fns

* feat: add basic step function workflow

* feat: add gen and pri domain validation lambdas

* feat: extend InfraService to handle failure resp

* refactor: get rid of dummy lambdas

* fix(launches and redirections models): tables should be paranoid, and have

* feat: add success and failure lambdas

* feat(site launch): step functions trigger lambda

* fix(site launch): standardise shape of inputs within lambdas

* refactor(step functions trigger): use existing NODE_DEV env var

* style(step functions triggering lambda): log to cloudwatch

* fix(site launch): remove duplicate function calls after rebase

Co-authored-by: Preston Lim <prestonlimlianjie@gmail.com>

* Feat: redirection lambda (#546)

* feat(launches table): migrations + table for launches

* feat(redirections): redirections table + migration

* fix(launches): change  type to number

* feat(site launch db): site associations for db

* fix(site launch models ): correct usage of model associations

* feat(site launch db): add assocations for user - launch & launch - redir

* fix(site launch sequalize): fix typos

* feat(site launch): getting dns redirections info from amplify

* feat(site launch): remove hardcoded params when updating db

* feat(site launch): pushing messages to local queue

* feat(site launch): ability to add and read + rm messages from queues

* feat(site launch): [wip] updating db after successful launch

* feat(site launch): define shape of message

ability to write into db after successful launch

* refactor(QueueClient): remove hardcoded queue url

* feat(sitelaunch): standarise shape of message sent to outgoing queue

* fix(site launch): preventing race condition when 2 sites launched...

at the same time. Originally, LaunchesService had instance variables to
cache results from the db, rather than keep re-pining the db for the
siteId + appId. But, this might lead to a race condition if two forms
were submitted back-to-back. As such, data is passed back to the parent
to be reused, rather than storing it within the singular object
 being created during runtime.

* feat(site launch): support for adding redirection into outgoing queue

* refactor(queue service): change code style to prevent inner functions

* fix(site launch): prevent weird  bug when polling for the

incomming queue. For more details:
aws/aws-sdk-js#2793

* feat(site launch): ability to update redirections table

* fix(incoming queue poller): fix undeterministic bug with regards HTTP push

* style(site launch): add in comments for clarity

-change  to

* refactor(site launch): renames for clairty

* refactor(site launch): dependency injection pattern design

* refactor(launches service): move waiting code to parent function

* fix(launches service): make update params partial rather than pick

* chore(site launch ): remove hardcoded params

* refactor(launches service): use never throw

* feat(launches service): stricter API defination to mandate id

* fix(queue service ): delete all valid messages to prevent q congestion

* fix(InfraService): remove usage of async/await in higher order func

* feat(site launch): email admin if requester was not input properly

send res eariler

* chore(launch client): rename params + fix typo

* feat(site launch): creation of domain assocaitaion in amplify

* feat: add basic lambda fns

* feat: add basic step function workflow

* feat: add gen and pri domain validation lambdas

* fix(generl domain validation): throw error if inital parameters are not defined

* feat: extend InfraService to handle failure resp

* refactor: get rid of dummy lambdas

* fix(launches and redirections models): tables should be paranoid, and have

* feat(redirections ): change message shape to cater for the 2 types

* feat(redirectionlambda): lambda to commit to redirection server

* fix(redirection domains): bug fix for domain associations with no redirect

* feat(site launch): read from .env + wrongly input state machine error

* fix(site launch step functions): catching errors and only trigger failure lambda...

after multiple retires

* feat(site launch redirections ): only provide support for A record redirection

for standardision purposes

* style(redirection-lambda): remove trivial comments, change logs

* fix(site launch): remove duplicate function calls

Co-authored-by: Preston Lim <prestonlimlianjie@gmail.com>

* Feat/site launch emails (#547)

* feat(launches table): migrations + table for launches

* feat(redirections): redirections table + migration

* fix(launches): change  type to number

* feat(site launch db): site associations for db

* fix(site launch models ): correct usage of model associations

* feat(site launch db): add assocations for user - launch & launch - redir

* fix(site launch sequalize): fix typos

* feat(site launch): getting dns redirections info from amplify

* feat(site launch): remove hardcoded params when updating db

* feat(site launch): pushing messages to local queue

* feat(site launch): ability to add and read + rm messages from queues

* feat(site launch): [wip] updating db after successful launch

* feat(site launch): define shape of message

ability to write into db after successful launch

* refactor(QueueClient): remove hardcoded queue url

* feat(sitelaunch): standarise shape of message sent to outgoing queue

* fix(site launch): preventing race condition when 2 sites launched...

at the same time. Originally, LaunchesService had instance variables to
cache results from the db, rather than keep re-pining the db for the
siteId + appId. But, this might lead to a race condition if two forms
were submitted back-to-back. As such, data is passed back to the parent
to be reused, rather than storing it within the singular object
 being created during runtime.

* feat(site launch): support for adding redirection into outgoing queue

* refactor(queue service): change code style to prevent inner functions

* fix(site launch): prevent weird  bug when polling for the

incomming queue. For more details:
aws/aws-sdk-js#2793

* feat(site launch): ability to update redirections table

* fix(incoming queue poller): fix undeterministic bug with regards HTTP push

* style(site launch): add in comments for clarity

-change  to

* refactor(site launch): renames for clairty

* refactor(site launch): dependency injection pattern design

* refactor(launches service): move waiting code to parent function

* fix(launches service): make update params partial rather than pick

* chore(site launch ): remove hardcoded params

* refactor(launches service): use never throw

* feat(launches service): stricter API defination to mandate id

* fix(queue service ): delete all valid messages to prevent q congestion

* fix(InfraService): remove usage of async/await in higher order func

* feat(site launch): email admin if requester was not input properly

send res eariler

* chore(launch client): rename params + fix typo

* feat(site launch): creation of domain assocaitaion in amplify

* feat: add basic lambda fns

* feat: add basic step function workflow

* feat: add gen and pri domain validation lambdas

* feat: extend InfraService to handle failure resp

* refactor: get rid of dummy lambdas

* feat(redirections ): change message shape to cater for the 2 types

* feat(site launch): read from .env + wrongly input state machine error

* feat(site launch redirections ): only provide support for A record redirection

for standardision purposes

* style(redirection-lambda): remove trivial comments, change logs

* feat(site launch): creation of domain assocaitaion in amplify

* fix(launches and redirections models): tables should be paranoid, and have

* feat(site launch): ability to update redirections table

* feat(redirections ): change message shape to cater for the 2 types

* fix(redirection domains): bug fix for domain associations with no redirect

* feat(site launch): read from .env + wrongly input state machine error

* Chore: update MessageBody type

* Feat: launchsite return domain validation information

* Feat: send email on launch success/failure

* Fix: modify launchSite to send proper email on success

* Fix: revert message body split

* fix(site launch): remove duplicate functions after rebase

Co-authored-by: Kishore <e0323826@u.nus.edu>
Co-authored-by: Preston Lim <prestonlimlianjie@gmail.com>

* Feat/integrate aws with site launch microservice (#561)

* feat(launches table): migrations + table for launches

* feat(redirections): redirections table + migration

* fix(launches): change  type to number

* feat(site launch db): site associations for db

* fix(site launch models ): correct usage of model associations

* feat(site launch db): add assocations for user - launch & launch - redir

* fix(site launch sequalize): fix typos

* feat(site launch): creation of domain assocaitaion in amplify

* feat(site launch): remove hardcoded params when updating db

* feat(site launch): pushing messages to local queue

* feat(site launch): ability to add and read + rm messages from queues

* refactor(QueueClient): remove hardcoded queue url

* feat(sitelaunch): standarise shape of message sent to outgoing queue

* fix(site launch): preventing race condition when 2 sites launched...

at the same time. Originally, LaunchesService had instance variables to
cache results from the db, rather than keep re-pining the db for the
siteId + appId. But, this might lead to a race condition if two forms
were submitted back-to-back. As such, data is passed back to the parent
to be reused, rather than storing it within the singular object
 being created during runtime.

* feat(site launch): support for adding redirection into outgoing queue

* refactor(queue service): change code style to prevent inner functions

* fix(site launch): prevent weird  bug when polling for the

incomming queue. For more details:
aws/aws-sdk-js#2793

* feat(site launch): ability to update redirections table

* fix(incoming queue poller): fix undeterministic bug with regards HTTP push

* style(site launch): add in comments for clarity

-change  to

* refactor(site launch): renames for clairty

* refactor(site launch): dependency injection pattern design

* refactor(launches service): move waiting code to parent function

* style(infra service ): use destructuring assignment

* chore(site launch ): remove hardcoded params

* refactor(launch client): remove env var and replace as constant

* refactor(queue client): clearer log messages

* feat(site launch): creation of domain assocaitaion in amplify

* fix(launches and redirections models): tables should be paranoid, and have

* feat: add basic lambda fns

* feat: add basic step function workflow

* fix(launches and redirections models): tables should be paranoid, and have

* feat: add gen and pri domain validation lambdas

* fix(generl domain validation): throw error if inital parameters are not defined

* fix(launches and redirections models): tables should be paranoid, and have

* feat: add success and failure lambdas

* refactor: get rid of dummy lambdas

* fix: set success true in success notif lambda

* fix(launches and redirections models): tables should be paranoid, and have

* feat(site launch): step functions trigger lambda

* fix(launches and redirections models): tables should be paranoid, and have

* feat(redirections ): change message shape to cater for the 2 types

* fix(redirection domains): bug fix for domain associations with no redirect

* feat(site launch): read from .env + wrongly input state machine error

* feat(site launch redirections ): only provide support for A record redirection

for standardision purposes

* style(redirection-lambda): remove trivial comments, change logs

* feat(site launch): creation of domain assocaitaion in amplify

* fix(launches and redirections models): tables should be paranoid, and have

* feat(site launch): ability to update redirections table

* feat(redirections ): change message shape to cater for the 2 types

* fix(redirection domains): bug fix for domain associations with no redirect

* feat(site launch): read from .env + wrongly input state machine error

* Chore: update MessageBody type

* Feat: launchsite return domain validation information

* Feat: send email on launch success/failure

* Fix: modify launchSite to send proper email on success

* Fix: revert message body split

* feat(site launch): creation of domain assocaitaion in amplify

* fix(launches and redirections models): tables should be paranoid, and have

* feat(site launch): ability to update redirections table

* feat: add success and failure lambdas

* feat(redirections ): change message shape to cater for the 2 types

* fix(redirection domains): bug fix for domain associations with no redirect

* feat(site launch): read from .env + wrongly input state machine error

* Feat: launchsite return domain validation information

* Fix: modify launchSite to send proper email on success

* fix(failure lambda ): output message not having the right message shape

* fix(serverless deployment): created new npm project within backend

This is to prevent the loading of all node modules for the site launch
microservice

* feat(redeclare interfaces): reducing the size of package for deployment of...

microservice. This is not an idael solution, seperate PR to refactor
this to read from a shared folder.

* feat(site launch): dns records email to also include pri domain

* build(site launch): removing serverless to test functionality

* fix(build script): fix path

* feat(step functions): Increase interval to once every 5 mins to ...

prevent hitting api rate limit. Changed backoff rate to 1 to allow for
exaclty 12 calls in one hour.

* refactor(domain validation lambda ): standardise message body for lambda

* refactor(primary domain validation lambda ): standarise message body for lambda

* fix(redirection domain lambda ): add in edge case if file already exists in github

* fix(success noti lambda): fix output params shape

* fix(step functions triggering lambda ): removal of local host

local host stuff tends to be buggy as it just emulates aws, but there
are subtle differences. it would make more sense to just test directly
in the lambdas that are deployed

* refactor(step functions): move shared declarations to a seperate folder

* refactor(site launch backend): use defination of messagebody from shared folder

* fix(primary domain validation): fix import dns issue

* feat(site launhc): dont allow moe folks to receive email + support

for redirection servers for both CNAME and A Records

* fix(domain validation lambda ): reduce backoff rate

* chore(launches service): remove unnecessary logging

* fix(launches model): launches model should be a 1-1 relationship

* feat(site launch): more robust updates to site launch during retry

updating in launches table and deleting all previous versions of
redirections

* feat(site launch): send email to ops if failure to trigger

createDomainAssociation.

* fix(sending email to agency folks): emails should not be send to agency users if

they are moe folks

* refactor(infra service): abstract out function for neatness

* fix(infra service ): only admins should receive vebose information

about error messages when failure

* feat(site launch redirections ): only provide support for A record redirection

for standardision purposes

* fix(site launch): clean up for imports

* style(failure noti lambda): remove console.log statements

* style(redirection domain): eariler return

* fix(redirection lambda): better error handling

* feat(package.json): remove deploying of serverless ...

seperate dev and serverless stuff to prevent bloat

* style(launches service ): use upsert for cleaner code

* style(launches service): use promise.all + map

* fix(site launch): remove sending of emails to agency

* style(infraservice): abstract out email details

* style(infraservice): declare type

* fix(redirection lambda): chnage branch to master

* feat(sire launch ): allow for multiple site launches in a single form

* refactor(infra service): refactor url validation method call

* fix(infra service ): fix bug when subdomain prefix is empty

* fix(site launch microservice): fix imports and simplify winston logger

* feat(site launch microservice): add in pending state for site launch end state

* fix(migrations): remove redundant columns

* refactor(infra service): non-null assertion for field

* fix(infra service ): change condition check for successful message

* fix(redirection lambda ): change logic to just parse repsonse in error

* refactor(shared types): change immutables to have UpperCamelCase

* fix(logger): change region + name of log group

* style(formsglaunch): adding in comments for clarity

* style(formsg site launch): use map + add comment for clarity

* refactor(redirection lambda ): remove redundant logging

* refactor(infraservice): clearer if logic

* refactor(launches service ): dont destroy

no need to destroy redirections if there is a new launch

* style(site launch): stricter typing for redirection domain object

* refactor(infraservice): code refactor for clarity

* refactor(infra service ): add guard clause

* fix(infraservice ): remove unnecessary code

remove redundant code

* refactor(infraservice): add helper methods to send emails instead

Co-authored-by: Preston Lim <prestonlimlianjie@gmail.com>
Co-authored-by: Alexander Lee <alexander@open.gov.sg>

Co-authored-by: Preston Lim <prestonlimlianjie@gmail.com>
Co-authored-by: Alexander Lee <alexander@open.gov.sg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants