hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.61k stars 8.99k forks source link

[New Data Source]: add `aws_flow_log` and `aws_cloudwatch_log_subscription_filter` #37704

Open lorenzophys opened 1 month ago

lorenzophys commented 1 month ago

Description

I am currently implementing a logs observability solution. This implementation requires both a flow log object and a subscription filter for the log group. Having these data sources available would greatly facilitate this process by allowing users to retrieve the necessary information directly within their Terraform configurations.

They both already have a resource block, but lack a data source.

Based on the AWS SDK:

  1. aws_cloudwatch_log_subscription_filter attributes: destination_arn, distribution, filter_pattern, log_group_name, role_arn, tags
  2. aws_flow_log attributes: flow_logs_status, log_destination, log_destination_type, log_format, log_group_name, max_aggregation_interval, traffic_type, tags

I would be happy to help you implement this.

Requested Resource(s) and/or Data Source(s)

Potential Terraform Configuration

# Based on:
# 1. https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/ec2@v1.27.0#DescribeFlowLogsInput
# 2. https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs@v1.27.0#DescribeSubscriptionFiltersInput

data "aws_flow_log" "example" {
  flow_log_id = "fl-1234567890abcdef"
}

data "aws_cloudwatch_log_subscription_filter" "example" {
  log_group_name = "my-log-group"
  filter_name    = "my-subscription-filter"
}

References

  1. https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs@v1.27.0/types#SubscriptionFilter
  2. https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/ec2@v1.27.0/types#FlowLog

Would you like to implement a fix?

Yes

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue