Skip to content

Commit

Permalink
Merge pull request #7 from umccr/refactor/toml
Browse files Browse the repository at this point in the history
refactor: remove TOML config and related changes
  • Loading branch information
mmalenic authored Jan 24, 2025
2 parents cd5d3b3 + 93a2833 commit de0bf47
Show file tree
Hide file tree
Showing 28 changed files with 2,047 additions and 1,277 deletions.
13 changes: 11 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: pretty-format-json
args: ["--autofix"]
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args: ["--baseline", ".secrets.baseline"]
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.4.2
hooks:
- id: prettier
exclude: pnpm-lock.yaml
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.18.0
hooks:
- id: eslint
files: \.[jt]sx?$
types: [file]
193 changes: 0 additions & 193 deletions DEPLOY.md

This file was deleted.

25 changes: 0 additions & 25 deletions Dockerfile

This file was deleted.

17 changes: 0 additions & 17 deletions Dockerfile.dockerignore

This file was deleted.

91 changes: 71 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,94 @@
# Quickstart
# htsget-deploy

Here's how to deploy [htsget-rs's htsget-lambda](https://github.com/umccr/htsget-rs) to AWS:
Deploy a cloud-based implementation of [htsget-rs]. This project contains a reusable CDK construct that deploys
[htsget-lambda] using an AWS [API Gateway][aws-api-gateway] function and an example CDK stack.

## Quickstart

1. Authenticate to your AWS account (preferably using SSO).
2. Modify the `bin/settings.ts`, according to your preferences.
3. Modify `config/<YOUR_TOML_FILE>.toml` pointed by `bin/settings.ts` accordingly.
4. Run `cdk deploy`.
Here's how to deploy [htsget-rs's htsget-lambda](https://github.com/umccr/htsget-rs) to AWS:

If the above guidance is insufficient, please refer to the [DEPLOY.md](DEPLOY.md) document for a more in-depth
walkthrough settings and operations.
1. Install packages by running `npm install` or `pnpm install`.
2. Authenticate to your AWS account (preferably using SSO).
3. Modify the [`bin/settings.ts`][htsget-settings], according to your preferences. All options are documented at [`docs/CONFIG.md`][docs-config].
4. Run `npx cdk deploy`.

## Does it work?
### Does it work?

A simple `curl` command should be able to determine that:

```sh
curl "https://htsget-demo.ga4gh-demo.org/reads/service-info"
curl "https://htsget.ga4gh-demo.org/reads/service-info"
```

Should return a response similar to the following one (some fields elided for brevity):
Should return a response similar to the following:

```json
{
"name": "umccr-htsget-rs",
"version": "0.1",
"id": "htsget-lambda/0.5.2",
"createdAt": "2025-01-22T23:29:34.423733522+00:00",
"name": "htsget-lambda",
"version": "0.5.2",
"updatedAt": "2025-01-22T23:29:34.423735886+00:00",
"description": "A cloud-based instance of htsget-rs using AWS Lambda, which serves data according to the htsget protocol.",
"organization": {
"name": "UMCCR",
"url": "https://umccr.org/"
"name": "",
"url": ""
},
"documentationUrl": "https://github.com/umccr/htsget-rs",
"type": {
"group": "org.ga4gh",
"artifact": "htsget",
"version": "1.3.0"
},
"htsget": {
"datatype": "reads",
"formats": [
"BAM",
"CRAM"
]
},
"contactUrl": "https://umccr.org/",
"documentationUrl": "https://github.com/umccr/htsget-rs",
],
"fieldsParametersEffective": false,
"tagsParametersEffective": false
}
}
```

Please note that the example above assumes a publicly accessible endpoint. If you have an authz'd deployment, please use `-H "Authorization: $JWT_TOKEN"` flags added to your `curl` command.
Please note that the example above assumes a publicly accessible endpoint. If you have an authz'd deployment, please add `-H "Authorization: $JWT_TOKEN"` flags to your `curl` command.

## Library

The `HtsgetConstruct` is [published][htsget-npm] as an NPM package so that it can be used as construct in other projects.

## Local development

This project uses pnpm as the preferred package manager. To install and update the lock file, run:

```sh
pnpm install
```

To generate the [config docs][docs-config], run:

```sh
npx typedoc
```

[htsget-npm]: https://www.npmjs.com/package/htsget-lambda
[docs-config]: docs/CONFIG.md
[htsget-settings]: bin/settings.ts
[cargo-lambda]: https://github.com/cargo-lambda/cargo-lambda
[htsget-rs]: https://github.com/umccr/htsget-rs
[aws-cdk]: https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html
[cdk-context]: https://docs.aws.amazon.com/cdk/v2/guide/context.html
[cdk-lookup-value]: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ssm.StringParameter.html#static-valuewbrfromwbrlookupscope-parametername
[cdk-json]: cdk.json
[aws-ssm]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html
[aws-api-gateway]: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
[aws-cognito]: https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html
[jwt-authorizer]: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html
[jwt-audience]: https://docs.aws.amazon.com/apigatewayv2/latest/api-reference/apis-apiid-authorizers-authorizerid.html#apis-apiid-authorizers-authorizerid-model-jwtconfiguration
[route-53]: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html
[rust-function]: https://www.npmjs.com/package/rust.aws-cdk-lambda
[aws-cdk]: https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html
[aws-cli]: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
[npm]: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
[rust]: https://www.rust-lang.org/tools/install
32 changes: 0 additions & 32 deletions bin/htsget-lambda.ts

This file was deleted.

31 changes: 31 additions & 0 deletions bin/htsget-stack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as cdk from "aws-cdk-lib";
import { Construct } from "constructs";
import { HtsgetLambdaProps } from "../index";
import { SETTINGS } from "./settings";
import { HtsgetLambda } from "../lib/htsget-lambda";

export class HtsgetStack extends cdk.Stack {
constructor(
scope: Construct,
id: string,
settings: HtsgetLambdaProps,
props?: cdk.StackProps,
) {
super(scope, id, props);

new HtsgetLambda(this, "HtsgetLambda", settings);
}
}

const app = new cdk.App();
new HtsgetStack(app, "HtsgetLambdaStack", SETTINGS, {
stackName: "HtsgetLambdaStack",
description: "A stack deploying htsget-rs with API gateway.",
tags: {
Stack: "HtsgetLambdaStack",
},
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION,
},
});
23 changes: 3 additions & 20 deletions bin/settings.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
import { HtsgetStatelessSettings } from "../lib/htsget-lambda-construct";
import { HtsgetStatefulSettings } from "../lib/htsget-lambda-construct";
import { HtsgetLambdaProps } from "../index";

