From c2448394c191175c27c61a36e3e9c155f7dc4e03 Mon Sep 17 00:00:00 2001 From: ryandeivert Date: Thu, 25 Jan 2018 09:03:24 -0800 Subject: [PATCH] resource/aws_cloudwatch_log_subscription_filter: Add support for distribution (#3046) * adding support for distribution in cw subscription filters. resolves #2853 * Update resource_aws_cloudwatch_log_subscription_filter_test.go --- aws/resource_aws_cloudwatch_log_subscription_filter.go | 8 ++++++++ ...esource_aws_cloudwatch_log_subscription_filter_test.go | 3 +++ .../r/cloudwatch_log_subscription_filter.html.markdown | 2 ++ 3 files changed, 13 insertions(+) diff --git a/aws/resource_aws_cloudwatch_log_subscription_filter.go b/aws/resource_aws_cloudwatch_log_subscription_filter.go index bbdb2208592..1598b748f54 100644 --- a/aws/resource_aws_cloudwatch_log_subscription_filter.go +++ b/aws/resource_aws_cloudwatch_log_subscription_filter.go @@ -48,6 +48,10 @@ func resourceAwsCloudwatchLogSubscriptionFilter() *schema.Resource { Optional: true, Computed: true, }, + "distribution": { + Type: schema.TypeString, + Optional: true, + }, }, } } @@ -121,6 +125,10 @@ func getAwsCloudWatchLogsSubscriptionFilterInput(d *schema.ResourceData) cloudwa params.RoleArn = aws.String(d.Get("role_arn").(string)) } + if _, ok := d.GetOk("distribution"); ok { + params.Distribution = aws.String(d.Get("distribution").(string)) + } + return params } diff --git a/aws/resource_aws_cloudwatch_log_subscription_filter_test.go b/aws/resource_aws_cloudwatch_log_subscription_filter_test.go index c83d48b8079..68ab207fad9 100644 --- a/aws/resource_aws_cloudwatch_log_subscription_filter_test.go +++ b/aws/resource_aws_cloudwatch_log_subscription_filter_test.go @@ -31,6 +31,8 @@ func TestAccAWSCloudwatchLogSubscriptionFilter_basic(t *testing.T) { "aws_cloudwatch_log_subscription_filter.test_lambdafunction_logfilter", "name", fmt.Sprintf("test_lambdafunction_logfilter_%s", rstring)), resource.TestCheckResourceAttr( "aws_cloudwatch_log_subscription_filter.test_lambdafunction_logfilter", "log_group_name", fmt.Sprintf("example_lambda_name_%s", rstring)), + resource.TestCheckResourceAttr( + "aws_cloudwatch_log_subscription_filter.test_lambdafunction_logfilter", "distribution", "Random"), ), }, }, @@ -152,6 +154,7 @@ resource "aws_cloudwatch_log_subscription_filter" "test_lambdafunction_logfilter log_group_name = "${aws_cloudwatch_log_group.logs.name}" filter_pattern = "logtype test" destination_arn = "${aws_lambda_function.test_lambdafunction.arn}" + distribution = "Random" } resource "aws_lambda_function" "test_lambdafunction" { diff --git a/website/docs/r/cloudwatch_log_subscription_filter.html.markdown b/website/docs/r/cloudwatch_log_subscription_filter.html.markdown index 9b279e90d1d..16c65ff6275 100644 --- a/website/docs/r/cloudwatch_log_subscription_filter.html.markdown +++ b/website/docs/r/cloudwatch_log_subscription_filter.html.markdown @@ -19,6 +19,7 @@ resource "aws_cloudwatch_log_subscription_filter" "test_lambdafunction_logfilter log_group_name = "/aws/lambda/example_lambda_name" filter_pattern = "logtype test" destination_arn = "${aws_kinesis_stream.test_logstream.arn}" + distribution = "Random" } ``` @@ -31,6 +32,7 @@ The following arguments are supported: * `filter_pattern` - (Required) A valid CloudWatch Logs filter pattern for subscribing to a filtered stream of log events. * `log_group_name` - (Required) The name of the log group to associate the subscription filter with * `role_arn` - (Optional) The ARN of an IAM role that grants Amazon CloudWatch Logs permissions to deliver ingested log events to the destination. If you use Lambda as a destination, you should skip this argument and use `aws_lambda_permission` resource for granting access from CloudWatch logs to the destination Lambda function. +* `distribution` - (Optional) The method used to distribute log data to the destination. By default log data is grouped by log stream, but the grouping can be set to random for a more even distribution. This property is only applicable when the destination is an Amazon Kinesis stream. Valid values are "Random" and "ByLogStream". ## Attributes Reference