@umccr/htsget-lambda 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,240 @@
1
+ import { IVpc } from "aws-cdk-lib/aws-ec2";
2
+ import { CorsHttpMethod, IHttpApi } from "aws-cdk-lib/aws-apigatewayv2";
3
+ import { IRole } from "aws-cdk-lib/aws-iam";
4
+ import { Duration } from "aws-cdk-lib";
5
+ import { IHostedZone } from "aws-cdk-lib/aws-route53";
6
+ /**
7
+ * Settings related to the htsget lambda construct props.
8
+ */
9
+ export interface HtsgetLambdaProps {
10
+ /**
11
+ * The htsget-rs config options. Use this to specify any locations and htsget-rs options.
12
+ *
13
+ * @defaultValue undefined
14
+ */
15
+ htsgetConfig?: HtsgetConfig;
16
+ /**
17
+ * The domain name for the htsget server. This must be specified if `httpApi` is not set. This assumes
18
+ * that a `HostedZone` exists for this domain.
19
+ *
20
+ * @defaultValue undefined
21
+ */
22
+ domain?: string;
23
+ /**
24
+ * The domain name prefix to use for the htsget-rs server.
25
+ *
26
+ * @defaultValue "htsget"
27
+ */
28
+ subDomain?: string;
29
+ /**
30
+ * Whether this deployment is gated behind a JWT authorizer, or if its public.
31
+ *
32
+ * @defaultValue `undefined`, defaults to a public deployment
33
+ */
34
+ jwt?: JwtConfig;
35
+ /**
36
+ * CORS configuration for the htsget-rs server. Values here are propagated to CORS options in htsget-rs.
37
+ *
38
+ * @defaultValue same as the `CorsConfig` defaults
39
+ */
40
+ cors?: CorsConifg;
41
+ /**
42
+ * The git reference to fetch from the htsget-rs repo.
43
+ *
44
+ * @defaultValue "main"
45
+ */
46
+ gitReference?: string;
47
+ /**
48
+ * Whether to force a git clone for every build. If this is false, then the git repo is only cloned once
49
+ * for every git reference in a temporary directory. Otherwise, the repo is cloned every time.
50
+ *
51
+ * @defaultValue false
52
+ */
53
+ gitForceClone?: boolean;
54
+ /**
55
+ * Override any cargo lambda flags for the build. By default, features are resolved automatically based on the
56
+ * config and `HtsgetLocation[]`. This option overrides that and any automatically added flags.
57
+ *
58
+ * @defaultValue undefined
59
+ */
60
+ cargoLambdaFlags?: string[];
61
+ /**
62
+ * Copy the test data directory to a new bucket:
63
+ * https://github.com/umccr/htsget-rs/tree/main/data
64
+ *
65
+ * Also copies the Crypt4GH keys to Secrets Manager. Automatically the htsget-rs server access
66
+ * to the bucket and secrets using the locations config.
67
+ *
68
+ * @defaultValue false
69
+ */
70
+ copyTestData?: boolean;
71
+ /**
72
+ * The name of the bucket to create when using `copyTestData`. Defaults to the auto-generated CDK construct name.
73
+ *
74
+ * @defaultValue undefined
75
+ */
76
+ bucketName?: string;
77
+ /**
78
+ * The name of the Lambda function. Defaults to the auto-generated CDK construct name.
79
+ *
80
+ * @defaultValue undefined
81
+ */
82
+ functionName?: string;
83
+ /**
84
+ * Optionally specify a VPC for the Lambda function.
85
+ *
86
+ * @defaultValue undefined
87
+ */
88
+ vpc?: IVpc;
89
+ /**
90
+ * Manually specify an `HttpApi`. This will not create a `HostedZone`, any Route53 records, certificates,
91
+ * or authorizers, and will instead rely on the existing `HttpApi`.
92
+ *
93
+ * @defaultValue undefined
94
+ */
95
+ httpApi?: IHttpApi;
96
+ /**
97
+ * The arn of the certificate to use. This will not create a `Certificate` if specified, and will instead lookup
98
+ * an existing one.
99
+ *
100
+ * @defaultValue undefined
101
+ */
102
+ certificateArn?: string;
103
+ /**
104
+ * Use the provided hosted zone instead of looking it up from the domain name.
105
+ *
106
+ * @defaultValue undefined
107
+ */
108
+ hostedZone?: IHostedZone;
109
+ /**
110
+ * Use the provided role instead of creating one. This will ignore any configuration related to permissions for
111
+ * buckets and secrets, and rely on the existing role.
112
+ *
113
+ * @defaultValue undefined
114
+ */
115
+ role?: IRole;
116
+ /**
117
+ * The name of the role for the Lambda function. Defaults to the auto-generated CDK construct name.
118
+ *
119
+ * @defaultValue undefined
120
+ */
121
+ roleName?: string;
122
+ /**
123
+ * Override the environment variables used to build htsget. Note that this only adds environment variables that
124
+ * get used to build htsget-rs with `cargo`. It has no effect on the environment variables that htsget-rs has when
125
+ * the Lambda function is deployed. In general, leave this undefined unless there is a specific reason to override
126
+ * the build environment.
127
+ *
128
+ * @defaultValue undefined
129
+ */
130
+ buildEnvironment?: Record<string, string>;
131
+ }
132
+ /**
133
+ * JWT authorization settings.
134
+ */
135
+ export interface JwtConfig {
136
+ /**
137
+ * The JWT audience.
138
+ *
139
+ * @defaultValue []
140
+ */
141
+ audience?: string[];
142
+ /**
143
+ * The cognito user pool id for the authorizer. If this is not set, then a new user pool is created.
144
+ *
145
+ * @defaultValue `undefined`, creates a new user pool
146
+ */
147
+ cogUserPoolId?: string;
148
+ }
149
+ /**
150
+ * CORS configuration for the htsget-rs server.
151
+ */
152
+ export interface CorsConifg {
153
+ /**
154
+ * CORS allow credentials.
155
+ *
156
+ * @defaultValue false
157
+ */
158
+ allowCredentials?: boolean;
159
+ /**
160
+ * CORS allow headers.
161
+ *
162
+ * @defaultValue ["*"]
163
+ */
164
+ allowHeaders?: string[];
165
+ /**
166
+ * CORS allow methods.
167
+ *
168
+ * @defaultValue [CorsHttpMethod.ANY]
169
+ */
170
+ allowMethods?: CorsHttpMethod[];
171
+ /**
172
+ * CORS allow origins.
173
+ *
174
+ * @defaultValue ["*"]
175
+ */
176
+ allowOrigins?: string[];
177
+ /**
178
+ * CORS expose headers.
179
+ *
180
+ * @defaultValue ["*"]
181
+ */
182
+ exposeHeaders?: string[];
183
+ /**
184
+ * CORS max age.
185
+ *
186
+ * @defaultValue Duration.days(30)
187
+ */
188
+ maxAge?: Duration;
189
+ }
190
+ /**
191
+ * Configuration for the htsget-rs server. This allows specifying the options
192
+ * available in the htsget-rs config: https://github.com/umccr/htsget-rs/tree/main/htsget-config
193
+ */
194
+ export interface HtsgetConfig {
195
+ /**
196
+ * The locations for the htsget-rs server. This is the same as the htsget-rs config locations:
197
+ * https://github.com/umccr/htsget-rs/tree/main/htsget-config#quickstart
198
+ *
199
+ * Any `s3://...` locations will automatically be added to the bucket access policy.
200
+ *
201
+ * @defaultValue []
202
+ */
203
+ locations?: HtsgetLocation[];
204
+ /**
205
+ * Service info fields to configure for the server. This is the same as the htsget-rs config service_info:
206
+ * https://github.com/umccr/htsget-rs/tree/main/htsget-config#service-info-config
207
+ *
208
+ * @defaultValue undefined
209
+ */
210
+ service_info?: Record<string, unknown>;
211
+ /**
212
+ * Any additional htsget-rs options can be specified here as environment variables. These will override
213
+ * any options set in this construct, and allows using advanced configuration. Options here should contain
214
+ * the `HTSGET_` prefix.
215
+ *
216
+ * @defaultValue undefined
217
+ */
218
+ environment_override?: Record<string, unknown>;
219
+ }
220
+ /**
221
+ * Config for locations.
222
+ */
223
+ export interface HtsgetLocation {
224
+ /**
225
+ * The location string.
226
+ */
227
+ location: string;
228
+ /**
229
+ * Optional Crypt4GH private key secret ARN or name.
230
+ *
231
+ * @defaultValue undefined
232
+ */
233
+ private_key?: string;
234
+ /**
235
+ * Optional Crypt4GH public key secret ARN or name.
236
+ *
237
+ * @defaultValue undefined
238
+ */
239
+ public_key?: string;
240
+ }
package/lib/config.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBJVnBjIH0gZnJvbSBcImF3cy1jZGstbGliL2F3cy1lYzJcIjtcbmltcG9ydCB7IENvcnNIdHRwTWV0aG9kLCBJSHR0cEFwaSB9IGZyb20gXCJhd3MtY2RrLWxpYi9hd3MtYXBpZ2F0ZXdheXYyXCI7XG5pbXBvcnQgeyBJUm9sZSB9IGZyb20gXCJhd3MtY2RrLWxpYi9hd3MtaWFtXCI7XG5pbXBvcnQgeyBEdXJh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qXG4gICAqIEBkZWZhdWx0VmFsdWUgdW5kZWZpbmVkXG4gICAqL1xuICBlbnZpcm9ubWVudF9vdmVycmlkZT86IFJlY29yZDxzdHJpbmcsIHVua25vd24+O1xufVxuXG4vKipcbiAqIENvbmZpZyBmb3IgbG9jYXRpb25zLlxuICovXG5leHBvcnQgaW50ZXJmYWNlIEh0c2dldExvY2F0aW9uIHtcbiAgLyoqXG4gICAqIFRoZSBsb2NhdGlvbiBzdHJpbmcuXG4gICAqL1xuICBsb2NhdGlvbjogc3RyaW5nO1xuICAvKipcbiAgICogT3B0aW9uYWwgQ3J5cHQ0R0ggcHJpdmF0ZSBrZXkgc2VjcmV0IEFSTiBvciBuYW1lLlxuICAgKlxuICAgKiBAZGVmYXVsdFZhbHVlIHVuZGVmaW5lZFxuICAgKi9cbiAgcHJpdmF0ZV9rZXk/OiBzdHJpbmc7XG4gIC8qKlxuICAgKiBPcHRpb25hbCBDcnlwdDRHSCBwdWJsaWMga2V5IHNlY3JldCBBUk4gb3IgbmFtZS5cbiAgICpcbiAgICogQGRlZmF1bHRWYWx1ZSB1bmRlZmluZWRcbiAgICovXG4gIHB1YmxpY19rZXk/OiBzdHJpbmc7XG59XG4iXX0=
package/lib/config.ts ADDED
@@ -0,0 +1,270 @@
1
+ import { IVpc } from "aws-cdk-lib/aws-ec2";
2
+ import { CorsHttpMethod, IHttpApi } from "aws-cdk-lib/aws-apigatewayv2";
3
+ import { IRole } from "aws-cdk-lib/aws-iam";
4
+ import { Duration } from "aws-cdk-lib";
5
+ import { IHostedZone } from "aws-cdk-lib/aws-route53";
6
+
7
+ /**
8
+ * Settings related to the htsget lambda construct props.
9
+ */
10
+ export interface HtsgetLambdaProps {
11
+ /**
12
+ * The htsget-rs config options. Use this to specify any locations and htsget-rs options.
13
+ *
14
+ * @defaultValue undefined
15
+ */
16
+ htsgetConfig?: HtsgetConfig;
17
+
18
+ /**
19
+ * The domain name for the htsget server. This must be specified if `httpApi` is not set. This assumes
20
+ * that a `HostedZone` exists for this domain.
21
+ *
22
+ * @defaultValue undefined
23
+ */
24
+ domain?: string;
25
+
26
+ /**
27
+ * The domain name prefix to use for the htsget-rs server.
28
+ *
29
+ * @defaultValue "htsget"
30
+ */
31
+ subDomain?: string;
32
+
33
+ /**
34
+ * Whether this deployment is gated behind a JWT authorizer, or if its public.
35
+ *
36
+ * @defaultValue `undefined`, defaults to a public deployment
37
+ */
38
+ jwt?: JwtConfig;
39
+
40
+ /**
41
+ * CORS configuration for the htsget-rs server. Values here are propagated to CORS options in htsget-rs.
42
+ *
43
+ * @defaultValue same as the `CorsConfig` defaults
44
+ */
45
+ cors?: CorsConifg;
46
+
47
+ /**
48
+ * The git reference to fetch from the htsget-rs repo.
49
+ *
50
+ * @defaultValue "main"
51
+ */
52
+ gitReference?: string;
53
+
54
+ /**
55
+ * Whether to force a git clone for every build. If this is false, then the git repo is only cloned once
56
+ * for every git reference in a temporary directory. Otherwise, the repo is cloned every time.
57
+ *
58
+ * @defaultValue false
59
+ */
60
+ gitForceClone?: boolean;
61
+
62
+ /**
63
+ * Override any cargo lambda flags for the build. By default, features are resolved automatically based on the
64
+ * config and `HtsgetLocation[]`. This option overrides that and any automatically added flags.
65
+ *
66
+ * @defaultValue undefined
67
+ */
68
+ cargoLambdaFlags?: string[];
69
+
70
+ /**
71
+ * Copy the test data directory to a new bucket:
72
+ * https://github.com/umccr/htsget-rs/tree/main/data
73
+ *
74
+ * Also copies the Crypt4GH keys to Secrets Manager. Automatically the htsget-rs server access
75
+ * to the bucket and secrets using the locations config.
76
+ *
77
+ * @defaultValue false
78
+ */
79
+ copyTestData?: boolean;
80
+
81
+ /**
82
+ * The name of the bucket to create when using `copyTestData`. Defaults to the auto-generated CDK construct name.
83
+ *
84
+ * @defaultValue undefined
85
+ */
86
+ bucketName?: string;
87
+
88
+ /**
89
+ * The name of the Lambda function. Defaults to the auto-generated CDK construct name.
90
+ *
91
+ * @defaultValue undefined
92
+ */
93
+ functionName?: string;
94
+
95
+ /**
96
+ * Optionally specify a VPC for the Lambda function.
97
+ *
98
+ * @defaultValue undefined
99
+ */
100
+ vpc?: IVpc;
101
+
102
+ /**
103
+ * Manually specify an `HttpApi`. This will not create a `HostedZone`, any Route53 records, certificates,
104
+ * or authorizers, and will instead rely on the existing `HttpApi`.
105
+ *
106
+ * @defaultValue undefined
107
+ */
108
+ httpApi?: IHttpApi;
109
+
110
+ /**
111
+ * The arn of the certificate to use. This will not create a `Certificate` if specified, and will instead lookup
112
+ * an existing one.
113
+ *
114
+ * @defaultValue undefined
115
+ */
116
+ certificateArn?: string;
117
+
118
+ /**
119
+ * Use the provided hosted zone instead of looking it up from the domain name.
120
+ *
121
+ * @defaultValue undefined
122
+ */
123
+ hostedZone?: IHostedZone;
124
+
125
+ /**
126
+ * Use the provided role instead of creating one. This will ignore any configuration related to permissions for
127
+ * buckets and secrets, and rely on the existing role.
128
+ *
129
+ * @defaultValue undefined
130
+ */
131
+ role?: IRole;
132
+
133
+ /**
134
+ * The name of the role for the Lambda function. Defaults to the auto-generated CDK construct name.
135
+ *
136
+ * @defaultValue undefined
137
+ */
138
+ roleName?: string;
139
+
140
+ /**
141
+ * Override the environment variables used to build htsget. Note that this only adds environment variables that
142
+ * get used to build htsget-rs with `cargo`. It has no effect on the environment variables that htsget-rs has when
143
+ * the Lambda function is deployed. In general, leave this undefined unless there is a specific reason to override
144
+ * the build environment.
145
+ *
146
+ * @defaultValue undefined
147
+ */
148
+ buildEnvironment?: Record<string, string>;
149
+ }
150
+
151
+ /**
152
+ * JWT authorization settings.
153
+ */
154
+ export interface JwtConfig {
155
+ /**
156
+ * The JWT audience.
157
+ *
158
+ * @defaultValue []
159
+ */
160
+ audience?: string[];
161
+
162
+ /**
163
+ * The cognito user pool id for the authorizer. If this is not set, then a new user pool is created.
164
+ *
165
+ * @defaultValue `undefined`, creates a new user pool
166
+ */
167
+ cogUserPoolId?: string;
168
+ }
169
+
170
+ /**
171
+ * CORS configuration for the htsget-rs server.
172
+ */
173
+ export interface CorsConifg {
174
+ /**
175
+ * CORS allow credentials.
176
+ *
177
+ * @defaultValue false
178
+ */
179
+ allowCredentials?: boolean;
180
+
181
+ /**
182
+ * CORS allow headers.
183
+ *
184
+ * @defaultValue ["*"]
185
+ */
186
+ allowHeaders?: string[];
187
+
188
+ /**
189
+ * CORS allow methods.
190
+ *
191
+ * @defaultValue [CorsHttpMethod.ANY]
192
+ */
193
+ allowMethods?: CorsHttpMethod[];
194
+
195
+ /**
196
+ * CORS allow origins.
197
+ *
198
+ * @defaultValue ["*"]
199
+ */
200
+ allowOrigins?: string[];
201
+
202
+ /**
203
+ * CORS expose headers.
204
+ *
205
+ * @defaultValue ["*"]
206
+ */
207
+ exposeHeaders?: string[];
208
+
209
+ /**
210
+ * CORS max age.
211
+ *
212
+ * @defaultValue Duration.days(30)
213
+ */
214
+ maxAge?: Duration;
215
+ }
216
+
217
+ /**
218
+ * Configuration for the htsget-rs server. This allows specifying the options
219
+ * available in the htsget-rs config: https://github.com/umccr/htsget-rs/tree/main/htsget-config
220
+ */
221
+ export interface HtsgetConfig {
222
+ /**
223
+ * The locations for the htsget-rs server. This is the same as the htsget-rs config locations:
224
+ * https://github.com/umccr/htsget-rs/tree/main/htsget-config#quickstart
225
+ *
226
+ * Any `s3://...` locations will automatically be added to the bucket access policy.
227
+ *
228
+ * @defaultValue []
229
+ */
230
+ locations?: HtsgetLocation[];
231
+
232
+ /**
233
+ * Service info fields to configure for the server. This is the same as the htsget-rs config service_info:
234
+ * https://github.com/umccr/htsget-rs/tree/main/htsget-config#service-info-config
235
+ *
236
+ * @defaultValue undefined
237
+ */
238
+ service_info?: Record<string, unknown>;
239
+
240
+ /**
241
+ * Any additional htsget-rs options can be specified here as environment variables. These will override
242
+ * any options set in this construct, and allows using advanced configuration. Options here should contain
243
+ * the `HTSGET_` prefix.
244
+ *
245
+ * @defaultValue undefined
246
+ */
247
+ environment_override?: Record<string, unknown>;
248
+ }
249
+
250
+ /**
251
+ * Config for locations.
252
+ */
253
+ export interface HtsgetLocation {
254
+ /**
255
+ * The location string.
256
+ */
257
+ location: string;
258
+ /**
259
+ * Optional Crypt4GH private key secret ARN or name.
260
+ *
261
+ * @defaultValue undefined
262
+ */
263
+ private_key?: string;
264
+ /**
265
+ * Optional Crypt4GH public key secret ARN or name.
266
+ *
267
+ * @defaultValue undefined
268
+ */
269
+ public_key?: string;
270
+ }
@@ -0,0 +1,36 @@
1
+ import { Construct } from "constructs";
2
+ import { Role } from "aws-cdk-lib/aws-iam";
3
+ import { Bucket } from "aws-cdk-lib/aws-s3";
4
+ import { Secret } from "aws-cdk-lib/aws-secretsmanager";
5
+ import { CorsConifg, HtsgetConfig, HtsgetLambdaProps } from "./config";
6
+ /**
7
+ * @ignore
8
+ * Construct used to deploy htsget-lambda.
9
+ */
10
+ export declare class HtsgetLambda extends Construct {
11
+ constructor(scope: Construct, id: string, props: HtsgetLambdaProps);
12
+ /**
13
+ * Determine the correct features based on the locations.
14
+ */
15
+ static resolveFeatures(config: HtsgetConfig, bucketSetup: boolean): string;
16
+ /**
17
+ * Create a bucket and copy test data if configured.
18
+ */
19
+ private setupTestData;
20
+ /**
21
+ * Set permissions for the Lambda role.
22
+ */
23
+ static setPermissions(role: Role, config: HtsgetConfig, bucket?: Bucket, privateKey?: Secret, publicKey?: Secret): void;
24
+ /**
25
+ * Creates a lambda role with the configured permissions.
26
+ */
27
+ static createRole(scope: Construct, id: string, roleName?: string): Role;
28
+ /**
29
+ * Create stateful config related to the httpApi and the API itself.
30
+ */
31
+ private createHttpApi;
32
+ /**
33
+ * Convert JSON config to htsget-rs env representation.
34
+ */
35
+ static configToEnv(config: HtsgetConfig, corsConfig?: CorsConifg, bucket?: Bucket, privateKey?: Secret, publicKey?: Secret): Record<string, string>;
36
+ }