/**
* Settings to use for the htsget deployment.
*/
export const SETTINGS: HtsgetStatelessSettings & HtsgetStatefulSettings = {
config: "config/example_deploy.toml",
domain: "demo.umccr.org",
subDomain: "htsget",
s3BucketResources: [],
lookupHostedZone: true,
createS3Bucket: true,
export const SETTINGS: HtsgetLambdaProps = {
domain: "ga4gh.org",
copyTestData: true,
copyExampleKeys: true,
// Override the bucket name.
// bucketName: "bucket",
jwtAuthorizer: {
// Set this to false if you want a private instance.
public: true,
cogUserPoolId: "", // i.e: ap-southeast-2_iWOHnsurL
jwtAudience: [""], // Should match your cognito client id, i.e: 3jgmc7kqaaf8mqbv2sgmujslrp
},
// Enable additional features for compiling htsget-rs. `s3-storage` is always enabled.
features: ["experimental", "aws"], // i.e: Enables Crypt4Gh+htsget functionality
};
11 changes: 3 additions & 8 deletions cdk.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"app": "npx ts-node --prefer-ts-exts bin/htsget-lambda.ts",
"app": "npx ts-node --prefer-ts-exts bin/htsget-stack.ts",
"context": {
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
Expand All @@ -10,10 +10,7 @@
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:stackRelativeExports": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
]
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"]
},
"watch": {
"exclude": [
Expand All @@ -27,8 +24,6 @@
"node_modules",
"test"
],
"include": [
"**"
]
"include": ["**"]
}
}
64 changes: 0 additions & 64 deletions config/dev_umccr.toml

This file was deleted.

Loading

0 comments on commit de0bf47

Please sign in to comment.