Skip to content

Commit

Permalink
Merge pull request #26240 from johnr-odusa/b-aws_appflow_flow_trigger…
Browse files Browse the repository at this point in the history
…-config

B aws appflow flow trigger config
  • Loading branch information
ewbankkit authored Aug 11, 2022
2 parents 7c0122e + dbf3ea0 commit a5488d9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .changelog/26240.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_appflow_flow: Fix `trigger_properties.schedule` being set to `trigger_properties.trigger_properties` during resource read
```
2 changes: 1 addition & 1 deletion internal/service/appflow/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -3537,7 +3537,7 @@ func flattenTriggerProperties(triggerProperties *appflow.TriggerProperties) map[
m := map[string]interface{}{}

if v := triggerProperties.Scheduled; v != nil {
m["trigger_properties"] = []interface{}{flattenScheduled(v)}
m["scheduled"] = []interface{}{flattenScheduled(v)}
}

return m
Expand Down
31 changes: 21 additions & 10 deletions internal/service/appflow/flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestAccAppFlowFlow_basic(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccFlowConfig_basic(rSourceName, rDestinationName, rFlowName),
Check: resource.ComposeTestCheckFunc(
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckFlowExists(resourceName, &flowOutput),
acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appflow", regexp.MustCompile(`flow/.+`)),
resource.TestCheckResourceAttr(resourceName, "name", rFlowName),
Expand All @@ -44,8 +44,12 @@ func TestAccAppFlowFlow_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "task.#"),
resource.TestCheckResourceAttrSet(resourceName, "task.0.source_fields.#"),
resource.TestCheckResourceAttrSet(resourceName, "task.0.task_type"),
resource.TestCheckResourceAttrSet(resourceName, "trigger_config.#"),
resource.TestCheckResourceAttrSet(resourceName, "trigger_config.0.trigger_type"),
resource.TestCheckResourceAttr(resourceName, "trigger_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "trigger_config.0.trigger_type", "Scheduled"),
resource.TestCheckResourceAttr(resourceName, "trigger_config.0.trigger_properties.#", "1"),
resource.TestCheckResourceAttr(resourceName, "trigger_config.0.trigger_properties.0.scheduled.#", "1"),
resource.TestCheckResourceAttr(resourceName, "trigger_config.0.trigger_properties.0.scheduled.0.data_pull_mode", "Complete"),
resource.TestCheckResourceAttr(resourceName, "trigger_config.0.trigger_properties.0.scheduled.0.schedule_expression", "rate(5minutes)"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "tags_all.%", "0"),
),
Expand Down Expand Up @@ -188,7 +192,7 @@ func TestAccAppFlowFlow_disappears(t *testing.T) {
})
}

func testAccConfigFlowBase(rSourceName string, rDestinationName string) string {
func testAccFlowConfig_base(rSourceName string, rDestinationName string) string {
return fmt.Sprintf(`
data "aws_partition" "current" {}
Expand Down Expand Up @@ -267,7 +271,7 @@ EOF

func testAccFlowConfig_basic(rSourceName string, rDestinationName string, rFlowName string) string {
return acctest.ConfigCompose(
testAccConfigFlowBase(rSourceName, rDestinationName),
testAccFlowConfig_base(rSourceName, rDestinationName),
fmt.Sprintf(`
resource "aws_appflow_flow" "test" {
name = %[3]q
Expand Down Expand Up @@ -308,7 +312,14 @@ resource "aws_appflow_flow" "test" {
}
trigger_config {
trigger_type = "OnDemand"
trigger_type = "Scheduled"
trigger_properties {
scheduled {
data_pull_mode = "Complete"
schedule_expression = "rate(5minutes)"
}
}
}
}
`, rSourceName, rDestinationName, rFlowName),
Expand All @@ -317,7 +328,7 @@ resource "aws_appflow_flow" "test" {

func testAccFlowConfig_update(rSourceName string, rDestinationName string, rFlowName string, description string) string {
return acctest.ConfigCompose(
testAccConfigFlowBase(rSourceName, rDestinationName),
testAccFlowConfig_base(rSourceName, rDestinationName),
fmt.Sprintf(`
resource "aws_appflow_flow" "test" {
name = %[3]q
Expand Down Expand Up @@ -368,7 +379,7 @@ resource "aws_appflow_flow" "test" {

func testAccFlowConfig_taskProperties(rSourceName string, rDestinationName string, rFlowName string) string {
return acctest.ConfigCompose(
testAccConfigFlowBase(rSourceName, rDestinationName),
testAccFlowConfig_base(rSourceName, rDestinationName),
fmt.Sprintf(`
resource "aws_appflow_flow" "test" {
name = %[3]q
Expand Down Expand Up @@ -423,7 +434,7 @@ resource "aws_appflow_flow" "test" {

func testAccFlowConfig_tags1(rSourceName string, rDestinationName string, rFlowName string, tagKey1 string, tagValue1 string) string {
return acctest.ConfigCompose(
testAccConfigFlowBase(rSourceName, rDestinationName),
testAccFlowConfig_base(rSourceName, rDestinationName),
fmt.Sprintf(`
resource "aws_appflow_flow" "test" {
name = %[3]q
Expand Down Expand Up @@ -477,7 +488,7 @@ resource "aws_appflow_flow" "test" {

func testAccFlowConfig_tags2(rSourceName string, rDestinationName string, rFlowName string, tagKey1 string, tagValue1 string, tagKey2 string, tagValue2 string) string {
return acctest.ConfigCompose(
testAccConfigFlowBase(rSourceName, rDestinationName),
testAccFlowConfig_base(rSourceName, rDestinationName),
fmt.Sprintf(`
resource "aws_appflow_flow" "test" {
name = %[3]q
Expand Down

0 comments on commit a5488d9

Please sign in to comment.