[terraform] CloudTrail 管理イベント/データイベント

管理イベント/データイベントを設定したCloudTrailをimportして、整形してplanすると、エラーがでる

```terraform:main.tf
resource "aws_cloudtrail" "cloudtrail" {
    enable_log_file_validation    = false
    enable_logging                = true
    include_global_service_events = true
    is_multi_region_trail         = true
    is_organization_trail         = false
    name                          = "TRAIL"
    s3_bucket_name                = "TRAIL-123456789012"
    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 = "管理イベントセレクター"

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

```terminal:terraform plan
│ Error: Invalid or unknown key
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 4, in resource "aws_cloudtrail" "cloudtrail":
│    4:     id                            = "TRAIL"
│
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 13, in resource "aws_cloudtrail" "cloudtrail":
│   13:     advanced_event_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 13, in resource "aws_cloudtrail" "cloudtrail":
│   13:     advanced_event_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 13, in resource "aws_cloudtrail" "cloudtrail":
│   13:     advanced_event_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 13, in resource "aws_cloudtrail" "cloudtrail":
│   13:     advanced_event_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 13, in resource "aws_cloudtrail" "cloudtrail":
│   13:     advanced_event_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 13, in resource "aws_cloudtrail" "cloudtrail":
│   13:     advanced_event_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 13, in resource "aws_cloudtrail" "cloudtrail":
│   13:     advanced_event_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 13, in resource "aws_cloudtrail" "cloudtrail":
│   13:     advanced_event_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 13, in resource "aws_cloudtrail" "cloudtrail":
│   13:     advanced_event_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 13, in resource "aws_cloudtrail" "cloudtrail":
│   13:     advanced_event_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 40, in resource "aws_cloudtrail" "cloudtrail":
│   40:         field_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 40, in resource "aws_cloudtrail" "cloudtrail":
│   40:         field_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 40, in resource "aws_cloudtrail" "cloudtrail":
│   40:         field_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 40, in resource "aws_cloudtrail" "cloudtrail":
│   40:         field_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
╷
│ Error: Not enough list items
│
│   with aws_cloudtrail.cloudtrail,
│   on main.tf line 40, in resource "aws_cloudtrail" "cloudtrail":
│   40:         field_selector {
│
│ Attribute requires 1 item minimum, but config has only 0 declared.
╵
```

結論、field_selectorのequals, field以外(end_with, not*, starts_with)をコメントアウトする。

```terraform:main.tf(修正後)
resource "aws_cloudtrail" "cloudtrail" {
    enable_log_file_validation    = false
    enable_logging                = true
    include_global_service_events = true
    is_multi_region_trail         = true
    is_organization_trail         = false
    name                          = "TRAIL"
    s3_bucket_name                = "TRAIL-123456789012"
    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 = "管理イベントセレクター"

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

[terraformのリファレンス](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudtrail)から、[AdvancedFieldSelectorのAPIリファレンス](https://docs.aws.amazon.com/ja_jp/awscloudtrail/latest/APIReference/API_AdvancedFieldSelector.html)を見ると書いてあった

> **NotEndsWith**

> Array Members: Minimum number of 1 item.