From e3fc8f07c36a9fe02c3a496664836394dfedc897 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Mon, 5 May 2025 20:43:55 +0530 Subject: [PATCH 1/4] Add table aws_cloudwatch_event_rule --- aws/plugin.go | 1 + aws/table_aws_cloudwatch_event_rule.go | 368 +++++++++++++++++++++++ docs/tables/aws_cloudwatch_event_rule.md | 151 ++++++++++ 3 files changed, 520 insertions(+) create mode 100644 aws/table_aws_cloudwatch_event_rule.go create mode 100644 docs/tables/aws_cloudwatch_event_rule.md diff --git a/aws/plugin.go b/aws/plugin.go index 5a138dd0e..8c205755b 100644 --- a/aws/plugin.go +++ b/aws/plugin.go @@ -138,6 +138,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "aws_cloudtrail_trail": tableAwsCloudtrailTrail(ctx), "aws_cloudtrail_trail_event": tableAwsCloudtrailTrailEvent(ctx), "aws_cloudwatch_alarm": tableAwsCloudWatchAlarm(ctx), + "aws_cloudwatch_event_rule": tableAwsCloudwatchEventRule(ctx), "aws_cloudwatch_log_delivery_destination": tableAwsCloudWatchLogDeliveryDestination(ctx), "aws_cloudwatch_log_delivery_source": tableAwsCloudWatchLogDeliverySource(ctx), "aws_cloudwatch_log_delivery": tableAwsCloudWatchLogDelivery(ctx), diff --git a/aws/table_aws_cloudwatch_event_rule.go b/aws/table_aws_cloudwatch_event_rule.go new file mode 100644 index 000000000..a5930b21b --- /dev/null +++ b/aws/table_aws_cloudwatch_event_rule.go @@ -0,0 +1,368 @@ +package aws + +import ( + "context" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/eventbridge" + + "github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/v5/plugin" + "github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform" +) + +//// TABLE DEFINITION + +func tableAwsCloudwatchEventRule(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "aws_cloudwatch_event_rule", + Description: "AWS CloudWatch Event Rule", + Get: &plugin.GetConfig{ + KeyColumns: plugin.AllColumns([]string{"name", "event_bus_name"}), + IgnoreConfig: &plugin.IgnoreConfig{ + ShouldIgnoreErrorFunc: shouldIgnoreErrors([]string{"ResourceNotFoundException"}), + }, + Hydrate: getAwsCloudWatchEventRule, + Tags: map[string]string{"service": "events", "action": "DescribeRule"}, + }, + List: &plugin.ListConfig{ + Hydrate: listAwsCloudWatchEventRules, + Tags: map[string]string{"service": "events", "action": "ListRules"}, + KeyColumns: []*plugin.KeyColumn{ + {Name: "event_bus_name", Require: plugin.Optional}, + {Name: "name_prefix", Require: plugin.Optional}, + }, + }, + HydrateConfig: []plugin.HydrateConfig{ + { + Func: getAwsCloudWatchEventTargetsByRule, + Tags: map[string]string{"service": "events", "action": "ListTargetsByRule"}, + }, + { + Func: getAwsCloudWatchEventRuleTags, + Tags: map[string]string{"service": "events", "action": "ListTagsForResource"}, + }, + }, + GetMatrixItemFunc: SupportedRegionMatrix(AWS_EVENTS_SERVICE_ID), + Columns: awsRegionalColumns([]*plugin.Column{ + { + Name: "name", + Description: "The name of the rule.", + Type: proto.ColumnType_STRING, + }, + { + Name: "arn", + Description: "The Amazon Resource Name (ARN) of the rule.", + Type: proto.ColumnType_STRING, + }, + { + Name: "description", + Description: "The description of the rule.", + Type: proto.ColumnType_STRING, + }, + { + Name: "state", + Description: "The state of the rule.", + Type: proto.ColumnType_STRING, + }, + { + Name: "event_bus_name", + Description: "The name or ARN of the event bus associated with the rule.", + Type: proto.ColumnType_STRING, + }, + { + Name: "created_by", + Description: "The account ID of the user that created the rule.", + Type: proto.ColumnType_STRING, + Hydrate: getAwsCloudWatchEventRule, + }, + { + Name: "role_arn", + Description: "The Amazon Resource Name (ARN) of the IAM role associated with the rule.", + Type: proto.ColumnType_STRING, + Hydrate: getAwsCloudWatchEventRule, + }, + { + Name: "schedule_expression", + Description: "The scheduling expression. For example, 'cron(0 20 * * ? *)', 'rate(5 minutes)'.", + Type: proto.ColumnType_STRING, + Hydrate: getAwsCloudWatchEventRule, + }, + { + Name: "managed_by", + Description: "If this is a managed rule, created by an AWS service on your behalf, this field displays the principal name of the AWS service that created the rule.", + Type: proto.ColumnType_STRING, + }, + { + Name: "event_pattern", + Description: "The event pattern of the rule.", + Type: proto.ColumnType_JSON, + Hydrate: getAwsCloudWatchEventRule, + }, + { + Name: "name_prefix", + Description: "Specifying this limits the results to only those event rules with names that start with the specified prefix.", + Type: proto.ColumnType_STRING, + Hydrate: getCloudWatchNamePrefixValue, + Transform: transform.FromValue(), + }, + { + Name: "targets", + Description: "The targets assigned to the rule.", + Type: proto.ColumnType_JSON, + Hydrate: getAwsCloudWatchEventTargetsByRule, + Transform: transform.FromField("Targets"), + }, + { + Name: "tags_src", + Description: "A list of tags assigned to the rule.", + Type: proto.ColumnType_JSON, + Hydrate: getAwsCloudWatchEventRuleTags, + Transform: transform.FromField("Tags"), + }, + + // Standard columns for all tables + { + Name: "title", + Description: resourceInterfaceDescription("title"), + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Name"), + }, + { + Name: "tags", + Description: resourceInterfaceDescription("tags"), + Type: proto.ColumnType_JSON, + Hydrate: getAwsCloudWatchEventRuleTags, + Transform: transform.FromField("Tags").Transform(cloudWatchEventTagListToTurbotTags), + }, + { + Name: "akas", + Description: resourceInterfaceDescription("akas"), + Type: proto.ColumnType_JSON, + Transform: transform.FromField("Arn").Transform(transform.EnsureStringArray), + }, + }), + } +} + +//// LIST FUNCTION + +func listAwsCloudWatchEventRules(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + // Get client + svc, err := EventBridgeClient(ctx, d) + if err != nil { + plugin.Logger(ctx).Error("aws_cloudwatch_event_rule.listAwsCloudWatchEventRules", "get_client_error", err) + return nil, err + } + if svc == nil { + // Unsupported region, return no data + return nil, nil + } + + // Limiting the results + maxLimit := int32(100) + if d.QueryContext.Limit != nil { + limit := int32(*d.QueryContext.Limit) + if limit < maxLimit { + if limit < 1 { + maxLimit = 1 + } else { + maxLimit = limit + } + } + } + + pagesLeft := true + params := &eventbridge.ListRulesInput{ + // Default to the maximum allowed + Limit: aws.Int32(maxLimit), + } + + equalQuals := d.EqualsQuals + if equalQuals["event_bus_name"] != nil { + params.EventBusName = aws.String(equalQuals["event_bus_name"].GetStringValue()) + } + if equalQuals["name_prefix"] != nil { + params.NamePrefix = aws.String(equalQuals["name_prefix"].GetStringValue()) + } + + // API doesn't support aws-go-sdk-v2 paginator as of date + for pagesLeft { + // apply rate limiting + d.WaitForListRateLimit(ctx) + + output, err := svc.ListRules(ctx, params) + if err != nil { + plugin.Logger(ctx).Error("aws_cloudwatch_event_rule.listAwsCloudWatchEventRules", "api_error", err) + return nil, err + } + for _, rule := range output.Rules { + d.StreamListItem(ctx, &eventbridge.DescribeRuleOutput{ + Name: rule.Name, + Arn: rule.Arn, + Description: rule.Description, + State: rule.State, + EventBusName: rule.EventBusName, + ManagedBy: rule.ManagedBy, + }) + + // Context may get cancelled due to manual cancellation or if the limit has been reached + if d.RowsRemaining(ctx) == 0 { + return nil, nil + } + } + if output.NextToken != nil { + pagesLeft = true + params.NextToken = output.NextToken + } else { + pagesLeft = false + } + } + + return nil, nil +} + +//// HYDRATE FUNCTIONS + +func getAwsCloudWatchEventRule(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + var name, eventBusName string + + if h.Item != nil { + name = *h.Item.(*eventbridge.DescribeRuleOutput).Name + if h.Item.(*eventbridge.DescribeRuleOutput).EventBusName != nil { + eventBusName = *h.Item.(*eventbridge.DescribeRuleOutput).EventBusName + } + } else { + name = d.EqualsQuals["name"].GetStringValue() + eventBusName = d.EqualsQuals["event_bus_name"].GetStringValue() + } + + // Create Session + svc, err := EventBridgeClient(ctx, d) + if err != nil { + plugin.Logger(ctx).Error("aws_cloudwatch_event_rule.getAwsCloudWatchEventRule", "get_client_error", err) + return nil, err + } + if svc == nil { + // Unsupported region, return no data + return nil, nil + } + + // Build the params + params := &eventbridge.DescribeRuleInput{ + Name: &name, + } + + // Use the event bus name if specified + if eventBusName != "" { + params.EventBusName = &eventBusName + } + + // Get call + data, err := svc.DescribeRule(ctx, params) + if err != nil { + plugin.Logger(ctx).Error("aws_cloudwatch_event_rule.getAwsCloudWatchEventRule", "api_error", err) + return nil, err + } + + return data, nil +} + +func getAwsCloudWatchEventTargetsByRule(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + rule := h.Item.(*eventbridge.DescribeRuleOutput) + name := rule.Name + var eventBusName *string + + if rule.EventBusName != nil { + eventBusName = rule.EventBusName + } + + // Create Session + svc, err := EventBridgeClient(ctx, d) + if err != nil { + plugin.Logger(ctx).Error("aws_cloudwatch_event_rule.getAwsCloudWatchEventTargetsByRule", "get_client_error", err) + return nil, err + } + if svc == nil { + // Unsupported region, return no data + return nil, nil + } + + // Build the params + params := &eventbridge.ListTargetsByRuleInput{ + Rule: name, + } + + // Use event bus name if available + if eventBusName != nil { + params.EventBusName = eventBusName + } + + data, err := svc.ListTargetsByRule(ctx, params) + if err != nil { + plugin.Logger(ctx).Error("aws_cloudwatch_event_rule.getAwsCloudWatchEventTargetsByRule", "api_error", err) + return nil, err + } + + return data, nil +} + +func getAwsCloudWatchEventRuleTags(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + arn := h.Item.(*eventbridge.DescribeRuleOutput).Arn + + // Create Session + svc, err := EventBridgeClient(ctx, d) + if err != nil { + plugin.Logger(ctx).Error("aws_cloudwatch_event_rule.getAwsCloudWatchEventRuleTags", "get_client_error", err) + return nil, err + } + if svc == nil { + // Unsupported region, return no data + return nil, nil + } + + // Build the params + params := &eventbridge.ListTagsForResourceInput{ + ResourceARN: arn, + } + + // Get call + op, err := svc.ListTagsForResource(ctx, params) + if err != nil { + plugin.Logger(ctx).Error("aws_cloudwatch_event_rule.getAwsCloudWatchEventRuleTags", "api_error", err) + return nil, err + } + + return op, nil +} + +//// TRANSFORM FUNCTIONS + +func cloudWatchEventTagListToTurbotTags(ctx context.Context, d *transform.TransformData) (interface{}, error) { + tagList := d.HydrateItem.(*eventbridge.ListTagsForResourceOutput) + + if tagList.Tags == nil { + return nil, nil + } + + // Mapping the resource tags inside turbotTags + var turbotTagsMap map[string]string + if tagList != nil { + turbotTagsMap = map[string]string{} + for _, i := range tagList.Tags { + turbotTagsMap[*i.Key] = *i.Value + } + } + + return turbotTagsMap, nil +} + +//// UTILITY FUNCTIONS + +func getCloudWatchNamePrefixValue(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + if d.EqualsQuals["name_prefix"].GetStringValue() != "" { + return d.EqualsQuals["name_prefix"].GetStringValue(), nil + } else { + return h.Item.(*eventbridge.DescribeRuleOutput).Name, nil + } +} diff --git a/docs/tables/aws_cloudwatch_event_rule.md b/docs/tables/aws_cloudwatch_event_rule.md new file mode 100644 index 000000000..92fcfd6cf --- /dev/null +++ b/docs/tables/aws_cloudwatch_event_rule.md @@ -0,0 +1,151 @@ +--- +title: "Steampipe Table: aws_cloudwatch_event_rule - Query AWS CloudWatch Event Rule using SQL" +description: "Allows users to query AWS CloudWatch Event Rule to access information regarding the event rules defined within an AWS account." +folder: "CloudWatch" +--- + +# Table: aws_cloudwatch_event_rule - Query AWS CloudWatch Event Rule using SQL + +AWS CloudWatch Events delivers a near real-time stream of system events that describe changes in AWS resources. CloudWatch Events allows you to route events to targets like AWS Lambda functions, Amazon SNS topics, Amazon SQS queues, or built-in targets. CloudWatch Events allows you to set up rules to trigger automated actions when an event matches your rule. + +## Table Usage Guide + +The `aws_cloudwatch_event_rule` table in Steampipe provides you with information about CloudWatch Event rules within AWS CloudWatch Events. This table allows you, as a DevOps engineer, to query rule-specific details, including the rule name, ARN, state, description, schedule expression, and associated metadata. You can utilize this table to gather insights on rules, such as the rules associated with a specific event bus, the state of the rules (whether they are enabled or disabled), and more. The schema outlines the various attributes of the CloudWatch Event rule for you, including the rule ARN, event bus name, description, state, and associated tags. + +## Examples + +### Basic info + +Gain insights into the status and origins of your AWS CloudWatch Events rules. This query is particularly useful for auditing and maintaining an overview of your event settings. + +```sql+postgres +select + name, + arn, + state, + created_by, + event_bus_name +from + aws_cloudwatch_event_rule; +``` + +```sql+sqlite +select + name, + arn, + state, + created_by, + event_bus_name +from + aws_cloudwatch_event_rule; +``` + +### List disabled rules + +Determine the areas in which AWS CloudWatch Events rules are not active. This is useful for identifying potential gaps in event-driven workflows or areas where automation may have been turned off. + +```sql+postgres +select + name, + arn, + state, + created_by +from + aws_cloudwatch_event_rule +where + state != 'ENABLED'; +``` + +```sql+sqlite +select + name, + arn, + state, + created_by +from + aws_cloudwatch_event_rule +where + state != 'ENABLED'; +``` + +### Get the target information for each rule + +This query allows you to identify the target details for each rule in your AWS CloudWatch Events service. It's useful for auditing and understanding the relationships and dependencies between different rules and their targets within your AWS infrastructure. + +```sql+postgres +select + name, + cd ->> 'Id' as target_id, + cd ->> 'Arn' as target_arn, + cd ->> 'RoleArn' as role_arn +from + aws_cloudwatch_event_rule, + jsonb_array_elements(targets) as cd; +``` + +```sql+sqlite +select + name, + json_extract(cd.value, '$.Id') as target_id, + json_extract(cd.value, '$.Arn') as target_arn, + json_extract(cd.value, '$.RoleArn') as role_arn +from + aws_cloudwatch_event_rule, + json_each(targets) as cd; +``` + +### List CloudWatch Event rules with schedule expressions + +Identify rules that are triggered on a schedule rather than by events, which is useful for understanding time-based automation in your environment. + +```sql+postgres +select + name, + schedule_expression, + state, + description +from + aws_cloudwatch_event_rule +where + schedule_expression is not null; +``` + +```sql+sqlite +select + name, + schedule_expression, + state, + description +from + aws_cloudwatch_event_rule +where + schedule_expression is not null; +``` + +### Find rules with Lambda function targets + +Discover which CloudWatch Event rules are triggering Lambda functions, helping to map out serverless event-driven architectures in your AWS environment. + +```sql+postgres +select + r.name as rule_name, + t ->> 'Id' as target_id, + t ->> 'Arn' as lambda_arn +from + aws_cloudwatch_event_rule as r, + jsonb_array_elements(r.targets) as t +where + t ->> 'Arn' like 'arn:aws:lambda:%'; +``` + +```sql+sqlite +select + r.name as rule_name, + json_extract(t.value, '$.Id') as target_id, + json_extract(t.value, '$.Arn') as lambda_arn +from + aws_cloudwatch_event_rule as r, + json_each(r.targets) as t +where + json_extract(t.value, '$.Arn') like 'arn:aws:lambda:%'; +``` From e745742d75c6ad6ec3cd000a310154fe810ffbfd Mon Sep 17 00:00:00 2001 From: ParthaI Date: Wed, 7 May 2025 11:10:35 +0530 Subject: [PATCH 2/4] update the doc and tested the table end to end --- aws/table_aws_cloudwatch_event_rule.go | 18 ++++++++---------- docs/tables/aws_cloudwatch_event_rule.md | 5 ----- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/aws/table_aws_cloudwatch_event_rule.go b/aws/table_aws_cloudwatch_event_rule.go index a5930b21b..dc1defcce 100644 --- a/aws/table_aws_cloudwatch_event_rule.go +++ b/aws/table_aws_cloudwatch_event_rule.go @@ -80,13 +80,11 @@ func tableAwsCloudwatchEventRule(_ context.Context) *plugin.Table { Name: "role_arn", Description: "The Amazon Resource Name (ARN) of the IAM role associated with the rule.", Type: proto.ColumnType_STRING, - Hydrate: getAwsCloudWatchEventRule, }, { Name: "schedule_expression", Description: "The scheduling expression. For example, 'cron(0 20 * * ? *)', 'rate(5 minutes)'.", Type: proto.ColumnType_STRING, - Hydrate: getAwsCloudWatchEventRule, }, { Name: "managed_by", @@ -97,7 +95,6 @@ func tableAwsCloudwatchEventRule(_ context.Context) *plugin.Table { Name: "event_pattern", Description: "The event pattern of the rule.", Type: proto.ColumnType_JSON, - Hydrate: getAwsCloudWatchEventRule, }, { Name: "name_prefix", @@ -185,7 +182,6 @@ func listAwsCloudWatchEventRules(ctx context.Context, d *plugin.QueryData, h *pl if equalQuals["name_prefix"] != nil { params.NamePrefix = aws.String(equalQuals["name_prefix"].GetStringValue()) } - // API doesn't support aws-go-sdk-v2 paginator as of date for pagesLeft { // apply rate limiting @@ -198,12 +194,14 @@ func listAwsCloudWatchEventRules(ctx context.Context, d *plugin.QueryData, h *pl } for _, rule := range output.Rules { d.StreamListItem(ctx, &eventbridge.DescribeRuleOutput{ - Name: rule.Name, - Arn: rule.Arn, - Description: rule.Description, - State: rule.State, - EventBusName: rule.EventBusName, - ManagedBy: rule.ManagedBy, + Name: rule.Name, + Arn: rule.Arn, + Description: rule.Description, + State: rule.State, + EventBusName: rule.EventBusName, + ManagedBy: rule.ManagedBy, + ScheduleExpression: rule.ScheduleExpression, + RoleArn: rule.RoleArn, }) // Context may get cancelled due to manual cancellation or if the limit has been reached diff --git a/docs/tables/aws_cloudwatch_event_rule.md b/docs/tables/aws_cloudwatch_event_rule.md index 92fcfd6cf..50606646e 100644 --- a/docs/tables/aws_cloudwatch_event_rule.md +++ b/docs/tables/aws_cloudwatch_event_rule.md @@ -15,7 +15,6 @@ The `aws_cloudwatch_event_rule` table in Steampipe provides you with information ## Examples ### Basic info - Gain insights into the status and origins of your AWS CloudWatch Events rules. This query is particularly useful for auditing and maintaining an overview of your event settings. ```sql+postgres @@ -41,7 +40,6 @@ from ``` ### List disabled rules - Determine the areas in which AWS CloudWatch Events rules are not active. This is useful for identifying potential gaps in event-driven workflows or areas where automation may have been turned off. ```sql+postgres @@ -69,7 +67,6 @@ where ``` ### Get the target information for each rule - This query allows you to identify the target details for each rule in your AWS CloudWatch Events service. It's useful for auditing and understanding the relationships and dependencies between different rules and their targets within your AWS infrastructure. ```sql+postgres @@ -95,7 +92,6 @@ from ``` ### List CloudWatch Event rules with schedule expressions - Identify rules that are triggered on a schedule rather than by events, which is useful for understanding time-based automation in your environment. ```sql+postgres @@ -123,7 +119,6 @@ where ``` ### Find rules with Lambda function targets - Discover which CloudWatch Event rules are triggering Lambda functions, helping to map out serverless event-driven architectures in your AWS environment. ```sql+postgres From ab38c0dd5990bfc1caafb5a272c8778c9b1a24b2 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Wed, 7 May 2025 12:01:38 +0530 Subject: [PATCH 3/4] Addressed copilot review comment --- aws/table_aws_cloudwatch_event_rule.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/aws/table_aws_cloudwatch_event_rule.go b/aws/table_aws_cloudwatch_event_rule.go index dc1defcce..c41107a9f 100644 --- a/aws/table_aws_cloudwatch_event_rule.go +++ b/aws/table_aws_cloudwatch_event_rule.go @@ -160,6 +160,7 @@ func listAwsCloudWatchEventRules(ctx context.Context, d *plugin.QueryData, h *pl maxLimit := int32(100) if d.QueryContext.Limit != nil { limit := int32(*d.QueryContext.Limit) + // AWS API enforces a minimum limit of 1 and a default of 100, so adjust if a lower value is provided. if limit < maxLimit { if limit < 1 { maxLimit = 1 @@ -226,9 +227,13 @@ func getAwsCloudWatchEventRule(ctx context.Context, d *plugin.QueryData, h *plug var name, eventBusName string if h.Item != nil { - name = *h.Item.(*eventbridge.DescribeRuleOutput).Name - if h.Item.(*eventbridge.DescribeRuleOutput).EventBusName != nil { - eventBusName = *h.Item.(*eventbridge.DescribeRuleOutput).EventBusName + item, ok := h.Item.(*eventbridge.DescribeRuleOutput) + if !ok { + return nil, nil + } + name = *item.Name + if item.EventBusName != nil { + eventBusName = *item.EventBusName } } else { name = d.EqualsQuals["name"].GetStringValue() @@ -268,6 +273,7 @@ func getAwsCloudWatchEventRule(ctx context.Context, d *plugin.QueryData, h *plug func getAwsCloudWatchEventTargetsByRule(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { rule := h.Item.(*eventbridge.DescribeRuleOutput) + name := rule.Name var eventBusName *string @@ -306,7 +312,9 @@ func getAwsCloudWatchEventTargetsByRule(ctx context.Context, d *plugin.QueryData } func getAwsCloudWatchEventRuleTags(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { - arn := h.Item.(*eventbridge.DescribeRuleOutput).Arn + item := h.Item.(*eventbridge.DescribeRuleOutput) + + arn := item.Arn // Create Session svc, err := EventBridgeClient(ctx, d) @@ -344,12 +352,9 @@ func cloudWatchEventTagListToTurbotTags(ctx context.Context, d *transform.Transf } // Mapping the resource tags inside turbotTags - var turbotTagsMap map[string]string - if tagList != nil { - turbotTagsMap = map[string]string{} - for _, i := range tagList.Tags { - turbotTagsMap[*i.Key] = *i.Value - } + turbotTagsMap := map[string]string{} + for _, i := range tagList.Tags { + turbotTagsMap[*i.Key] = *i.Value } return turbotTagsMap, nil From b593c7aae0120ac6d7b86dcccd788efa14428035 Mon Sep 17 00:00:00 2001 From: Keep Focused Date: Tue, 20 May 2025 23:28:15 +0700 Subject: [PATCH 4/4] Update the limit logic --- aws/table_aws_cloudwatch_event_rule.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/aws/table_aws_cloudwatch_event_rule.go b/aws/table_aws_cloudwatch_event_rule.go index c41107a9f..7684b8f3c 100644 --- a/aws/table_aws_cloudwatch_event_rule.go +++ b/aws/table_aws_cloudwatch_event_rule.go @@ -162,11 +162,7 @@ func listAwsCloudWatchEventRules(ctx context.Context, d *plugin.QueryData, h *pl limit := int32(*d.QueryContext.Limit) // AWS API enforces a minimum limit of 1 and a default of 100, so adjust if a lower value is provided. if limit < maxLimit { - if limit < 1 { - maxLimit = 1 - } else { - maxLimit = limit - } + maxLimit = limit } }