import { Construct } from '@aws-cdk/core' ; import { Role , PolicyStatement , Effect , ServicePrincipal } from '@aws-cdk/aws-iam' ; export interface KendraDataSourceIamRoleProps { kendraIndexArns : string [ ] ; } /**
 * Role for a kendra data source, see: https://docs.aws.amazon.com/kendra/latest/dg/iam-roles.html
 */ export default class KendraDataSourceIamRole extends Role { constructor ( scope , id , props ) { super ( scope , id , { assumedBy : new ServicePrincipal ( 'kendra.amazonaws.com' ) , } ) ; this . addToPolicy ( new PolicyStatement ( { effect : Effect . ALLOW , actions : [ 'kendra:BatchPutDocument' , 'kendra:BatchDeleteDocument' , ] , resources : props . kendraIndexArns , } ) ) ; } }