hashicorp / terraform-provider-awscc

Terraform AWS Cloud Control provider
https://registry.terraform.io/providers/hashicorp/awscc/latest/docs
Mozilla Public License 2.0
258 stars 117 forks source link

awscc_appflow_flow does not recognize empty list of string in source_fields when doing map_all operation #847

Open yzouyang opened 1 year ago

yzouyang commented 1 year ago

Community Note

Terraform CLI and Terraform AWS Cloud Control Provider Version

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "awscc_appflow_flow" "test-facebook-ads-flow-terraform" {
  flow_name = "test-facebook-flow-terraform"
  destination_flow_config_list = [{
    connector_type = "S3"
    destination_connector_properties = {
      s3 = {
        bucket_name   = "aws-appflow-resource"
        bucket_prefix = "facebook-test-terraform"
        s3_output_format_config = {
          aggregation_config = {
            aggregation_type = "SingleFile"
          }
          file_type = "CSV"
          prefix_config = {
            prefix_format = "DAY"
            prefix_type   = "PATH"
          }
        }
      }
    }
  }]
  source_flow_config = {
    api_version            = "v15.0"
    connector_type         = "CustomConnector"
    connector_profile_name = "appflow-facebook-ad-connection"
    source_connector_properties = {
      custom_connector = {
        entity_name = "act_masked/ads"
      }
    }
  }
  trigger_config = {
    trigger_type = "OnDemand"
  }
  tasks = [{
    connector_operator = {
      custom_connector = "NO_OP"
    }
    source_fields = []
    task_type     = "Map_all"
    task_properties = [
      {
        key   = "EXCLUDE_SOURCE_FIELDS_LIST"
        value = "[]"
      }
    ]
    write_operation_type = "INSERT"
  }]
}

Debug Output

ValidationException: Model validation failed (#/Tasks/0: required key [SourceFields] not found)

Panic Output

Expected Behavior

On-demand flow created

Actual Behavior

Creation failed

Steps to Reproduce

  1. Set up a test connection profile "appflow-facebook-ad-connection" for Facebook Ads source connector with access to the 'ads' endpoint for a particular Facebook account (masked)
  2. terraform apply

Important Factoids

References

bpicolo commented 9 months ago

This may stem from https://github.com/hashicorp/terraform-provider-awscc/issues/700 ?

Some AWS resource creation APIs have non-optional list fields. Empty list is a valid input, but null or a missing JSON key are not. These don't seem to function with terraform-provider-awscc today when an empty list is passed as input, because it's being converted to null. (Or rather, the key doesn't seem to be present in the API call at all from what I see setting TF_LOG=debug)

rofreytag commented 4 months ago

Truly frustrating. I moved to awscc to fix a bunch of issues with appflow, as they are not supported well with aws provider, but ran into this exact issue. Wonder if other APIs are affected by this?