Skip to content

Commit

Permalink
Merge pull request #34948 from tusharpandit18/flow_status
Browse files Browse the repository at this point in the history
Flow status
  • Loading branch information
ewbankkit authored Jan 25, 2024
2 parents 9c5ceb8 + 446f388 commit 0067d5c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .changelog/34948.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_appflow_flow: Add `flow_status` attribute
```
21 changes: 11 additions & 10 deletions internal/service/appflow/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ import (
"github.com/hashicorp/terraform-provider-aws/names"
)

const (
AttrObjectPath = "object_path"
)

// @SDKResource("aws_appflow_flow", name="Flow")
// @Tags(identifierAttribute="id")
func resourceFlow() *schema.Resource {
Expand Down Expand Up @@ -497,7 +493,7 @@ func resourceFlow() *schema.Resource {
ValidateFunc: validation.All(validation.StringMatch(regexache.MustCompile(`\S+`), "must not contain any whitespace characters"), validation.StringLenBetween(0, 128)),
},
},
AttrObjectPath: {
"object_path": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.All(validation.StringMatch(regexache.MustCompile(`\S+`), "must not contain any whitespace characters"), validation.StringLenBetween(1, 512)),
Expand Down Expand Up @@ -698,6 +694,10 @@ func resourceFlow() *schema.Resource {
},
},
},
"flow_status": {
Type: schema.TypeString,
Computed: true,
},
"kms_arn": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -926,7 +926,7 @@ func resourceFlow() *schema.Resource {
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
AttrObjectPath: {
"object_path": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.All(validation.StringMatch(regexache.MustCompile(`\S+`), "must not contain any whitespace characters"), validation.StringLenBetween(1, 512)),
Expand Down Expand Up @@ -1301,6 +1301,7 @@ func resourceFlowRead(ctx context.Context, d *schema.ResourceData, meta interfac
if err := d.Set("destination_flow_config", flattenDestinationFlowConfigs(output.DestinationFlowConfigList)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting destination_flow_config: %s", err)
}
d.Set("flow_status", output.FlowStatus)
d.Set("kms_arn", output.KmsArn)
d.Set(names.AttrName, output.FlowName)
if output.SourceFlowConfig != nil {
Expand Down Expand Up @@ -1875,7 +1876,7 @@ func expandSAPODataDestinationProperties(tfMap map[string]interface{}) *types.SA
a.IdFieldNames = flex.ExpandStringValueList(v)
}

if v, ok := tfMap[AttrObjectPath].(string); ok && v != "" {
if v, ok := tfMap["object_path"].(string); ok && v != "" {
a.ObjectPath = aws.String(v)
}

Expand Down Expand Up @@ -2289,7 +2290,7 @@ func expandSAPODataSourceProperties(tfMap map[string]interface{}) *types.SAPODat

a := &types.SAPODataSourceProperties{}

if v, ok := tfMap[AttrObjectPath].(string); ok && v != "" {
if v, ok := tfMap["object_path"].(string); ok && v != "" {
a.ObjectPath = aws.String(v)
}

Expand Down Expand Up @@ -2961,7 +2962,7 @@ func flattenSAPODataDestinationProperties(SAPODataDestinationProperties *types.S
}

if v := SAPODataDestinationProperties.ObjectPath; v != nil {
m[AttrObjectPath] = aws.ToString(v)
m["object_path"] = aws.ToString(v)
}

if v := SAPODataDestinationProperties.SuccessResponseHandlingConfig; v != nil {
Expand Down Expand Up @@ -3360,7 +3361,7 @@ func flattenSAPODataSourceProperties(sapoDataSourceProperties *types.SAPODataSou
m := map[string]interface{}{}

if v := sapoDataSourceProperties.ObjectPath; v != nil {
m[AttrObjectPath] = aws.ToString(v)
m["object_path"] = aws.ToString(v)
}

return m
Expand Down
4 changes: 2 additions & 2 deletions internal/service/appflow/flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ func TestAccAppFlowFlow_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "destination_flow_config.#"),
resource.TestCheckResourceAttrSet(resourceName, "destination_flow_config.0.connector_type"),
resource.TestCheckResourceAttrSet(resourceName, "destination_flow_config.0.destination_connector_properties.#"),
resource.TestCheckResourceAttrSet(resourceName, "flow_status"),
resource.TestCheckResourceAttrSet(resourceName, "source_flow_config.#"),
resource.TestCheckResourceAttrSet(resourceName, "source_flow_config.0.connector_type"),
resource.TestCheckResourceAttrSet(resourceName, "source_flow_config.0.source_connector_properties.#"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttrSet(resourceName, "task.#"),
resource.TestCheckResourceAttrSet(resourceName, "task.0.source_fields.#"),
resource.TestCheckResourceAttrSet(resourceName, "task.0.task_type"),
Expand All @@ -58,8 +60,6 @@ func TestAccAppFlowFlow_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "trigger_config.0.trigger_properties.0.scheduled.0.data_pull_mode", "Incremental"),
resource.TestCheckResourceAttr(resourceName, "trigger_config.0.trigger_properties.0.scheduled.0.schedule_expression", "rate(3hours)"),
resource.TestCheckResourceAttr(resourceName, "trigger_config.0.trigger_properties.0.scheduled.0.schedule_start_time", scheduleStartTime),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "tags_all.%", "0"),
),
},
{
Expand Down
1 change: 1 addition & 0 deletions website/docs/cdktf/python/r/appflow_flow.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ This resource supports the following arguments:
* `kms_arn` - (Optional) ARN (Amazon Resource Name) of the Key Management Service (KMS) key you provide for encryption. This is required if you do not want to use the Amazon AppFlow-managed KMS key. If you don't provide anything here, Amazon AppFlow uses the Amazon AppFlow-managed KMS key.
* `tags` - (Optional) Key-value mapping of resource tags. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
* `tags_all` - Map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block).
* `flow_status` - (Optional) Set the status of the flow ([`could be Active, Suspended, Draft` https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appflow-flow.html ] )

### Destination Flow Config

Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/appflow_flow.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ This resource supports the following arguments:
* `description` - (Optional) Description of the flow you want to create.
* `kms_arn` - (Optional) ARN (Amazon Resource Name) of the Key Management Service (KMS) key you provide for encryption. This is required if you do not want to use the Amazon AppFlow-managed KMS key. If you don't provide anything here, Amazon AppFlow uses the Amazon AppFlow-managed KMS key.
* `tags` - (Optional) Key-value mapping of resource tags. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
* `tags_all` - Map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block).

### Destination Flow Config

Expand Down Expand Up @@ -397,6 +396,8 @@ resource "aws_appflow_flow" "example" {
This resource exports the following attributes in addition to the arguments above:

* `arn` - Flow's ARN.
* `flow_status` - The current status of the flow.
* `tags_all` - Map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block).

## Import

Expand Down

0 comments on commit 0067d5c

Please sign in to comment.