@grafana/aws-sdk 0.8.2 → 0.9.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/esm/components/ConnectionConfig.js +137 -44
- package/dist/esm/components/ConnectionConfig.js.map +1 -1
- package/dist/esm/regions.js +6 -0
- package/dist/esm/regions.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +142 -43
- package/dist/index.js.map +1 -1
- package/package.json +27 -27
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ const standardRegions = [
|
|
|
29
29
|
"ap-southeast-3",
|
|
30
30
|
"ap-southeast-4",
|
|
31
31
|
"ap-southeast-5",
|
|
32
|
+
"ap-southeast-6",
|
|
32
33
|
"ap-southeast-7",
|
|
33
34
|
"ca-central-1",
|
|
34
35
|
"ca-west-1",
|
|
@@ -36,6 +37,7 @@ const standardRegions = [
|
|
|
36
37
|
"cn-northwest-1",
|
|
37
38
|
"eu-central-1",
|
|
38
39
|
"eu-central-2",
|
|
40
|
+
"eu-isoe-west-1",
|
|
39
41
|
"eu-north-1",
|
|
40
42
|
"eu-south-1",
|
|
41
43
|
"eu-south-2",
|
|
@@ -52,7 +54,11 @@ const standardRegions = [
|
|
|
52
54
|
"us-gov-east-1",
|
|
53
55
|
"us-gov-west-1",
|
|
54
56
|
"us-iso-east-1",
|
|
57
|
+
"us-iso-west-1",
|
|
55
58
|
"us-isob-east-1",
|
|
59
|
+
"us-isob-west-1",
|
|
60
|
+
"us-isof-east-1",
|
|
61
|
+
"us-northeast-1",
|
|
56
62
|
"us-west-1",
|
|
57
63
|
"us-west-2"
|
|
58
64
|
];
|
|
@@ -100,12 +106,13 @@ const DS_TYPES_THAT_SUPPORT_TEMP_CREDS = [
|
|
|
100
106
|
"grafana-athena-datasource",
|
|
101
107
|
"grafana-amazonprometheus-datasource"
|
|
102
108
|
];
|
|
109
|
+
const RFC_2396_WARNING = 'This functionality should only be used with legacy web sites. RFC 2396 warns that interpreting Userinfo this way "is NOT RECOMMENDED, because the passing of authentication information in clear text (such as URI) has proven to be a security risk in almost every case where it has been used."';
|
|
103
110
|
const toOption = (value) => ({ value, label: value });
|
|
104
111
|
const isAwsAuthType = (value) => {
|
|
105
112
|
return typeof value === "string" && awsAuthProviderOptions.some((opt) => opt.value === value);
|
|
106
113
|
};
|
|
107
114
|
const ConnectionConfig = (props) => {
|
|
108
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
115
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
109
116
|
const [isARNInstructionsOpen, setIsARNInstructionsOpen] = React.useState(false);
|
|
110
117
|
const [regions, setRegions] = React.useState((props.standardRegions || standardRegions).map(toOption));
|
|
111
118
|
const {
|
|
@@ -114,31 +121,40 @@ const ConnectionConfig = (props) => {
|
|
|
114
121
|
skipHeader = false,
|
|
115
122
|
skipEndpoint = false,
|
|
116
123
|
options,
|
|
117
|
-
hideAssumeRoleArn = false
|
|
124
|
+
hideAssumeRoleArn = false,
|
|
125
|
+
showHttpProxySettings = false
|
|
118
126
|
} = props;
|
|
119
127
|
let profile = options.jsonData.profile;
|
|
120
128
|
if (profile === void 0) {
|
|
121
129
|
profile = options.database;
|
|
122
130
|
}
|
|
123
131
|
const tempCredsFeatureEnabled = runtime.config.featureToggles.awsDatasourcesTempCredentials && DS_TYPES_THAT_SUPPORT_TEMP_CREDS.includes(options.type);
|
|
124
|
-
const
|
|
132
|
+
const httpProxySettingEnabled = showHttpProxySettings && ((_a = runtime.config.awsPerDatasourceHTTPProxyEnabled) != null ? _a : false);
|
|
133
|
+
const awsAssumeRoleEnabled = (_b = runtime.config.awsAssumeRoleEnabled) != null ? _b : true;
|
|
125
134
|
const awsAllowedAuthProviders = React.useMemo(
|
|
126
135
|
() => runtime.config.awsAllowedAuthProviders.filter((provider) => provider === AwsAuthType.GrafanaAssumeRole ? tempCredsFeatureEnabled : true).filter(isAwsAuthType),
|
|
127
136
|
[tempCredsFeatureEnabled]
|
|
128
137
|
);
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
|
|
138
|
+
const externalId = React.useMemo(() => {
|
|
139
|
+
if (tempCredsFeatureEnabled && options.jsonData.authType === AwsAuthType.GrafanaAssumeRole) {
|
|
140
|
+
if (runtime.config.namespace.startsWith("stacks-")) {
|
|
141
|
+
return runtime.config.namespace.substring(runtime.config.namespace.indexOf("-") + 1);
|
|
142
|
+
}
|
|
132
143
|
}
|
|
133
|
-
|
|
144
|
+
return props.externalId;
|
|
145
|
+
}, [tempCredsFeatureEnabled, options.jsonData.authType, props.externalId]);
|
|
134
146
|
const currentProvider = awsAuthProviderOptions.find((p) => p.value === options.jsonData.authType);
|
|
135
147
|
React.useEffect(() => {
|
|
136
148
|
if (!currentProvider && awsAllowedAuthProviders.length) {
|
|
149
|
+
let defaultAuthType = awsAllowedAuthProviders[0];
|
|
150
|
+
if (awsAllowedAuthProviders.includes(AwsAuthType.GrafanaAssumeRole)) {
|
|
151
|
+
defaultAuthType = AwsAuthType.GrafanaAssumeRole;
|
|
152
|
+
}
|
|
137
153
|
onOptionsChange({
|
|
138
154
|
...options,
|
|
139
155
|
jsonData: {
|
|
140
156
|
...options.jsonData,
|
|
141
|
-
authType:
|
|
157
|
+
authType: defaultAuthType
|
|
142
158
|
}
|
|
143
159
|
});
|
|
144
160
|
}
|
|
@@ -186,7 +202,7 @@ const ConnectionConfig = (props) => {
|
|
|
186
202
|
onChange: data.onUpdateDatasourceJsonDataOption(props, "profile")
|
|
187
203
|
}
|
|
188
204
|
)
|
|
189
|
-
), options.jsonData.authType === "keys" && /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(ui.Field, { label: "Access Key ID", htmlFor: "accessKeyId" }, ((
|
|
205
|
+
), options.jsonData.authType === "keys" && /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(ui.Field, { label: "Access Key ID", htmlFor: "accessKeyId" }, ((_c = props.options.secureJsonFields) == null ? void 0 : _c.accessKey) ? /* @__PURE__ */ React__default.default.createElement(ui.ButtonGroup, null, /* @__PURE__ */ React__default.default.createElement(ui.Input, { disabled: true, placeholder: "Configured", id: "accessKeyId" }), /* @__PURE__ */ React__default.default.createElement(
|
|
190
206
|
ui.ToolbarButton,
|
|
191
207
|
{
|
|
192
208
|
icon: "edit",
|
|
@@ -198,10 +214,10 @@ const ConnectionConfig = (props) => {
|
|
|
198
214
|
ui.Input,
|
|
199
215
|
{
|
|
200
216
|
id: "accessKeyId",
|
|
201
|
-
value: (
|
|
217
|
+
value: (_e = (_d = options.secureJsonData) == null ? void 0 : _d.accessKey) != null ? _e : "",
|
|
202
218
|
onChange: data.onUpdateDatasourceSecureJsonDataOption(props, "accessKey")
|
|
203
219
|
}
|
|
204
|
-
)), /* @__PURE__ */ React__default.default.createElement(ui.Field, { label: "Secret Access Key", htmlFor: "secretKey" }, ((
|
|
220
|
+
)), /* @__PURE__ */ React__default.default.createElement(ui.Field, { label: "Secret Access Key", htmlFor: "secretKey" }, ((_f = props.options.secureJsonFields) == null ? void 0 : _f.secretKey) ? /* @__PURE__ */ React__default.default.createElement(ui.ButtonGroup, null, /* @__PURE__ */ React__default.default.createElement(ui.Input, { disabled: true, placeholder: "Configured" }), /* @__PURE__ */ React__default.default.createElement(
|
|
205
221
|
ui.ToolbarButton,
|
|
206
222
|
{
|
|
207
223
|
id: "secretKey",
|
|
@@ -214,56 +230,139 @@ const ConnectionConfig = (props) => {
|
|
|
214
230
|
ui.Input,
|
|
215
231
|
{
|
|
216
232
|
id: "secretKey",
|
|
217
|
-
value: (
|
|
233
|
+
value: (_h = (_g = options.secureJsonData) == null ? void 0 : _g.secretKey) != null ? _h : "",
|
|
218
234
|
onChange: data.onUpdateDatasourceSecureJsonDataOption(props, "secretKey")
|
|
219
235
|
}
|
|
220
|
-
)))), !hideAssumeRoleArn && /* @__PURE__ */ React__default.default.createElement(
|
|
221
|
-
|
|
236
|
+
)))), !hideAssumeRoleArn && /* @__PURE__ */ React__default.default.createElement(
|
|
237
|
+
pluginUi.ConfigSubSection,
|
|
222
238
|
{
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
239
|
+
title: "Assume Role",
|
|
240
|
+
description: options.jsonData.authType === AwsAuthType.GrafanaAssumeRole ? /* @__PURE__ */ React__default.default.createElement(ui.Text, null, "Learn more about", " ", /* @__PURE__ */ React__default.default.createElement(
|
|
241
|
+
ui.TextLink,
|
|
242
|
+
{
|
|
243
|
+
inline: true,
|
|
244
|
+
external: true,
|
|
245
|
+
variant: "bodySmall",
|
|
246
|
+
href: "https://grafana.com/docs/plugins/cloudwatch/latest/aws-authentication/#use-grafana-assume-role"
|
|
247
|
+
},
|
|
248
|
+
"Grafana Assume Role"
|
|
249
|
+
), ".") : null
|
|
227
250
|
},
|
|
228
|
-
|
|
229
|
-
|
|
251
|
+
options.jsonData.authType === AwsAuthType.GrafanaAssumeRole && /* @__PURE__ */ React__default.default.createElement("div", { className: assumeRoleInstructionsStyle }, /* @__PURE__ */ React__default.default.createElement(
|
|
252
|
+
ui.Collapse,
|
|
230
253
|
{
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
254
|
+
label: "How to create an IAM role for grafana to assume:",
|
|
255
|
+
collapsible: true,
|
|
256
|
+
isOpen: isARNInstructionsOpen,
|
|
257
|
+
onToggle: () => setIsARNInstructionsOpen(!isARNInstructionsOpen)
|
|
234
258
|
},
|
|
235
|
-
"
|
|
236
|
-
|
|
237
|
-
|
|
259
|
+
/* @__PURE__ */ React__default.default.createElement("ol", null, /* @__PURE__ */ React__default.default.createElement("li", null, /* @__PURE__ */ React__default.default.createElement("p", null, "1. Create a new IAM role in the AWS console, and select ", /* @__PURE__ */ React__default.default.createElement("code", null, "Another AWS account"), " as the", " ", /* @__PURE__ */ React__default.default.createElement("code", null, "Trusted entity"), ".")), /* @__PURE__ */ React__default.default.createElement("li", null, /* @__PURE__ */ React__default.default.createElement("p", null, "2. Enter the account ID of the Grafana account that has permission to assume this role:", /* @__PURE__ */ React__default.default.createElement("code", null, " 008923505280 "), " and check the ", /* @__PURE__ */ React__default.default.createElement("code", null, "Require external ID"), " box.")), /* @__PURE__ */ React__default.default.createElement("li", null, /* @__PURE__ */ React__default.default.createElement("p", null, "3. Enter the following external ID:", " ", /* @__PURE__ */ React__default.default.createElement("code", null, externalId || "External Id is currently unavailable"), " and click ", /* @__PURE__ */ React__default.default.createElement("code", null, "Next"), ".")), /* @__PURE__ */ React__default.default.createElement("li", null, /* @__PURE__ */ React__default.default.createElement("p", null, "4. Add any required permissions you would like Grafana to be able to access on your behalf. For more details on our permissions please", " ", /* @__PURE__ */ React__default.default.createElement(
|
|
260
|
+
"a",
|
|
261
|
+
{
|
|
262
|
+
href: "https://grafana.com/docs/grafana/latest/datasources/aws-cloudwatch/",
|
|
263
|
+
target: "_blank",
|
|
264
|
+
rel: "noreferrer"
|
|
265
|
+
},
|
|
266
|
+
"read through our documentation"
|
|
267
|
+
), ".")), /* @__PURE__ */ React__default.default.createElement("li", null, /* @__PURE__ */ React__default.default.createElement("p", null, "5. Give the role a name and description, and click ", /* @__PURE__ */ React__default.default.createElement("code", null, "Create role"), ".")), /* @__PURE__ */ React__default.default.createElement("li", null, /* @__PURE__ */ React__default.default.createElement("p", null, "6. Copy the ARN of the role you just created and paste it into the ", /* @__PURE__ */ React__default.default.createElement("code", null, "Assume Role ARN"), " ", "field below.")))
|
|
268
|
+
)),
|
|
269
|
+
awsAssumeRoleEnabled && /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(
|
|
270
|
+
ui.Field,
|
|
271
|
+
{
|
|
272
|
+
htmlFor: "assumeRoleArn",
|
|
273
|
+
label: "Assume Role ARN",
|
|
274
|
+
description: "Optional. Specifying the ARN of a role will ensure that the\n selected authentication provider is used to assume the role rather than the\n credentials directly."
|
|
275
|
+
},
|
|
276
|
+
/* @__PURE__ */ React__default.default.createElement(
|
|
277
|
+
ui.Input,
|
|
278
|
+
{
|
|
279
|
+
id: "assumeRoleArn",
|
|
280
|
+
placeholder: "arn:aws:iam:*",
|
|
281
|
+
value: options.jsonData.assumeRoleArn || "",
|
|
282
|
+
onChange: data.onUpdateDatasourceJsonDataOption(props, "assumeRoleArn")
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
), options.jsonData.authType !== AwsAuthType.GrafanaAssumeRole && /* @__PURE__ */ React__default.default.createElement(
|
|
286
|
+
ui.Field,
|
|
287
|
+
{
|
|
288
|
+
htmlFor: "externalId",
|
|
289
|
+
label: "External ID",
|
|
290
|
+
description: "If you are assuming a role in another account, that has been created with an external ID, specify the external ID here."
|
|
291
|
+
},
|
|
292
|
+
/* @__PURE__ */ React__default.default.createElement(
|
|
293
|
+
ui.Input,
|
|
294
|
+
{
|
|
295
|
+
id: "externalId",
|
|
296
|
+
placeholder: "External ID",
|
|
297
|
+
value: options.jsonData.externalId || "",
|
|
298
|
+
onChange: data.onUpdateDatasourceJsonDataOption(props, "externalId")
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
))
|
|
302
|
+
), httpProxySettingEnabled && /* @__PURE__ */ React__default.default.createElement(pluginUi.ConfigSubSection, { title: "Proxy Configuration" }, /* @__PURE__ */ React__default.default.createElement(
|
|
238
303
|
ui.Field,
|
|
239
304
|
{
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
305
|
+
label: "Proxy Type",
|
|
306
|
+
description: "Specify the type of proxy to use. This should not be set if Secure Socks Proxy is enabled.",
|
|
307
|
+
htmlFor: "proxyType"
|
|
308
|
+
},
|
|
309
|
+
/* @__PURE__ */ React__default.default.createElement(
|
|
310
|
+
ui.Select,
|
|
311
|
+
{
|
|
312
|
+
inputId: "proxyType",
|
|
313
|
+
value: options.jsonData.proxyType || "env",
|
|
314
|
+
options: [
|
|
315
|
+
{ label: "Environment (default)", value: "env" },
|
|
316
|
+
{ label: "None", value: "none" },
|
|
317
|
+
{ label: "URL", value: "url" }
|
|
318
|
+
],
|
|
319
|
+
onChange: data.onUpdateDatasourceJsonDataOptionSelect(props, "proxyType")
|
|
320
|
+
}
|
|
321
|
+
)
|
|
322
|
+
), (options.jsonData.proxyType === "env" || !options.jsonData.proxyType) && /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(ui.Text, { variant: "bodySmall", color: "secondary" }, "Proxy settings from environment variables will be used. Use ", /* @__PURE__ */ React__default.default.createElement("code", null, "HTTP_PROXY"), " &", " ", /* @__PURE__ */ React__default.default.createElement("code", null, "HTTPS_PROXY"), " environment variables. This will be skipped if no environment variables found."), /* @__PURE__ */ React__default.default.createElement(ui.Space, { v: 2 })), options.jsonData.proxyType === "url" && /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(
|
|
323
|
+
ui.Field,
|
|
324
|
+
{
|
|
325
|
+
label: "Proxy URL",
|
|
326
|
+
description: "Proxy URL. Don't set the username or password here",
|
|
327
|
+
htmlFor: "proxyUrl"
|
|
328
|
+
},
|
|
329
|
+
/* @__PURE__ */ React__default.default.createElement(
|
|
330
|
+
ui.Input,
|
|
331
|
+
{
|
|
332
|
+
id: "proxyUrl",
|
|
333
|
+
placeholder: "Example: https://localhost:3004",
|
|
334
|
+
value: options.jsonData.proxyUrl || "",
|
|
335
|
+
onChange: data.onUpdateDatasourceJsonDataOption(props, "proxyUrl")
|
|
336
|
+
}
|
|
337
|
+
)
|
|
338
|
+
), /* @__PURE__ */ React__default.default.createElement(
|
|
339
|
+
ui.Field,
|
|
340
|
+
{
|
|
341
|
+
label: "Proxy Username",
|
|
342
|
+
description: `Optional: Proxy Username. ${RFC_2396_WARNING}`,
|
|
343
|
+
htmlFor: "proxyUsername"
|
|
243
344
|
},
|
|
244
345
|
/* @__PURE__ */ React__default.default.createElement(
|
|
245
346
|
ui.Input,
|
|
246
347
|
{
|
|
247
|
-
id: "
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
onChange: data.onUpdateDatasourceJsonDataOption(props, "assumeRoleArn")
|
|
348
|
+
id: "proxyUsername",
|
|
349
|
+
value: options.jsonData.proxyUsername || "",
|
|
350
|
+
onChange: data.onUpdateDatasourceJsonDataOption(props, "proxyUsername")
|
|
251
351
|
}
|
|
252
352
|
)
|
|
253
|
-
),
|
|
353
|
+
), /* @__PURE__ */ React__default.default.createElement(
|
|
254
354
|
ui.Field,
|
|
255
355
|
{
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
356
|
+
label: "Proxy Password",
|
|
357
|
+
description: `Optional: Proxy Password. ${RFC_2396_WARNING}`,
|
|
358
|
+
htmlFor: "proxyPassword"
|
|
259
359
|
},
|
|
260
360
|
/* @__PURE__ */ React__default.default.createElement(
|
|
261
361
|
ui.Input,
|
|
262
362
|
{
|
|
263
|
-
id: "
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
onChange: data.onUpdateDatasourceJsonDataOption(props, "externalId")
|
|
363
|
+
id: "proxyPassword",
|
|
364
|
+
value: (_j = (_i = options.secureJsonData) == null ? void 0 : _i.proxyPassword) != null ? _j : "",
|
|
365
|
+
onChange: data.onUpdateDatasourceSecureJsonDataOption(props, "proxyPassword")
|
|
267
366
|
}
|
|
268
367
|
)
|
|
269
368
|
))), /* @__PURE__ */ React__default.default.createElement(pluginUi.ConfigSubSection, { title: "Additional Settings" }, !skipEndpoint && options.jsonData.authType !== AwsAuthType.GrafanaAssumeRole && /* @__PURE__ */ React__default.default.createElement(
|
|
@@ -277,7 +376,7 @@ const ConnectionConfig = (props) => {
|
|
|
277
376
|
ui.Input,
|
|
278
377
|
{
|
|
279
378
|
id: "endpoint",
|
|
280
|
-
placeholder: (
|
|
379
|
+
placeholder: (_k = props.defaultEndpoint) != null ? _k : "https://{service}.{region}.amazonaws.com",
|
|
281
380
|
value: options.jsonData.endpoint || "",
|
|
282
381
|
onChange: data.onUpdateDatasourceJsonDataOption(props, "endpoint")
|
|
283
382
|
}
|
|
@@ -293,7 +392,7 @@ const ConnectionConfig = (props) => {
|
|
|
293
392
|
ui.Select,
|
|
294
393
|
{
|
|
295
394
|
inputId: "defaultRegion",
|
|
296
|
-
value: (
|
|
395
|
+
value: (_l = regions.find((region) => region.value === options.jsonData.defaultRegion)) != null ? _l : options.jsonData.defaultRegion ? {
|
|
297
396
|
label: options.jsonData.defaultRegion,
|
|
298
397
|
value: options.jsonData.defaultRegion
|
|
299
398
|
} : void 0,
|