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

B aws appflow flow trigger config #26240

Merged
merged 6 commits into from Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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