@@ -38,6 +38,13 @@ func tableAwsCloudFrontDistribution(_ context.Context) *plugin.Table {
3838 Func : getCloudFrontDistributionTags ,
3939 Tags : map [string ]string {"service" : "cloudfront" , "action" : "ListTagsForResource" },
4040 },
41+ {
42+ Func : getCloudFrontDistributionMonitoringSubscription ,
43+ Tags : map [string ]string {"service" : "cloudfront" , "action" : "GetMonitoringSubscription" },
44+ IgnoreConfig : & plugin.IgnoreConfig {
45+ ShouldIgnoreErrorFunc : shouldIgnoreErrors ([]string {"NoSuchMonitoringSubscription" }),
46+ },
47+ },
4148 },
4249 Columns : awsRegionalColumns ([]* plugin.Column {
4350 {
@@ -215,6 +222,13 @@ func tableAwsCloudFrontDistribution(_ context.Context) *plugin.Table {
215222 Type : proto .ColumnType_JSON ,
216223 Transform : transform .FromField ("ViewerCertificate" , "Distribution.DistributionConfig.ViewerCertificate" ),
217224 },
225+ {
226+ Name : "monitoring_subscription" ,
227+ Description : "The monitoring subscription for the CloudFront distribution." ,
228+ Type : proto .ColumnType_JSON ,
229+ Hydrate : getCloudFrontDistributionMonitoringSubscription ,
230+ Transform : transform .FromValue (),
231+ },
218232
219233 // Standard columns for all tables
220234 {
@@ -356,6 +370,45 @@ func getCloudFrontDistributionTags(ctx context.Context, d *plugin.QueryData, h *
356370 return op , nil
357371}
358372
373+ func getCloudFrontDistributionMonitoringSubscription (ctx context.Context , d * plugin.QueryData , h * plugin.HydrateData ) (interface {}, error ) {
374+ // Get client
375+ svc , err := CloudFrontClient (ctx , d )
376+ if err != nil {
377+ plugin .Logger (ctx ).Error ("aws_cloudfront_distribution.getCloudFrontDistributionMonitoringSubscription" , "client_error" , err )
378+ return nil , err
379+ }
380+
381+ var distributionID string
382+ if h .Item != nil {
383+ switch item := h .Item .(type ) {
384+ case types.DistributionSummary :
385+ distributionID = * item .Id
386+ case cloudfront.GetDistributionOutput :
387+ distributionID = * item .Distribution .Id
388+ }
389+ } else {
390+ distributionID = d .EqualsQuals ["id" ].GetStringValue ()
391+ }
392+
393+ if strings .TrimSpace (distributionID ) == "" {
394+ return nil , nil
395+ }
396+
397+ // Build the params
398+ params := & cloudfront.GetMonitoringSubscriptionInput {
399+ DistributionId : & distributionID ,
400+ }
401+
402+ // Get call
403+ op , err := svc .GetMonitoringSubscription (ctx , params )
404+ if err != nil {
405+ plugin .Logger (ctx ).Error ("aws_cloudfront_distribution.getCloudFrontDistributionMonitoringSubscription" , "api_error" , err )
406+ return nil , err
407+ }
408+
409+ return op .MonitoringSubscription , nil
410+ }
411+
359412//// TRANSFORM FUNCTIONS
360413
361414func cloudFrontDistributionTagListToTurbotTags (ctx context.Context , d * transform.TransformData ) (interface {}, error ) {
0 commit comments