Skip to content

Commit

Permalink
r/aws_appflow_flow: 'flow_status' is Computed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Jan 25, 2024
1 parent 503402d commit 446f388
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
26 changes: 11 additions & 15 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,18 +694,17 @@ func resourceFlow() *schema.Resource {
},
},
},
"flow_status": {
Type: schema.TypeString,
Computed: true,
},
"kms_arn": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(regexache.MustCompile(`arn:.*:kms:.*:[0-9]+:.*`), "must be a valid ARN of a Key Management Services (KMS) key"),
},
"flow_status": {
Type: schema.TypeString,
Optional: true,
ValidateDiagFunc: enum.Validate[types.FlowStatus](),
},
names.AttrName: {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -931,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 @@ -1306,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 @@ -1880,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 @@ -2294,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 @@ -2966,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 @@ -3365,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
4 changes: 2 additions & 2 deletions website/docs/r/appflow_flow.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +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).
* `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 Expand Up @@ -398,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 446f388

Please sign in to comment.