diff --git a/.gitignore b/.gitignore index 6314665..2f4edbf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ __pycache__ .vscode # The build folder for sam .aws-sam -.venv \ No newline at end of file +.venv +env.json \ No newline at end of file diff --git a/README.md b/README.md index df2792f..7590c5e 100644 --- a/README.md +++ b/README.md @@ -31,17 +31,39 @@ npm install react react-dom react-router-dom npm install bootstrap npm install -D @vitejs/plugin-react ``` -4. Launch the API, navigate to the API repo and run the following commands +4. Add a env.json to add all credentials necessary ``` -sam build -sam local start-api +{ + "ApiFunction": { + "ENVIRONMENT": "local", #specify local if working in local + "OPENSEARCH_HOST": "opensearch-node1", + "OPENSEARCH_PORT": "9200", + "OPENSEARCH_INITIAL_ADMIN_PASSWORD": "", + "POSTGRES_HOST": "db", + "POSTGRES_PORT": "5432", + "POSTGRES_DB": "postgres", + "POSTGRES_USER": "postgres", + "POSTGRES_PASSWORD": "password", + "DB_SECRET_NAME": "mirrulationsdb/postgres/master", + "OS_SECRET_NAME": "mirrulationsdb/opensearch/master" + } + } ``` +5. Install the [Data-Product-Kit Repo](https://github.com/mirrulations/Data-Product-Kit) to set up the docker. Follow the `ReadMe.md` up to setting up the installations necessary.`LocalTesting.md` instructions. Start with section **"Clean Reset"** and then move on to the top of the document. + + +6. Launch the API, navigate to the API repo and run the following commands +``` +sam build && sam local start-api --env-vars env.json --docker-network shared_network +``` +**Note:** Make sure that you have the env.json in the root directory as sam would need to pick up the environment variables! + If you make changes to template.yaml, run sam validate to check for errors and sam build to implement the changes. Take note of your api gateway link for later, you can see it in the output under “Mounting ApiFunction at {GATEWAY_URL_HERE} [GET, OPTIONS]” -5. Launch the Website +7. Launch the Website - Create a file named “.env” - Type “VITE_GATEWAY_API_URL={GATEWAY_URL}” - Your Gateway URL is the output from the last step, it might look something like “http://127.0.0.1:3000/dummy” diff --git a/samconfig.toml b/samconfig.toml index a1fe67b..f9108b2 100644 --- a/samconfig.toml +++ b/samconfig.toml @@ -17,4 +17,3 @@ region = "us-east-1" confirm_changeset = true # Example: Ensure manual review of changesets in prod capabilities = "CAPABILITY_IAM" disable_rollback = false # Example: Automatically rollback on failure to ensure stability - diff --git a/template.yaml b/template.yaml index c02ccc1..863fa99 100644 --- a/template.yaml +++ b/template.yaml @@ -67,7 +67,16 @@ Resources: Resource: "arn:aws:secretsmanager:us-east-1:936771282063:secret:mirrulationsdb/opensearch/master-7xJt7C" Environment: Variables: - DB_SECRET_NAME: "mirrulationsdb/postgres/master" - OS_SECRET_NAME: "mirrulationsdb/opensearch/master" + ENVIRONMENT: "" + DB_SECRET_NAME: "" + OS_SECRET_NAME: "" + OPENSEARCH_HOST: "" + OPENSEARCH_PORT: "" + OPENSEARCH_INITIAL_ADMIN_PASSWORD: "" + POSTGRES_HOST: "" + POSTGRES_PORT: "" + POSTGRES_DB: "" + POSTGRES_USER: "" + POSTGRES_PASSWORD: "" Timeout: 15 Role: arn:aws:iam::936771282063:role/334s25_lambda_execution_opensearch \ No newline at end of file