@lightdash/warehouses 0.2548.0 → 0.2549.0
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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/warehouseClients/AthenaWarehouseClient.d.ts.map +1 -1
- package/dist/warehouseClients/AthenaWarehouseClient.js +12 -0
- package/dist/warehouseClients/AthenaWarehouseClient.test.d.ts +2 -0
- package/dist/warehouseClients/AthenaWarehouseClient.test.d.ts.map +1 -0
- package/dist/warehouseClients/AthenaWarehouseClient.test.js +106 -0
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AthenaWarehouseClient.d.ts","sourceRoot":"","sources":["../../src/warehouseClients/AthenaWarehouseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EAOf,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"AthenaWarehouseClient.d.ts","sourceRoot":"","sources":["../../src/warehouseClients/AthenaWarehouseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EAOf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAGH,uBAAuB,EAGvB,MAAM,EAEN,mBAAmB,EACnB,gBAAgB,EAGhB,gBAAgB,EAChB,cAAc,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAM5C,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAEhE,oBAAY,WAAW;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IAC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AgB,CAAC;IAwDtB,YAAY,IAAI,OAAO,CACzB;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CACxD;IAyCK,SAAS,CACX,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,gBAAgB,CAAC;IA2C5B,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;CAGlC"}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AthenaWarehouseClient = exports.AthenaSqlBuilder = exports.AthenaTypes = void 0;
|
|
7
7
|
const client_athena_1 = require("@aws-sdk/client-athena");
|
|
8
|
+
const credential_providers_1 = require("@aws-sdk/credential-providers");
|
|
8
9
|
const common_1 = require("@lightdash/common");
|
|
9
10
|
const processPromisesInBatches_1 = require("../utils/processPromisesInBatches");
|
|
10
11
|
const sql_1 = require("../utils/sql");
|
|
@@ -138,6 +139,17 @@ class AthenaWarehouseClient extends WarehouseBaseClient_1.default {
|
|
|
138
139
|
secretAccessKey: credentials.secretAccessKey,
|
|
139
140
|
};
|
|
140
141
|
}
|
|
142
|
+
// Wrap with assume role if configured
|
|
143
|
+
if (credentials.assumeRoleArn) {
|
|
144
|
+
clientConfig.credentials = (0, credential_providers_1.fromTemporaryCredentials)({
|
|
145
|
+
masterCredentials: clientConfig.credentials,
|
|
146
|
+
params: {
|
|
147
|
+
RoleArn: credentials.assumeRoleArn,
|
|
148
|
+
RoleSessionName: 'lightdash-athena-session',
|
|
149
|
+
ExternalId: credentials.assumeRoleExternalId || undefined,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
141
153
|
this.client = new client_athena_1.AthenaClient(clientConfig);
|
|
142
154
|
}
|
|
143
155
|
catch (e) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AthenaWarehouseClient.test.d.ts","sourceRoot":"","sources":["../../src/warehouseClients/AthenaWarehouseClient.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const common_1 = require("@lightdash/common");
|
|
4
|
+
const mockAthenaClient = jest.fn();
|
|
5
|
+
jest.mock('@aws-sdk/client-athena', () => ({
|
|
6
|
+
...jest.requireActual('@aws-sdk/client-athena'),
|
|
7
|
+
AthenaClient: mockAthenaClient,
|
|
8
|
+
}));
|
|
9
|
+
const mockFromTemporaryCredentials = jest.fn(() => 'sts-credentials');
|
|
10
|
+
jest.mock('@aws-sdk/credential-providers', () => ({
|
|
11
|
+
fromTemporaryCredentials: mockFromTemporaryCredentials,
|
|
12
|
+
}));
|
|
13
|
+
// eslint-disable-next-line import/first -- Must import after mocks are set up
|
|
14
|
+
const AthenaWarehouseClient_1 = require("./AthenaWarehouseClient");
|
|
15
|
+
const baseCredentials = {
|
|
16
|
+
type: common_1.WarehouseTypes.ATHENA,
|
|
17
|
+
region: 'us-east-1',
|
|
18
|
+
database: 'AwsDataCatalog',
|
|
19
|
+
schema: 'my_database',
|
|
20
|
+
s3StagingDir: 's3://bucket/staging/',
|
|
21
|
+
authenticationType: common_1.AthenaAuthenticationType.ACCESS_KEY,
|
|
22
|
+
accessKeyId: 'AKID',
|
|
23
|
+
secretAccessKey: 'SECRET',
|
|
24
|
+
};
|
|
25
|
+
describe('AthenaWarehouseClient', () => {
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
jest.clearAllMocks();
|
|
28
|
+
mockAthenaClient.mockImplementation(() => ({}));
|
|
29
|
+
});
|
|
30
|
+
describe('authentication', () => {
|
|
31
|
+
test('should use static credentials for ACCESS_KEY auth', () => {
|
|
32
|
+
// eslint-disable-next-line no-new
|
|
33
|
+
new AthenaWarehouseClient_1.AthenaWarehouseClient(baseCredentials);
|
|
34
|
+
expect(mockAthenaClient).toHaveBeenCalledWith({
|
|
35
|
+
region: 'us-east-1',
|
|
36
|
+
credentials: {
|
|
37
|
+
accessKeyId: 'AKID',
|
|
38
|
+
secretAccessKey: 'SECRET',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
test('should not set credentials for IAM_ROLE auth', () => {
|
|
43
|
+
const creds = {
|
|
44
|
+
...baseCredentials,
|
|
45
|
+
authenticationType: common_1.AthenaAuthenticationType.IAM_ROLE,
|
|
46
|
+
};
|
|
47
|
+
// eslint-disable-next-line no-new
|
|
48
|
+
new AthenaWarehouseClient_1.AthenaWarehouseClient(creds);
|
|
49
|
+
expect(mockAthenaClient).toHaveBeenCalledWith({
|
|
50
|
+
region: 'us-east-1',
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
describe('assume role', () => {
|
|
55
|
+
test('should wrap credentials with fromTemporaryCredentials when assumeRoleArn is set', () => {
|
|
56
|
+
const creds = {
|
|
57
|
+
...baseCredentials,
|
|
58
|
+
assumeRoleArn: 'arn:aws:iam::123456789012:role/my-role',
|
|
59
|
+
assumeRoleExternalId: 'ext-id',
|
|
60
|
+
};
|
|
61
|
+
// eslint-disable-next-line no-new
|
|
62
|
+
new AthenaWarehouseClient_1.AthenaWarehouseClient(creds);
|
|
63
|
+
expect(mockFromTemporaryCredentials).toHaveBeenCalledWith({
|
|
64
|
+
masterCredentials: {
|
|
65
|
+
accessKeyId: 'AKID',
|
|
66
|
+
secretAccessKey: 'SECRET',
|
|
67
|
+
},
|
|
68
|
+
params: {
|
|
69
|
+
RoleArn: 'arn:aws:iam::123456789012:role/my-role',
|
|
70
|
+
RoleSessionName: 'lightdash-athena-session',
|
|
71
|
+
ExternalId: 'ext-id',
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
expect(mockAthenaClient).toHaveBeenCalledWith({
|
|
75
|
+
region: 'us-east-1',
|
|
76
|
+
credentials: 'sts-credentials',
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
test('should not wrap credentials when assumeRoleArn is not set', () => {
|
|
80
|
+
// eslint-disable-next-line no-new
|
|
81
|
+
new AthenaWarehouseClient_1.AthenaWarehouseClient(baseCredentials);
|
|
82
|
+
expect(mockFromTemporaryCredentials).not.toHaveBeenCalled();
|
|
83
|
+
});
|
|
84
|
+
test('should work with IAM_ROLE and assume role together', () => {
|
|
85
|
+
const creds = {
|
|
86
|
+
...baseCredentials,
|
|
87
|
+
authenticationType: common_1.AthenaAuthenticationType.IAM_ROLE,
|
|
88
|
+
assumeRoleArn: 'arn:aws:iam::123456789012:role/my-role',
|
|
89
|
+
};
|
|
90
|
+
// eslint-disable-next-line no-new
|
|
91
|
+
new AthenaWarehouseClient_1.AthenaWarehouseClient(creds);
|
|
92
|
+
expect(mockFromTemporaryCredentials).toHaveBeenCalledWith({
|
|
93
|
+
masterCredentials: undefined,
|
|
94
|
+
params: {
|
|
95
|
+
RoleArn: 'arn:aws:iam::123456789012:role/my-role',
|
|
96
|
+
RoleSessionName: 'lightdash-athena-session',
|
|
97
|
+
ExternalId: undefined,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
expect(mockAthenaClient).toHaveBeenCalledWith({
|
|
101
|
+
region: 'us-east-1',
|
|
102
|
+
credentials: 'sts-credentials',
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash/warehouses",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2549.0",
|
|
4
4
|
"description": "Warehouse connectors for Lightdash",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"types": "dist/index.d.ts",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@aws-sdk/client-athena": "^3.972.0",
|
|
17
|
+
"@aws-sdk/credential-providers": "^3.972.0",
|
|
17
18
|
"@clickhouse/client": "^1.12.1",
|
|
18
19
|
"@databricks/sql": "1.8.4",
|
|
19
20
|
"@duckdb/node-api": "^1.4.4-r.1",
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
"snowflake-sdk": "~2.3.4",
|
|
26
27
|
"ssh2": "^1.14.0",
|
|
27
28
|
"trino-client": "0.2.9",
|
|
28
|
-
"@lightdash/common": "0.
|
|
29
|
+
"@lightdash/common": "0.2549.0"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@types/node-fetch": "^2.6.13",
|