isomerpages / isomercms-backend

A static website builder and host for the Singapore Government
5 stars 1 forks source link

Chore(Site launch microservices):managing cloud environments #657

Closed kishore03109 closed 1 year ago

kishore03109 commented 1 year ago

Problem

We used to have local development using serverless offline, before we deployed it into the cloud. However, due to limitations of local development, and the differences between local and the cloud environments, there was effort needed to ensure similarity between emulated local and cloud environments.

Solution

This PR removes lingering local emulation of our cloud services that we no longer intend to use. Additionally, site launch cloud infra will have staging, production environments. If you wish to develop in an isolated cloud environment, simply create your own version of the infra in the cloud. eg: npm run deploy:dev -- --stage kishore-test.

Eng Decisions made

Notice that the package.json has a source ../.env before running the sls deploy command. I opted to use our .env file at the project root rather than creating a separate .env file at /microservices/.env for the following reasons:

  1. Lesser overhead to maintain by keeping all of our env in one singular folder. The values used for a potential /microservices/.env will be a subset of the as the current .env files, so any changes to .env would need to be repeated for /microservices/.env.
  2. Serverless framework is smart enough to only export the variables that are required to run in the script
  3. More intuitive to have a .env in the root folder only rather than at multiple locations

Breaking Changes

Tests

  1. Run npm run deploy:dev -- --stage <your-name>-test
  2. Head to https://ap-southeast-1.console.aws.amazon.com/states/home?region=ap-southeast-1#/statemachines
  3. Verify that new state machine environment has been created
  4. Run npm run destroy: dev -- --stage <your-name>-test to destroy newly created environment

Other notes:

Currently we have SiteLaunchStepFunctionsStateMachine-<some-gibberish-string>. This is currently being used for our site launch process with ops. Will be depreciated soon to directly use SiteLaunchStepFunctions-prod in a separate PR.