Skip to content

Commit

Permalink
resource/aws_s3_bucket_metric: Fix import ordering and spread filter …
Browse files Browse the repository at this point in the history
…casting across lines
  • Loading branch information
bflad committed Feb 16, 2018
1 parent 1d9468a commit 58fed40
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions aws/resource_aws_s3_bucket_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import (
"strings"
"time"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
)

func resourceAwsS3BucketMetric() *schema.Resource {
Expand Down Expand Up @@ -62,7 +61,9 @@ func resourceAwsS3BucketMetricPut(d *schema.ResourceData, meta interface{}) erro
}

if v, ok := d.GetOk("filter"); ok {
metricsConfiguration.Filter = expandS3MetricsFilter(v.([]interface{})[0].(map[string]interface{}))
filterList := v.([]interface{})
filterMap := filterList[0].(map[string]interface{})
metricsConfiguration.Filter = expandS3MetricsFilter(filterMap)
}

input := &s3.PutBucketMetricsConfigurationInput{
Expand Down

1 comment on commit 58fed40

@michaelm-88
Copy link

@michaelm-88 michaelm-88 commented on 58fed40 Jul 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @bflad
could you provide me an example pls , when I trying I am getting the below error

each.value.metric_prefix is tuple with 1 element
Inappropriate value for attribute "prefix": string required


resource "aws_s3_bucket_metric" "bucket_metric" {
  for_each = { for key, bucket in var.buckets :
    key => bucket
    if bucket.metric_enabled && bucket.create
  }

  bucket = each.key
  name   = each.value.metric_prefix

  filter {
    prefix = each.value.metric_prefix
  }
}
    
  variable "buckets" {
  type = any
  default = {}
}

the variables 

    bucket-folders = {
      create = true

      metric_enabled = true
      metric_prefix = [
        "folder-1"
      ]
    
    }

Please sign in to comment.