aws-samples / aws2tf

aws2tf - automates the importing of existing AWS resources into Terraform and outputs the Terraform HCL code.
MIT No Attribution
587 stars 102 forks source link

Error: Not enough list items with aws_cloudtrail.s3events #28

Closed gregbouwens closed 1 year ago

gregbouwens commented 1 year ago

Hi, I just pulled this repo and ran it on a sandbox account without making any changes to your code. I got a bunch of these errors on both line 14 and line 41:

Error: Not enough list items │ │ with aws_cloudtrail.s3events, │ on aws_cloudtrail__s3events.tf line 14, in resource "aws_cloudtrail" "s3events": │ 14: advanced_event_selector { │ │ Attribute advanced_event_selector.0.field_selector.0.starts_with requires 1 item minimum, but config has only 0 declared.

 File generated by aws2tf see https://github.com/aws-samples/aws2tf

aws_cloudtrail.s3events:

resource "aws_cloudtrail" "s3events" { enable_log_file_validation = true enable_logging = true include_global_service_events = true is_multi_region_trail = true is_organization_trail = false name = "s3events" s3_bucket_name = aws_s3_bucket.b_aws-cloudtrail-logs-"awsaccountnumber"-54acd01e.bucket tags = {} tags_all = {}

advanced_event_selector { field_selector { ends_with = [] equals = [ "AWS::S3::Object", ] field = "resources.type" not_ends_with = [] not_equals = [] not_starts_with = [] starts_with = [] } field_selector { ends_with = [] equals = [ "Data", ] field = "eventCategory" not_ends_with = [] not_equals = [] not_starts_with = [] starts_with = [] } } advanced_event_selector { name = "Management events selector"

field_selector {
  ends_with = []
  equals = [
    "Management",
  ]
  field           = "eventCategory"
  not_ends_with   = []
  not_equals      = []
  not_starts_with = []
  starts_with     = []
}

} }

awsandy commented 1 year ago

committed changes that should fix this

awsandy commented 1 year ago

There's now also a cloud trail filter: aws2tf.sh -t cloudtrail