@@ -8,6 +8,8 @@ import { TagMap } from '../../types'
88import services from '../../enums/services'
99import { RawAwsS3 } from '../s3/data'
1010import { s3BucketArn } from '../../utils/generateArns'
11+ import { globalRegionName } from '../../enums/regions'
12+ import { RawAwsIamRole } from '../iamRole/data'
1113
1214/**
1315 * Kinesis Firehose
@@ -26,7 +28,11 @@ export default ({
2628 region : string
2729} ) : { [ key : string ] : ServiceConnection [ ] } => {
2830 const connections : ServiceConnection [ ] = [ ]
29- const { DeliveryStreamARN : id , Destinations : destinations = [ ] } = firehose
31+ const {
32+ DeliveryStreamARN : id ,
33+ Destinations : destinations = [ ] ,
34+ Source = { } ,
35+ } = firehose
3036
3137 const kinesisStreamSourceARN =
3238 firehose . Source ?. KinesisStreamSourceDescription ?. KinesisStreamARN
@@ -63,10 +69,8 @@ export default ({
6369
6470 if ( ! isEmpty ( destinations ) ) {
6571 destinations . map ( ( destination : DestinationDescription ) => {
66- const {
67- ExtendedS3DestinationDescription,
68- S3DestinationDescription,
69- } = destination
72+ const { ExtendedS3DestinationDescription, S3DestinationDescription } =
73+ destination
7074 const s3DestinationDescription =
7175 ExtendedS3DestinationDescription || S3DestinationDescription
7276 if ( s3DestinationDescription ) {
@@ -94,6 +98,32 @@ export default ({
9498 } )
9599 }
96100
101+ /**
102+ * Find related IAM Roles
103+ */
104+ const roles : { name : string ; data : { [ property : string ] : any [ ] } } =
105+ data . find ( ( { name } ) => name === services . iamRole )
106+ if (
107+ roles ?. data ?. [ globalRegionName ] &&
108+ Source ?. KinesisStreamSourceDescription ?. RoleARN
109+ ) {
110+ const dataAtRegion : RawAwsIamRole [ ] = roles . data [ globalRegionName ] . filter (
111+ role => role . Arn === Source . KinesisStreamSourceDescription . RoleARN
112+ )
113+ if ( ! isEmpty ( dataAtRegion ) ) {
114+ for ( const instance of dataAtRegion ) {
115+ const { Arn : roleId } = instance
116+
117+ connections . push ( {
118+ id : roleId ,
119+ resourceType : services . iamRole ,
120+ relation : 'child' ,
121+ field : 'iamRole' ,
122+ } )
123+ }
124+ }
125+ }
126+
97127 const kinesisFirehoseResult = {
98128 [ id ] : connections ,
99129 }
0 commit comments