11import React , { FC , useEffect , useMemo , useState } from 'react' ;
2- import { Input , Select , InlineField , ButtonGroup , ToolbarButton , FieldSet , Collapse } from '@grafana/ui' ;
2+ import { Input , Select , InlineField , ButtonGroup , ToolbarButton , FieldSet , Collapse , useStyles2 } from '@grafana/ui' ;
33import {
44 DataSourcePluginOptionsEditorProps ,
55 onUpdateDatasourceJsonDataOptionSelect ,
@@ -11,6 +11,7 @@ import { config } from '@grafana/runtime';
1111import { standardRegions } from './regions' ;
1212import { AwsAuthDataSourceJsonData , AwsAuthDataSourceSecureJsonData , AwsAuthType } from './types' ;
1313import { awsAuthProviderOptions } from './providers' ;
14+ import { css } from '@emotion/css' ;
1415
1516export const DEFAULT_LABEL_WIDTH = 28 ;
1617const DS_TYPES_THAT_SUPPORT_TEMP_CREDS = [ 'cloudwatch' ] ;
@@ -77,6 +78,7 @@ export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionCon
7778 } , [ loadRegions ] ) ;
7879
7980 const inputWidth = inExperimentalAuthComponent ? 'width-20' : 'width-30' ;
81+ const styles = useStyles2 ( getStyles ) ;
8082
8183 return (
8284 < FieldSet label = { skipHeader ? '' : 'Connection Details' } data-testid = "connection-config" >
@@ -160,58 +162,60 @@ export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionCon
160162 ) }
161163
162164 { options . jsonData . authType === AwsAuthType . GrafanaAssumeRole && (
163- < Collapse
164- label = { 'How to create an IAM role for grafana to assume:' }
165- collapsible = { true }
166- isOpen = { isARNInstructionsOpen }
167- onToggle = { ( ) => setIsARNInstructionsOpen ( ! isARNInstructionsOpen ) }
168- >
169- < ol >
170- < li >
171- < p >
172- 1. Create a new IAM role in the AWS console, and select < code > Another AWS account</ code > as the{ ' ' }
173- < code > Trusted entity</ code > .
174- </ p >
175- </ li >
176- < li >
177- < p >
178- 2. Enter the account ID of the Grafana account that has permission to assume this role:
179- < code > 008923505280 </ code > and check the < code > Require external ID</ code > box.
180- </ p >
181- </ li >
182- < li >
183- < p >
184- 3. Enter the following external ID:{ ' ' }
185- < code > { props . externalId || 'External Id is currently unavailable' } </ code > and click < code > Next</ code > .
186- </ p >
187- </ li >
188- < li >
189- < p >
190- 4. Add any required permissions you would like Grafana to be able to access on your behalf. For more
191- details on our permissions please{ ' ' }
192- < a
193- href = "https://grafana.com/docs/grafana/latest/datasources/aws-cloudwatch/"
194- target = "_blank"
195- rel = "noreferrer"
196- >
197- read through our documentation
198- </ a >
199- .
200- </ p >
201- </ li >
202- < li >
203- < p >
204- 5. Give the role a name and description, and click < code > Create role</ code > .
205- </ p >
206- </ li >
207- < li >
208- < p >
209- 6. Copy the ARN of the role you just created and paste it into the < code > Assume Role ARN</ code > field
210- below.
211- </ p >
212- </ li >
213- </ ol >
214- </ Collapse >
165+ < div className = { styles . assumeRoleInstructions } >
166+ < Collapse
167+ label = { 'How to create an IAM role for grafana to assume:' }
168+ collapsible = { true }
169+ isOpen = { isARNInstructionsOpen }
170+ onToggle = { ( ) => setIsARNInstructionsOpen ( ! isARNInstructionsOpen ) }
171+ >
172+ < ol >
173+ < li >
174+ < p >
175+ 1. Create a new IAM role in the AWS console, and select < code > Another AWS account</ code > as the{ ' ' }
176+ < code > Trusted entity</ code > .
177+ </ p >
178+ </ li >
179+ < li >
180+ < p >
181+ 2. Enter the account ID of the Grafana account that has permission to assume this role:
182+ < code > 008923505280 </ code > and check the < code > Require external ID</ code > box.
183+ </ p >
184+ </ li >
185+ < li >
186+ < p >
187+ 3. Enter the following external ID:{ ' ' }
188+ < code > { props . externalId || 'External Id is currently unavailable' } </ code > and click < code > Next</ code > .
189+ </ p >
190+ </ li >
191+ < li >
192+ < p >
193+ 4. Add any required permissions you would like Grafana to be able to access on your behalf. For more
194+ details on our permissions please{ ' ' }
195+ < a
196+ href = "https://grafana.com/docs/grafana/latest/datasources/aws-cloudwatch/"
197+ target = "_blank"
198+ rel = "noreferrer"
199+ >
200+ read through our documentation
201+ </ a >
202+ .
203+ </ p >
204+ </ li >
205+ < li >
206+ < p >
207+ 5. Give the role a name and description, and click < code > Create role</ code > .
208+ </ p >
209+ </ li >
210+ < li >
211+ < p >
212+ 6. Copy the ARN of the role you just created and paste it into the < code > Assume Role ARN</ code > field
213+ below.
214+ </ p >
215+ </ li >
216+ </ ol >
217+ </ Collapse >
218+ </ div >
215219 ) }
216220
217221 { awsAssumeRoleEnabled && (
@@ -282,3 +286,11 @@ export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionCon
282286 </ FieldSet >
283287 ) ;
284288} ;
289+
290+ function getStyles ( ) {
291+ return {
292+ assumeRoleInstructions : css ( {
293+ maxWidth : '715px' ,
294+ } ) ,
295+ } ;
296+ }
0 commit comments