Skip to content

Commit b905592

Browse files
authored
Merge pull request #24 from umccr/feature/aws-vpc-lattice-support
added new vpc lattice stack
2 parents 1adebdd + 0d53be5 commit b905592

14 files changed

+651
-27
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ cdk.out
77
*.d.ts
88
*.js
99
dist
10-
.dev.vars
11-
.wrangler
10+
.idea/

aws-vpc-lattice/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## Quickstart
2+
3+
Here's how to deploy [htsget-rs's htsget-lambda](https://github.com/umccr/htsget-rs) to AWS in
4+
a VPC Lattice configuration. This is more a code example rather than a practical deployment.
5+
Code features it has:
6+
7+
1. Construction of VPC Lattice artifacts
8+
2. Deployment of htsget-rs as a Lambda Target Group
9+
10+
To deploy:
11+
12+
1. Authenticate to your AWS account (preferably using SSO).
13+
2. Modify the [`htsget-vpc-lattice-app.ts`][htsget-vpc-lattice-app], according to your preferences.
14+
3. Run `pnpm cdk deploy`.
15+
16+
### Does it work?
17+
18+
The VPC Lattice service network will be shared to the list of AWS accounts
19+
in the app settings. You will need to accept the RAM share in those
20+
accounts in order to then construct a service network client.
21+
22+
Once the service network in the other account is associated with a VPC (say) -
23+
then from that VPC a simple `curl` command should be able to determine that:
24+
25+
```sh
26+
curl "https://<host>/reads/service-info"
27+
```
28+
29+
Should return a response similar to the following:
30+
31+
```json
32+
{
33+
"id": "htsget-lambda/0.5.2",
34+
"createdAt": "2025-01-22T23:29:34.423733522+00:00",
35+
"name": "htsget-lambda",
36+
"version": "0.5.2",
37+
"updatedAt": "2025-01-22T23:29:34.423735886+00:00",
38+
"description": "A cloud-based instance of htsget-rs using AWS Lambda, which serves data according to the htsget protocol.",
39+
"organization": {
40+
"name": "",
41+
"url": ""
42+
},
43+
"documentationUrl": "https://github.com/umccr/htsget-rs",
44+
"type": {
45+
"group": "org.ga4gh",
46+
"artifact": "htsget",
47+
"version": "1.3.0"
48+
},
49+
"htsget": {
50+
"datatype": "reads",
51+
"formats": [
52+
"BAM",
53+
"CRAM"
54+
],
55+
"fieldsParametersEffective": false,
56+
"tagsParametersEffective": false
57+
}
58+
}
59+
```

aws-vpc-lattice/cdk.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"app": "npx ts-node --prefer-ts-exts htsget-vpc-lattice-app.ts",
3+
"context": {
4+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
5+
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
6+
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
7+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
8+
"@aws-cdk/aws-iam:minimizePolicies": true,
9+
"@aws-cdk/aws-lambda:recognizeVersionProps": true,
10+
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
11+
"@aws-cdk/core:checkSecretUsage": true,
12+
"@aws-cdk/core:stackRelativeExports": true,
13+
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"]
14+
},
15+
"watch": {
16+
"exclude": [
17+
"README.md",
18+
"cdk*.json",
19+
"**/*.d.ts",
20+
"**/*.js",
21+
"tsconfig.json",
22+
"package*.json",
23+
"yarn.lock",
24+
"node_modules",
25+
"test"
26+
],
27+
"include": ["**"]
28+
}
29+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import * as cdk from "aws-cdk-lib";
2+
import { HtsgetVpcLatticeStack } from "./htsget-vpc-lattice-stack";
3+
4+
const stackId = "HtsgetVpcLatticeStack";
5+
6+
const app = new cdk.App();
7+
8+
new HtsgetVpcLatticeStack(
9+
app,
10+
stackId,
11+
{
12+
vpcOrName: "main-vpc",
13+
destinationAccounts: ["534840902377"],
14+
htsgetConfig: {
15+
environment_override: {
16+
HTSGET_LOCATIONS: "[]",
17+
HTSGET_DATA_SERVER: "None",
18+
HTSGET_AUTH_AUTHORIZATION_URL: `https://elsa-data.dev.umccr.org/api/integration/htsget-rs`,
19+
HTSGET_AUTH_FORWARD_ENDPOINT_TYPE: true,
20+
HTSGET_AUTH_FORWARD_ID: true,
21+
HTSGET_AUTH_SUPPRESS_ERRORS: true,
22+
HTSGET_AUTH_ADD_HINT: true,
23+
HTSGET_AUTH_FORWARD_EXTENSIONS: `[{ json_path=$.requestContext.identity.sourceVpcArn, name=SourceVpcArn }]`,
24+
AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH: true,
25+
},
26+
},
27+
build: {
28+
gitReference: "main",
29+
gitForceClone: true,
30+
},
31+
naming: {
32+
subDomain: "htsget-vpc-lattice",
33+
domain: "dev.umccr.org",
34+
certificateArn:
35+
"arn:aws:acm:ap-southeast-2:843407916570:certificate/aa9a1385-7f72-4f1f-98a5-a5da2eff653b",
36+
},
37+
},
38+
{
39+
stackName: stackId,
40+
description:
41+
"A stack deploying htsget-rs with VPC Lattice in a UMCCR environment",
42+
tags: {
43+
Stack: stackId,
44+
},
45+
env: {
46+
account: process.env.CDK_DEFAULT_ACCOUNT,
47+
region: process.env.CDK_DEFAULT_REGION,
48+
},
49+
},
50+
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as cdk from "aws-cdk-lib";
2+
import { Construct } from "constructs";
3+
import { HtsgetVpcLatticeLambda } from "./lib/htsget-vpc-lattice-lambda";
4+
import { HtsgetVpcLatticeLambdaProps } from "./lib/htsget-vpc-lattice-lambda-props";
5+
6+
export class HtsgetVpcLatticeStack extends cdk.Stack {
7+
constructor(
8+
scope: Construct,
9+
id: string,
10+
settings: HtsgetVpcLatticeLambdaProps,
11+
props?: cdk.StackProps,
12+
) {
13+
super(scope, id, props);
14+
15+
new HtsgetVpcLatticeLambda(this, "HtsgetVpcLatticeLambda", settings);
16+
}
17+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { IVpc } from "aws-cdk-lib/aws-ec2";
2+
import { IRole } from "aws-cdk-lib/aws-iam";
3+
import { HtsgetConfig } from "htsget-lambda/lib/config";
4+
5+
/**
6+
* Settings related to the htsget lambda construct props.
7+
*/
8+
export interface HtsgetVpcLatticeLambdaProps {
9+
/**
10+
* The htsget-rs config options. Use this to specify any locations and htsget-rs options.
11+
*
12+
* @defaultValue undefined
13+
*/
14+
htsgetConfig?: HtsgetConfig;
15+
16+
build: {
17+
/**
18+
* The git reference to fetch from the htsget-rs repo.
19+
*
20+
* @defaultValue "main"
21+
*/
22+
gitReference?: string;
23+
24+
/**
25+
* Whether to force a git clone for every build. If this is false, then the git repo is only cloned once
26+
* for every git reference in a temporary directory. Otherwise, the repo is cloned every time.
27+
*
28+
* @defaultValue false
29+
*/
30+
gitForceClone?: boolean;
31+
32+
/**
33+
* Override any cargo lambda flags for the build. By default, features are resolved automatically based on the
34+
* config and `HtsgetLocation[]`. This option overrides that and any automatically added flags.
35+
*
36+
* @defaultValue undefined
37+
*/
38+
cargoLambdaFlags?: string[];
39+
40+
/**
41+
* Override the environment variables used to build htsget. Note that this only adds environment variables that
42+
* get used to build htsget-rs with `cargo`. It has no effect on the environment variables that htsget-rs has when
43+
* the Lambda function is deployed. In general, leave this undefined unless there is a specific reason to override
44+
* the build environment.
45+
*
46+
* @defaultValue undefined
47+
*/
48+
buildEnvironment?: Record<string, string>;
49+
};
50+
51+
/**
52+
* How to name the VPC Lattice service.
53+
*/
54+
naming: {
55+
/**
56+
* The domain name for the htsget server. This assumes
57+
* that a `HostedZone` exists for this domain.
58+
*/
59+
domain: string;
60+
61+
/**
62+
* The domain name prefix to use for the htsget-rs server.
63+
*/
64+
subDomain: string;
65+
66+
/**
67+
* The certificate ARN for SSL corresponding to a wildcard or specific cert for the sub.domain
68+
*/
69+
certificateArn: string;
70+
};
71+
72+
/**
73+
* Specify a VPC for the Lambda function, or specify the name of the VPC to lookup.
74+
*/
75+
vpcOrName: string | IVpc;
76+
77+
/**
78+
* Use the provided role instead of creating one. This will ignore any configuration related to permissions for
79+
* buckets and secrets, and rely on the existing role.
80+
*
81+
* @defaultValue undefined
82+
*/
83+
role?: IRole;
84+
85+
/**
86+
* A list of AWS account ids that the VPC Lattice service will be shared to using RAM.
87+
*/
88+
destinationAccounts: string[];
89+
}

0 commit comments

Comments
 (0)