Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform is recreating Appflow Flow #317

Closed
juanforo opened this issue Dec 7, 2021 · 2 comments · Fixed by #306
Closed

Terraform is recreating Appflow Flow #317

juanforo opened this issue Dec 7, 2021 · 2 comments · Fixed by #306
Labels
bug upstream-plugin-framework Unable to proceed due to missing or broken functionality from terraform-plugin-framework

Comments

@juanforo
Copy link

juanforo commented Dec 7, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • The resources and data sources in this provider are generated from the CloudFormation schema, so they can only support the actions that the underlying schema supports. For this reason submitted bugs should be limited to defects in the generation and runtime code of the provider. Customizing behavior of the resource, or noting a gap in behavior are not valid bugs and should be submitted as enhancements to AWS via the Cloudformation Open Coverage Roadmap.

Terraform CLI and Terraform AWS Cloud Control Provider Version

Terraform v1.0.11
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.52.0
+ provider registry.terraform.io/hashicorp/awscc v0.8.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/mongodb/mongodbatlas v1.0.1

Affected Resource(s)

  • awscc_appflow_flow

Terraform Configuration Files

resource "awscc_appflow_flow" "flow" {
  provider  = awscc.target
  flow_name = var.appflow_flow_name
  kms_arn   = var.kms_arn
  source_flow_config = {
    connector_profile_name = var.source_flow_config.connector_profile_name
    connector_type         = var.source_flow_config.connector_type
    source_connector_properties = {
      salesforce = {
        enable_dynamic_field_update = var.source_flow_config.enable_dynamic_field_update
        include_deleted_records     = var.source_flow_config.include_deleted_records
        object                      = var.source_flow_config.object
      }
    }
  }
  destination_flow_config_list = [
    {
      connector_profile_name = var.destination_flow_config.connector_profile_name
      connector_type         = var.destination_flow_config.connector_type
      destination_connector_properties = {
        event_bridge = {
          error_handling_config = {
            bucket_name         = var.destination_flow_config.bucket_name
            bucket_prefix       = var.destination_flow_config.bucket_prefix
            fail_on_first_error = var.destination_flow_config.fail_on_first_error
          }
          object = "aws.partner/appflow/salesforce.com/${var.account_id}"
        }
      }
    }
  ]

  tasks = local.task_map_list

  trigger_config = {
    trigger_type = var.trigger_type
  }

  lifecycle {
    ignore_changes = [kms_arn]
  }
}

Expected Behavior

After successful creation, no changes should appear when creating a plan

No changes. Your infrastructure matches the configuration.

Actual Behavior

Every time when I run a plan or apply terraform is re-creating the resource stating changes in KMS. Even though nothing changed.

When creating for the first time:

