Skip to content

Commit

Permalink
adding deployment guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigues committed Mar 4, 2021
1 parent 5c397a1 commit 2a5ef60
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 16 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ A solution prototype utilizing AWS-managed Natural Language Processing (NLP) ser
## High level Architecture
![alt text](src/backend/media/AWS_Diagram.png)

## Stack Documentation
[Backend Documentation](src/backend/README.md) \
[Frontend Documentation](src/frontend/README.md)
## Deployment
deploy this solution into your AWS Account please follow our [Deployment Guide](doc/deployment_guide.md)

[UBC CIC Project Page](https://cic.ubc.ca/projects/vch-mri-project-cant-wait/)

Expand Down
88 changes: 88 additions & 0 deletions docs/deployment_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Requirements
Before you deploy, you must have the following in place:
* [AWS Account](https://aws.amazon.com/account/)
* [GitHub Account](https://github.com/)
* [AWS CLI](https://aws.amazon.com/cli/)
* [SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
* [Amplify CLI installed and configured](https://aws-amplify.github.io/docs/cli-toolchain/quickstart#quickstart)


# Step 1: Front-end deployment

1. Clone and Fork this solution repository.
If you haven't configured Amplify before, configure the Amplify CLI in your terminal as follows:
```bash
amplify configure
```

2. In a terminal from the project root directory, enter the following command selecting the IAM user of the AWS Account you will deploy this application from. (accept all defaults):

```bash
amplify init
```

3. Deploy the resourse to your AWS Account using the command:
```bash
amplify push
```

4. Log into the AWS Management Console.
5. Select AWS Amplify and select the **mri-sched**
6. At the *Frontend environments* tab connect to your github account poiting to the forked repo. More informatoin at https://docs.aws.amazon.com/amplify/latest/userguide/deploy-backend.html

# Step 2: Back-end deployment

If you don’t have any Amazon EC2 key-pair available [create-your-key-pair](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#having-ec2-create-your-key-pair). You need the name of the key-pair to proceed. You can list your key-pair executing the following command:
```bash
aws ec2 describe-key-pairs
```

1. Store the database username and password at Systems Manager Parameter Store. **Make sure to replace DATABASENAME and DATABASEPWD with the respectives username and password you want to use for the database.
```bash
aws ssm put-parameter --name "/mri-sched/dbuser_ec2" --value "DATABASENAME" --type SecureString --overwrite
aws ssm put-parameter --name "/mri-sched/dbpwd_ec2" --value "DATABASEPWD" --type SecureString --overwrite
```

2. In this step we will execute AWS SAM guided configuration by running.
```bash
sam deploy -g --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND CAPABILITY_NAMED_IAM
```

3. Provide the stack name, region and the key-pair name. For all other question accept the default answer or select *Y*. Below an example:

```
Configuring SAM deploy
======================
Looking for config file [samconfig.toml] : Not found
Setting default arguments for 'sam deploy'
=========================================
Stack Name [sam-app]: mri-sched
AWS Region [us-east-1]: [Your-AWS-REGION]
Parameter CidrBlockVpcParameter [10.0.0.0/16]:
Parameter PrivateSubnetAParameter [10.0.1.0/24]:
Parameter PublicSubnetAParameter [10.0.2.0/24]:
Parameter DBInstanceTypeParameter [t3.medium]:
Parameter AMIID [/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2]:
Parameter KeyName []: [Your-Key-Pair Name]
#Shows you resources changes to be deployed and require a 'Y' to initiate deploy
Confirm changes before deploy [y/N]: y
#SAM needs permission to be able to create roles to connect to the resources in your template
Allow SAM CLI IAM role creation [Y/n]: y
Preprocess may not have authorization defined, Is this okay? [y/N]: y
QueryRules may not have authorization defined, Is this okay? [y/N]: y
QuerySpellchecker may not have authorization defined, Is this okay? [y/N]: y
QueryConjunctions may not have authorization defined, Is this okay? [y/N]: y
QueryWeights may not have authorization defined, Is this okay? [y/N]: y
QuerySpecialtyTags may not have authorization defined, Is this okay? [y/N]: y
DataResults may not have authorization defined, Is this okay? [y/N]: y
Save arguments to configuration file [Y/n]: y
SAM configuration file [samconfig.toml]:
SAM configuration environment [default]:
```

4. Confirm the deployment and wait for the stack to be created.



11 changes: 11 additions & 0 deletions samconfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version = 0.1
[default]
[default.deploy]
[default.deploy.parameters]
stack_name = "mri-sched"
s3_bucket = "aws-sam-cli-managed-default-samclisourcebucket-tv5fka8ymyxs"
s3_prefix = "mri-sched"
region = "us-west-2"
confirm_changeset = true
capabilities = "CAPABILITY_IAM CAPABILITY_AUTO_EXPAND CAPABILITY_NAMED_IAM"
parameter_overrides = "CidrBlockVpcParameter=\"10.0.0.0/16\" PrivateSubnetAParameter=\"10.0.1.0/24\" PublicSubnetAParameter=\"10.0.2.0/24\" DBInstanceTypeParameter=\"t3.medium\" AMIID=\"/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2\" KeyName=\"pdx-kenobi\""
26 changes: 13 additions & 13 deletions src/backend/template.yaml → template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ Resources:
Type: AWS::Serverless::LayerVersion
Properties:
Description: Spell Checker
ContentUri: ./layers/spellchecker.zip
ContentUri: ./src/backend/layers/spellchecker.zip
CompatibleRuntimes:
- python3.8
- python3.7
Expand All @@ -345,7 +345,7 @@ Resources:
Type: AWS::Serverless::LayerVersion
Properties:
Description: Psycopg2 Library
ContentUri: ./layers/psycopg2.zip
ContentUri: ./src/backend/layers/psycopg2.zip
CompatibleRuntimes:
- python3.8
- python3.7
Expand All @@ -356,7 +356,7 @@ Resources:
Type: AWS::Serverless::LayerVersion
Properties:
Description: Postgres Custom Functions
ContentUri: ./layers/postgresql.zip
ContentUri: ./src/backend/layers/postgresql.zip
CompatibleRuntimes:
- python3.8
- python3.7
Expand All @@ -366,7 +366,7 @@ Resources:
Preprocess:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./lambdas/preprocess
CodeUri: ./src/backend/lambdas/preprocess
Events:
ExplicitApi: # warning: creates a public endpoint
Type: HttpApi
Expand Down Expand Up @@ -403,7 +403,7 @@ Resources:
RuleProcessing:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./lambdas/rule_processing
CodeUri: ./src/backend/lambdas/rule_processing
Layers:
- !Ref Psycopg2Layer
- !Ref PostgresLayer
Expand All @@ -420,7 +420,7 @@ Resources:
QueryRules:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./lambdas/query_rules_table
CodeUri: ./src/backend/lambdas/query_rules_table
Events:
ExplicitApi: # warning: creates a public endpoint
Type: HttpApi
Expand Down Expand Up @@ -453,7 +453,7 @@ Resources:
QuerySpellchecker:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./lambdas/query_spellchecker
CodeUri: ./src/backend/lambdas/query_spellchecker
Events:
ExplicitApi: # warning: creates a public endpoint
Type: HttpApi
Expand All @@ -480,7 +480,7 @@ Resources:
QueryConjunctions:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./lambdas/query_conjunctions
CodeUri: ./src/backend/lambdas/query_conjunctions
Events:
ExplicitApi: # warning: creates a public endpoint
Type: HttpApi
Expand All @@ -507,7 +507,7 @@ Resources:
QueryWeights:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./lambdas/query_weights
CodeUri: ./src/backend/lambdas/query_weights
Events:
ExplicitApi: # warning: creates a public endpoint
Type: HttpApi
Expand Down Expand Up @@ -540,7 +540,7 @@ Resources:
QuerySpecialtyTags:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./lambdas/query_specialty_tags
CodeUri: ./src/backend/lambdas/query_specialty_tags
Events:
ExplicitApi: # warning: creates a public endpoint
Type: HttpApi
Expand All @@ -567,7 +567,7 @@ Resources:
UpdateWeights:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./lambdas/update_word_weights
CodeUri: ./src/backend/lambdas/update_word_weights
Layers:
- !Ref Psycopg2Layer
- !Ref PostgresLayer
Expand All @@ -584,7 +584,7 @@ Resources:
DataResults:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./lambdas/results
CodeUri: ./src/backend/lambdas/results
Events:
ExplicitApi: # warning: creates a public endpoint
Type: HttpApi
Expand All @@ -611,7 +611,7 @@ Resources:
Thesaurus:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./lambdas/thesaurus
CodeUri: ./src/backend/lambdas/thesaurus
Events:
FileUpload:
Type: S3
Expand Down

0 comments on commit 2a5ef60

Please sign in to comment.