Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
fix: Allow running sls offline with Hapi Validator (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyen102 authored Jun 3, 2021
1 parent 376fd68 commit 8b98da9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
13 changes: 12 additions & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ Once the script has finished running, you can run `yarn watch` in the directory

`AWS_ACCESS_KEY_ID=<Access-Key> AWS_SECRET_ACCESS_KEY=<Secret-Key> OFFLINE_BINARY_BUCKET=<FHIRBinaryBucket> OFFLINE_ELASTICSEARCH_DOMAIN_ENDPOINT=<ElasticSearchDomainEndpoint> serverless offline start`

If you don't know the `OFFLINE_BINARY_BUCKET` and `OFFLINE_ELASTICSEARCH_DOMAIN_ENDPOINT` value, you can run `serverless info --verbose` in the deployment package directory.
### Local Development with Implementation Guides

If you're using [Implementation Guides](./USING_IMPLEMENTATION_GUIDES.md), then follow these steps to run FHIR Works with IG locally. You'll need to provide the `OFFLINE_LAMBDA_VALIDATOR_ALIAS`.

Run this command in the `deployment` package directory to start your local environment:

`AWS_ACCESS_KEY_ID=<Access-Key> AWS_SECRET_ACCESS_KEY=<Secret-Key> OFFLINE_BINARY_BUCKET=<FHIRBinaryBucket> OFFLINE_ELASTICSEARCH_DOMAIN_ENDPOINT=<ElasticSearchDomainEndpoint> OFFLINE_VALIDATOR_LAMBDA_ALIAS=<ValidatorLambdaAlias> serverless offline start`

The command above runs the local FHIR server with the appropriate environment variables.

If you don't know the value for `OFFLINE_BINARY_BUCKET`,`OFFLINE_ELASTICSEARCH_DOMAIN_ENDPOINT`, and `OFFLINE_VALIDATOR_LAMBDA_ALIAS` value, run the following command in the deployment package directory: `serverless info --verbose`


## Deploy Local Packages to AWS

Expand Down
5 changes: 5 additions & 0 deletions serverless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,11 @@ resources:
]
Export:
Name: !Join ['-', [CloudwatchExecutionLogGroup, !Ref Stage, Arn]]
ValidatorLambdaAlias:
Condition: isUsingHapiValidator
Description: Arn of Hapi Validator lambda
Value:
Fn::ImportValue: "fhir-service-validator-lambda-${self:custom.stage}"

plugins:
- serverless-step-functions
Expand Down
5 changes: 4 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ const dynamoDbBundleService = new DynamoDbBundleService(DynamoDb);

// Configure the input validators. Validators run in the order that they appear on the array. Use an empty array to disable input validation.
const validators: Validator[] = [];
if (process.env.VALIDATOR_LAMBDA_ALIAS) {
if (process.env.VALIDATOR_LAMBDA_ALIAS && process.env.VALIDATOR_LAMBDA_ALIAS !== '[object Object]') {
// The HAPI FHIR Validator must be deployed separately. It is the recommended choice when using implementation guides.
validators.push(new HapiFhirLambdaValidator(process.env.VALIDATOR_LAMBDA_ALIAS));
} else if (process.env.OFFLINE_VALIDATOR_LAMBDA_ALIAS) {
// Allows user to run sls offline with custom provided HAPI Lambda
validators.push(new HapiFhirLambdaValidator(process.env.OFFLINE_VALIDATOR_LAMBDA_ALIAS));
} else {
// The JSON Schema Validator is simpler and is a good choice for testing the FHIR server with minimal configuration.
validators.push(new JsonSchemaValidator(fhirVersion));
Expand Down

0 comments on commit 8b98da9

Please sign in to comment.