# module.dev_infra.module.appflow.awscc_appflow_flow.flow will be created
  + resource "awscc_appflow_flow" "flow" {
      + destination_flow_config_list = [
          + {
            + connector_profile_name           = "b360-dev-salesforce-connection"
            + connector_type                   = "EventBridge"
            + destination_connector_properties = {
              + event_bridge = {
                + error_handling_config = {
                  + bucket_name         = "b360-dev-salesforce-s3"
                  + fail_on_first_error = false
                }
                + object                = "aws.partner/appflow/salesforce.com/231054047818"
              }
            }
          },
        ]
      + flow_arn                     = (known after apply)
      + flow_name                    = "dev-salesforce-flow"
      + id                           = (known after apply)
      + kms_arn                      = "arn:aws:kms:us-east-1:231054047818:key/mrk-e3c66ad25ba846ccb06efe54df472745"
      + source_flow_config           = {
        + connector_profile_name      = "b360-dev-salesforce-connection"
        + connector_type              = "Salesforce"
        + source_connector_properties = {
          + salesforce = {
            + enable_dynamic_field_update = false
            + include_deleted_records     = false
            + object                      = "AccountChangeEvent"
          }
        }
      }
      + tasks                        = [
          + {
            + connector_operator = {
              + salesforce = "PROJECTION"
            }
            + source_fields      = [
                + "Id",
                + "ReplayId",
                + "ChangeEventHeader",
                + "Name",
                + "LastName",
                + "FirstName",
                + "Salutation",
                + "MiddleName",
                + "Suffix",
                + "Type",
                + "RecordTypeId",
                + "ParentId",
                + "BillingStreet",
                + "BillingCity",
                + "BillingState",
                + "BillingPostalCode",
                + "BillingCountry",
                + "BillingLatitude",
                + "BillingLongitude",
                + "BillingGeocodeAccuracy",
                + "BillingAddress",
                + "ShippingStreet",
                + "ShippingCity",
                + "ShippingState",
                + "ShippingPostalCode",
                + "ShippingCountry",
                + "ShippingLatitude",
                + "ShippingLongitude",
                + "ShippingGeocodeAccuracy",
                + "ShippingAddress",
                + "Phone",
                + "Website",
                + "Industry",
                + "NumberOfEmployees",
                + "Description",
                + "OwnerId",
                + "CreatedDate",
                + "CreatedById",
                + "LastModifiedDate",
                + "LastModifiedById",
                + "Jigsaw",
                + "JigsawCompanyId",
                + "AccountSource",
                + "SicDesc",
                + "Status__c",
                + "Last_Owner_Change_Date__c",
              ]
            + task_type          = "Filter"

            + connector_operator = {
              + salesforce = "NO_OP"
            }
            + destination_field  = "Id"
            + source_fields      = [
                + "Id",
              ]
            + task_properties    = [
                + {
                  + key   = "DESTINATION_DATA_TYPE"
                  + value = "string"

                  + key   = "SOURCE_DATA_TYPE"
                  + value = "string"
                },
              ]
            + task_type          = "Map"

            + connector_operator = {
              + salesforce = "NO_OP"
            }
            + destination_field  = "ReplayId"
            + source_fields      = [
                + "ReplayId",
              ]
            + task_properties    = [
                + {
                  + key   = "DESTINATION_DATA_TYPE"
                  + value = "string"

                  + key   = "SOURCE_DATA_TYPE"
                  + value = "string"
                },
              ]
            + task_type          = "Map"
          },
        ]
      + trigger_config               = {
        + trigger_type = "Event"
      }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

A consecutive plan:

terraform plan
  # module.appflow.awscc_appflow_flow.flow must be replaced
-/+ resource "awscc_appflow_flow" "flow" {
      ~ destination_flow_config_list = [
          ~ {
            ~ destination_connector_properties = {
              ~ event_bridge = {
                ~ error_handling_config = {
                    # (2 unchanged attributes hidden)
                }
                ~ object                = "aws.partner/appflow/salesforce.com/524501426365/aws.partner/appflow/salesforce.com/231054047818" -> "aws.partner/appflow/salesforce.com/231054047818"
              }
            }
              # (2 unchanged attributes hidden)
          },
        ]
      + flow_arn                     = (known after apply)
      ~ id                           = "snd-salesforce-flow" -> (known after apply)
      + kms_arn                      = "arn:aws:kms:us-east-1:524501426365:key/mrk-fa554d67dd074b2798dcab59bf355414" # forces replacement
      ~ source_flow_config           = {
        - incremental_pull_config     = {
        }
          # (3 unchanged attributes hidden)
      }
      ~ tasks                        = [
          ~ {
              # (3 unchanged attributes hidden)
          },
          # (2 unchanged elements hidden)
        ]
        # (2 unchanged attributes hidden)
    }

Steps to Reproduce

  1. terraform plan
  2. terraform apply

References

@nicoodle
Copy link

nicoodle commented Dec 8, 2021

Hi @juanforo, would you be able to share the value of local.task_map_list?

@ewbankkit ewbankkit added bug upstream-plugin-framework Unable to proceed due to missing or broken functionality from terraform-plugin-framework labels Dec 8, 2021
@juanforo
Copy link
Author

juanforo commented Dec 9, 2021

Hi @nicoodle

Sure! Below you will find the value of that local expression.

locals {
  task_map = { for index in range(length(var.tasks)) :
    "task-${index}" => {
      connector_operator = { "salesforce" = var.tasks[index].connector_operator }
      source_fields      = try(var.tasks[index].source_fields)
      destination_field  = try(var.tasks[index].destination_field, "")
      task_type          = try(var.tasks[index].task_type)
      task_properties    = try(var.tasks[index].task_properties)
    }
  }
  task_map_list = [for k, v in local.task_map : v]
}

These are the values of the variables

appflow_flow_name = "my-flow"
kms_arn           = "arn:aws:kms:us-east-1:xxxxxxx:key/xxxxxxxxx"
source_flow_config = {
  connector_profile_name      = "my-salesforce-connection"
  connector_type              = "Salesforce"
  enable_dynamic_field_update = false
  include_deleted_records     = false
  object                      = "AccountChangeEvent"
}
destination_flow_config = {
  connector_profile_name = "my-salesforce-connection"
  connector_type         = "EventBridge"
  bucket_name            = "my-salesforce-bucket"
  bucket_prefix          = ""
  fail_on_first_error    = false
}
trigger_type = "Event"

task_map = [
  {
    source_fields = [
      "Id",
      "ReplayId",
      "ChangeEventHeader",
      "Name",
      "LastName",
      "FirstName",
      "Salutation",
      "MiddleName",
      "Suffix",
      "Type",
      "RecordTypeId",
      "ParentId",
      "BillingStreet",
      "BillingCity",
      "BillingState",
      "BillingPostalCode",
      "BillingCountry",
      "BillingLatitude",
      "BillingLongitude",
      "BillingGeocodeAccuracy",
      "BillingAddress",
      "ShippingStreet",
      "ShippingCity",
      "ShippingState",
      "ShippingPostalCode",
      "ShippingCountry",
      "ShippingLatitude",
      "ShippingLongitude",
      "ShippingGeocodeAccuracy",
      "ShippingAddress",
      "Phone",
      "Website",
      "Industry",
      "NumberOfEmployees",
      "Description",
      "OwnerId",
      "CreatedDate",
      "CreatedById",
      "LastModifiedDate",
      "LastModifiedById",
      "Jigsaw",
      "JigsawCompanyId",
      "AccountSource",
      "SicDesc",
      "Status__c",
      "Last_Owner_Change_Date__c"
    ],
    connector_operator = "PROJECTION"
    task_type          = "Filter"
    task_properties    = null
  },
  {
    source_fields      = ["Id"]
    connector_operator = "NO_OP"
    destination_field  = "Id"
    task_type          = "Map"
    task_properties = [{
      key   = "DESTINATION_DATA_TYPE",
      value = "string"
      },
      {
        key   = "SOURCE_DATA_TYPE",
        value = "string"
      }
    ]
  },
  {
    source_fields      = ["ReplayId"]
    connector_operator = "NO_OP"
    destination_field  = "ReplayId"
    task_type          = "Map"
    task_properties = [{
      key   = "DESTINATION_DATA_TYPE",
      value = "string"
      },
      {
        key   = "SOURCE_DATA_TYPE",
        value = "string"
      }
    ]
  }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug upstream-plugin-framework Unable to proceed due to missing or broken functionality from terraform-plugin-framework
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants