hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.8k stars 9.15k forks source link

[Bug]: aws_appflow_flow fails when deleting or modifying a task #28237

Closed ikaila closed 11 months ago

ikaila commented 1 year ago

Terraform Core Version

1.3.6

AWS Provider Version

v4.37.0

Affected Resource(s)

aws_appflow_flow

Expected Behavior

when deleting/modifying the configuration for an appflow field, the field should be successfully deleted/updated.

Actual Behavior

terraform gives an error

Relevant Error/Panic Output Snippet

Error: updating AppFlow Flow (arn:aws:appflow:us-east-1:[account-id]:flow/test-flow): InvalidParameter: 2 validation error(s) found.
│ - missing required field, UpdateFlowInput.Tasks[0].SourceFields.
│ - missing required field, UpdateFlowInput.Tasks[0].TaskType.
│ 
│ 
│   with aws_appflow_flow.test_flow,
│   on appflow-test.tf line 1, in resource "aws_appflow_flow" "test_flow":
│    1: resource "aws_appflow_flow" "test_flow" {

Terraform Configuration Files

resource "aws_appflow_flow" "test_flow" {
  name     = "test-flow"
  source_flow_config {
    connector_profile_name = "salesforce-connection"
    connector_type         = "Salesforce"
    source_connector_properties {
      salesforce {
        enable_dynamic_field_update = false
        include_deleted_records     = false
        object                      = "AccountChangeEvent"
      }
    }
  }
  destination_flow_config {
    connector_type         = "EventBridge"
    destination_connector_properties {
      event_bridge {
        error_handling_config {
          bucket_name                     = "some-bucket"
          bucket_prefix                   = ""
          fail_on_first_destination_error = false
        }
        object = "aws.partner/appflow/salesforce.com/${account-id}"
      }
    }
  }

  dynamic "task" {
    for_each = local.appflow_test_task_map
    content {
      connector_operator { salesforce = task.value.connector_operator }
      source_fields     = task.value.source_fields
      destination_field = try(task.value.destination_field, "")
      task_type         = task.value.task_type
      task_properties   = task.value.task_properties
    }
  }

  trigger_config {
    trigger_type = "Event"
  }
}

locals {
  appflow_test_task_map = [
    {
      source_fields = [
        "Id",
        "ReplayId"
      ],
      connector_operator = "PROJECTION"
      task_type          = "Filter"
      task_properties    = null
    },
    {
      source_fields = [
        "Id"
      ],
      connector_operator = "NO_OP",
      destination_field  = "Id",
      task_type          = "Map",
      task_properties = {
        "DESTINATION_DATA_TYPE" = "id"
        "SOURCE_DATA_TYPE"      = "id"
      }
    },
    {
      source_fields = [
        "ReplayId"
      ],
      connector_operator = "NO_OP",
      destination_field  = "ReplayId",
      task_type          = "Map",
      task_properties = {
        "DESTINATION_DATA_TYPE" = "string"
        "SOURCE_DATA_TYPE"      = "string"
      }
    },
    ]
}

Steps to Reproduce

  1. create a flow with multiple fields like in the above example with terraform apply
  2. delete one field, for example so the task map becomes like so
    appflow_test_task_map = [
    {
      source_fields = [
        "Id"
      ],
      connector_operator = "PROJECTION"
      task_type          = "Filter"
      task_properties    = null
    },
    {
      source_fields = [
        "Id"
      ],
      connector_operator = "NO_OP",
      destination_field  = "Id",
      task_type          = "Map",
      task_properties = {
        "DESTINATION_DATA_TYPE" = "id"
        "SOURCE_DATA_TYPE"      = "id"
      }
    }
    ]
  3. do terraform apply
  4. get error

the same error can be found if an existing field is modified, for example

appflow_test_task_map = [
    {
      source_fields = [
        "Id",
        "ReplayId"
      ],
      connector_operator = "PROJECTION"
      task_type          = "Filter"
      task_properties    = null
    },
    {
      source_fields = [
        "Id"
      ],
      connector_operator = "NO_OP",
      destination_field  = "Id",
      task_type          = "Map",
      task_properties = {
        "DESTINATION_DATA_TYPE" = "id"
        "SOURCE_DATA_TYPE"      = "id"
      }
    },
    {
      source_fields = [
        "ReplayId"
      ],
      connector_operator = "NO_OP",
      destination_field  = "ReplayId",              ->          "ReplayId-name-change"
      task_type          = "Map",
      task_properties = {
        "DESTINATION_DATA_TYPE" = "string"
        "SOURCE_DATA_TYPE"      = "string"
      }
    },
    ]

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

denisgaina commented 1 year ago

We face the same error with AWS provider version v4.45.0.

ruizcamilo commented 1 year ago

We are facing the same issue with AWS provider version 4.46.0. The plan is showing that it will create two different destination_flow_config. One of them is empty which is what is causing the error. Is this a bug in the latest released version of the resource?


      + destination_flow_config {

          + connector_type = "S3"

          + destination_connector_properties {

              + s3 {
                  + bucket_name = "dev-dynamic-boost-salesforce-deleted-records"

                  + s3_output_format_config {
                      + file_type = "JSON"

                      + aggregation_config {
                          + aggregation_type = "SingleFile"
                        }
                    }
                }
            }
        }
      + destination_flow_config {
       }
tbarle commented 11 months ago

We face always the same error with AWS provider version v5.23.1.

ewbankkit commented 11 months ago

Relates https://github.com/hashicorp/terraform-plugin-sdk/issues/588.

tusharpandit18 commented 10 months ago

when do you think v5.27.0 will be released and available?

github-actions[bot] commented 10 months ago

This functionality has been released in v5.27.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] commented 9 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.