@@ -23,7 +23,14 @@ const isAwsAuthType = (value: any): value is AwsAuthType => {
23
23
export const ConnectionConfig : FC < ConnectionConfigProps > = ( props : ConnectionConfigProps ) => {
24
24
const [ isARNInstructionsOpen , setIsARNInstructionsOpen ] = useState ( false ) ;
25
25
const [ regions , setRegions ] = useState ( ( props . standardRegions || standardRegions ) . map ( toOption ) ) ;
26
- const { loadRegions, onOptionsChange, skipHeader = false , skipEndpoint = false , options } = props ;
26
+ const {
27
+ loadRegions,
28
+ onOptionsChange,
29
+ skipHeader = false ,
30
+ skipEndpoint = false ,
31
+ options,
32
+ hideAssumeRoleArn = false ,
33
+ } = props ;
27
34
let profile = options . jsonData . profile ;
28
35
if ( profile === undefined ) {
29
36
profile = options . database ;
@@ -142,97 +149,99 @@ export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionCon
142
149
) }
143
150
</ ConfigSubSection >
144
151
145
- < ConfigSubSection title = "Assume Role" >
146
- { options . jsonData . authType === AwsAuthType . GrafanaAssumeRole && (
147
- < div className = { assumeRoleInstructionsStyle } >
148
- < Collapse
149
- label = { 'How to create an IAM role for grafana to assume:' }
150
- collapsible = { true }
151
- isOpen = { isARNInstructionsOpen }
152
- onToggle = { ( ) => setIsARNInstructionsOpen ( ! isARNInstructionsOpen ) }
153
- >
154
- < ol >
155
- < li >
156
- < p >
157
- 1. Create a new IAM role in the AWS console, and select < code > Another AWS account</ code > as the{ ' ' }
158
- < code > Trusted entity</ code > .
159
- </ p >
160
- </ li >
161
- < li >
162
- < p >
163
- 2. Enter the account ID of the Grafana account that has permission to assume this role:
164
- < code > 008923505280 </ code > and check the < code > Require external ID</ code > box.
165
- </ p >
166
- </ li >
167
- < li >
168
- < p >
169
- 3. Enter the following external ID:{ ' ' }
170
- < code > { props . externalId || 'External Id is currently unavailable' } </ code > and click{ ' ' }
171
- < code > Next</ code > .
172
- </ p >
173
- </ li >
174
- < li >
175
- < p >
176
- 4. Add any required permissions you would like Grafana to be able to access on your behalf. For
177
- more details on our permissions please{ ' ' }
178
- < a
179
- href = "https://grafana.com/docs/grafana/latest/datasources/aws-cloudwatch/"
180
- target = "_blank"
181
- rel = "noreferrer"
182
- >
183
- read through our documentation
184
- </ a >
185
- .
186
- </ p >
187
- </ li >
188
- < li >
189
- < p >
190
- 5. Give the role a name and description, and click < code > Create role</ code > .
191
- </ p >
192
- </ li >
193
- < li >
194
- < p >
195
- 6. Copy the ARN of the role you just created and paste it into the < code > Assume Role ARN</ code > { ' ' }
196
- field below.
197
- </ p >
198
- </ li >
199
- </ ol >
200
- </ Collapse >
201
- </ div >
202
- ) }
203
- { awsAssumeRoleEnabled && (
204
- < >
205
- < Field
206
- htmlFor = "assumeRoleArn"
207
- label = "Assume Role ARN"
208
- description = "Optional. Specifying the ARN of a role will ensure that the
152
+ { ! hideAssumeRoleArn && (
153
+ < ConfigSubSection title = "Assume Role" >
154
+ { options . jsonData . authType === AwsAuthType . GrafanaAssumeRole && (
155
+ < div className = { assumeRoleInstructionsStyle } >
156
+ < Collapse
157
+ label = { 'How to create an IAM role for grafana to assume:' }
158
+ collapsible = { true }
159
+ isOpen = { isARNInstructionsOpen }
160
+ onToggle = { ( ) => setIsARNInstructionsOpen ( ! isARNInstructionsOpen ) }
161
+ >
162
+ < ol >
163
+ < li >
164
+ < p >
165
+ 1. Create a new IAM role in the AWS console, and select < code > Another AWS account</ code > as the{ ' ' }
166
+ < code > Trusted entity</ code > .
167
+ </ p >
168
+ </ li >
169
+ < li >
170
+ < p >
171
+ 2. Enter the account ID of the Grafana account that has permission to assume this role:
172
+ < code > 008923505280 </ code > and check the < code > Require external ID</ code > box.
173
+ </ p >
174
+ </ li >
175
+ < li >
176
+ < p >
177
+ 3. Enter the following external ID:{ ' ' }
178
+ < code > { props . externalId || 'External Id is currently unavailable' } </ code > and click{ ' ' }
179
+ < code > Next</ code > .
180
+ </ p >
181
+ </ li >
182
+ < li >
183
+ < p >
184
+ 4. Add any required permissions you would like Grafana to be able to access on your behalf. For
185
+ more details on our permissions please{ ' ' }
186
+ < a
187
+ href = "https://grafana.com/docs/grafana/latest/datasources/aws-cloudwatch/"
188
+ target = "_blank"
189
+ rel = "noreferrer"
190
+ >
191
+ read through our documentation
192
+ </ a >
193
+ .
194
+ </ p >
195
+ </ li >
196
+ < li >
197
+ < p >
198
+ 5. Give the role a name and description, and click < code > Create role</ code > .
199
+ </ p >
200
+ </ li >
201
+ < li >
202
+ < p >
203
+ 6. Copy the ARN of the role you just created and paste it into the < code > Assume Role ARN</ code > { ' ' }
204
+ field below.
205
+ </ p >
206
+ </ li >
207
+ </ ol >
208
+ </ Collapse >
209
+ </ div >
210
+ ) }
211
+ { awsAssumeRoleEnabled && (
212
+ < >
213
+ < Field
214
+ htmlFor = "assumeRoleArn"
215
+ label = "Assume Role ARN"
216
+ description = "Optional. Specifying the ARN of a role will ensure that the
209
217
selected authentication provider is used to assume the role rather than the
210
218
credentials directly."
211
- >
212
- < Input
213
- id = "assumeRoleArn"
214
- placeholder = "arn:aws:iam:*"
215
- value = { options . jsonData . assumeRoleArn || '' }
216
- onChange = { onUpdateDatasourceJsonDataOption ( props , 'assumeRoleArn' ) }
217
- />
218
- </ Field >
219
- { options . jsonData . authType !== AwsAuthType . GrafanaAssumeRole && (
220
- < Field
221
- htmlFor = "externalId"
222
- label = "External ID"
223
- description = "If you are assuming a role in another account, that has been created with an external ID, specify the external ID here."
224
219
>
225
220
< Input
226
- id = "externalId "
227
- placeholder = "External ID "
228
- value = { options . jsonData . externalId || '' }
229
- onChange = { onUpdateDatasourceJsonDataOption ( props , 'externalId ' ) }
221
+ id = "assumeRoleArn "
222
+ placeholder = "arn:aws:iam:* "
223
+ value = { options . jsonData . assumeRoleArn || '' }
224
+ onChange = { onUpdateDatasourceJsonDataOption ( props , 'assumeRoleArn ' ) }
230
225
/>
231
226
</ Field >
232
- ) }
233
- </ >
234
- ) }
235
- </ ConfigSubSection >
227
+ { options . jsonData . authType !== AwsAuthType . GrafanaAssumeRole && (
228
+ < Field
229
+ htmlFor = "externalId"
230
+ label = "External ID"
231
+ description = "If you are assuming a role in another account, that has been created with an external ID, specify the external ID here."
232
+ >
233
+ < Input
234
+ id = "externalId"
235
+ placeholder = "External ID"
236
+ value = { options . jsonData . externalId || '' }
237
+ onChange = { onUpdateDatasourceJsonDataOption ( props , 'externalId' ) }
238
+ />
239
+ </ Field >
240
+ ) }
241
+ </ >
242
+ ) }
243
+ </ ConfigSubSection >
244
+ ) }
236
245
< ConfigSubSection title = "Additional Settings" >
237
246
{ ! skipEndpoint && options . jsonData . authType !== AwsAuthType . GrafanaAssumeRole && (
238
247
< Field
0 commit comments