mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Cloudwatch: Upgrade aws-sdk and display external ids for temporary credentials (#72821)
(under a feature toggle, not yet ready for public testing)
This commit is contained in:
@@ -36,6 +36,10 @@ jest.mock('@grafana/runtime', () => ({
|
||||
get: getMock,
|
||||
}),
|
||||
getAppEvents: () => mockAppEvents,
|
||||
config: {
|
||||
...jest.requireActual('@grafana/runtime').config,
|
||||
awsAssumeRoleEnabled: true,
|
||||
},
|
||||
}));
|
||||
|
||||
const props: Props = {
|
||||
|
||||
@@ -57,6 +57,15 @@ export const ConfigEditor = (props: Props) => {
|
||||
failSubscription.unsubscribe();
|
||||
};
|
||||
}, [options.jsonData.authType, report]);
|
||||
const [externalId, setExternalId] = useState('');
|
||||
useEffect(() => {
|
||||
if (!externalId && datasource) {
|
||||
datasource.resources
|
||||
.getExternalId()
|
||||
.then(setExternalId)
|
||||
.catch(() => setExternalId('Unable to fetch externalId'));
|
||||
}
|
||||
}, [datasource, externalId]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -76,6 +85,7 @@ export const ConfigEditor = (props: Props) => {
|
||||
);
|
||||
})
|
||||
}
|
||||
externalId={externalId}
|
||||
>
|
||||
<InlineField label="Namespaces of Custom Metrics" labelWidth={29} tooltip="Namespaces of Custom Metrics.">
|
||||
<Input
|
||||
|
||||
@@ -35,6 +35,10 @@ export class ResourcesAPI extends CloudWatchRequest {
|
||||
return getBackendSrv().get(`/api/datasources/${this.instanceSettings.id}/resources/${subtype}`, parameters);
|
||||
}
|
||||
|
||||
async getExternalId(): Promise<string> {
|
||||
return await this.memoizedGetRequest<{ externalId: string }>('external-id').then(({ externalId }) => externalId);
|
||||
}
|
||||
|
||||
getAccounts({ region }: ResourceRequest): Promise<Account[]> {
|
||||
return this.memoizedGetRequest<Array<ResourceResponse<Account>>>('accounts', {
|
||||
region: this.templateSrv.replace(this.getActualRegion(region)),
|
||||
|
||||
Reference in New Issue
Block a user