From 58f1837fd79b40390f79a0e5b2602a059c9e61c3 Mon Sep 17 00:00:00 2001 From: Nick Hankins Date: Thu, 16 May 2024 11:59:41 -0400 Subject: [PATCH 01/10] add glue integration and prefix_hierarchy --- internal/service/appflow/flow.go | 108 ++++++++++++++++++++++++ internal/service/appflow/flow_test.go | 116 +++++++++++++++++++++++++- 2 files changed, 223 insertions(+), 1 deletion(-) diff --git a/internal/service/appflow/flow.go b/internal/service/appflow/flow.go index 937f008aff52..1fd72322d119 100644 --- a/internal/service/appflow/flow.go +++ b/internal/service/appflow/flow.go @@ -383,6 +383,14 @@ func resourceFlow() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "prefix_hierarchy": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateDiagFunc: enum.Validate[types.PathPrefix](), + }, + }, "prefix_format": { Type: schema.TypeString, Optional: true, @@ -620,6 +628,14 @@ func resourceFlow() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "prefix_hierarchy": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateDiagFunc: enum.Validate[types.PathPrefix](), + }, + }, "prefix_format": { Type: schema.TypeString, Optional: true, @@ -1247,6 +1263,37 @@ func resourceFlow() *schema.Resource { }, }, }, + "metadata_catalog_config": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "glue": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database_name": { + Type: schema.TypeString, + Required: true, + }, + "role_arn": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringMatch(regexache.MustCompile(`arn:.*:[0-9]+:role/.*`), "must be a valid ARN of an IAM Role"), + }, + "table_prefix": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + }, + }, + }, }, CustomizeDiff: verify.SetTagsDiff, @@ -1268,6 +1315,11 @@ func resourceFlowCreate(ctx context.Context, d *schema.ResourceData, meta interf TriggerConfig: expandTriggerConfig(d.Get("trigger_config").([]interface{})[0].(map[string]interface{})), } + if v, ok := d.GetOk("metadata_catalog_config"); ok { + m := v.([]interface{})[0].(map[string]interface{}) + input.MetadataCatalogConfig = expandMetadataCatalogConfig(m) + } + if v, ok := d.GetOk(names.AttrDescription); ok { input.Description = aws.String(v.(string)) } @@ -1355,6 +1407,11 @@ func resourceFlowUpdate(ctx context.Context, d *schema.ResourceData, meta interf TriggerConfig: expandTriggerConfig(d.Get("trigger_config").([]interface{})[0].(map[string]interface{})), } + if v, ok := d.GetOk("metadata_catalog_config"); ok { + m := v.([]interface{})[0].(map[string]interface{}) + input.MetadataCatalogConfig = expandMetadataCatalogConfig(m) + } + // always send description when updating a task if v, ok := d.GetOk(names.AttrDescription); ok { input.Description = aws.String(v.(string)) @@ -1552,9 +1609,22 @@ func expandPrefixConfig(tfMap map[string]interface{}) *types.PrefixConfig { a.PrefixType = types.PrefixType(v) } + if v, ok := tfMap["prefix_hierarchy"].([]interface{}); ok && len(v) > 0 && v[0] != nil { + a.PathPrefixHierarchy = expandPrefixHierarchies(v) + } + return a } +func expandPrefixHierarchies(l []interface{}) []types.PathPrefix { + var prefixes []types.PathPrefix + + for _, item := range l { + prefixes = append(prefixes, types.PathPrefix(item.(string))) + } + return prefixes +} + func expandDestinationFlowConfigs(tfList []interface{}) []types.DestinationFlowConfig { if len(tfList) == 0 { return nil @@ -2625,6 +2695,43 @@ func expandScheduledTriggerProperties(tfMap map[string]interface{}) *types.Sched return a } +func expandMetadataCatalogConfig(tfMap map[string]interface{}) *types.MetadataCatalogConfig { + if tfMap == nil { + return nil + } + + a := &types.MetadataCatalogConfig{} + + if v, ok := tfMap["glue"].([]interface{}); ok && len(v) > 0 && v[0] != nil { + a.GlueDataCatalog = expandGlueCatalogConfig(v[0].(map[string]interface{})) + return a + } + + return nil +} + +func expandGlueCatalogConfig(tfMap map[string]interface{}) *types.GlueDataCatalogConfig { + if tfMap == nil { + return nil + } + + a := &types.GlueDataCatalogConfig{} + + if v, ok := tfMap["database_name"].(string); ok && v != "" { + a.DatabaseName = aws.String(v) + } + + if v, ok := tfMap["role_arn"].(string); ok && v != "" { + a.RoleArn = aws.String(v) + } + + if v, ok := tfMap["table_prefix"].(string); ok && v != "" { + a.TablePrefix = aws.String(v) + } + + return a +} + func flattenErrorHandlingConfig(errorHandlingConfig *types.ErrorHandlingConfig) map[string]interface{} { if errorHandlingConfig == nil { return nil @@ -2654,6 +2761,7 @@ func flattenPrefixConfig(prefixConfig *types.PrefixConfig) map[string]interface{ m["prefix_format"] = prefixConfig.PrefixFormat m["prefix_type"] = prefixConfig.PrefixType + m["prefix_hierarchy"] = prefixConfig.PathPrefixHierarchy return m } diff --git a/internal/service/appflow/flow_test.go b/internal/service/appflow/flow_test.go index 9d423cb4f4c3..663cd6122c0e 100644 --- a/internal/service/appflow/flow_test.go +++ b/internal/service/appflow/flow_test.go @@ -370,6 +370,40 @@ func TestAccAppFlowFlow_disappears(t *testing.T) { }) } +func TestAccAppFlowFlow_metadata_catalog(t *testing.T) { + ctx := acctest.Context(t) + var flowOutput types.FlowDefinition + rSourceName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + rDestinationName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + rFlowName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_appflow_flow.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, names.AppFlowServiceID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckFlowDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccFlowConfig_metadata_catalog(rSourceName, rDestinationName, rFlowName), + Check: resource.ComposeTestCheckFunc( + testAccCheckFlowExists(ctx, resourceName, &flowOutput), + resource.TestCheckResourceAttr(resourceName, "metadata_catalog_config.#", acctest.Ct1), + resource.TestCheckTypeSetElemNestedAttrs(resourceName, "prefix_config.*", map[string]string{ + "prefix_heirarchy.#": acctest.Ct2, + "prefix_heirarchy.0": "SCHEMA_VERSION", + "prefix_heirarchy.1": "EXECUTION_ID", + }), + ), + }, + { + Config: testAccFlowConfig_metadata_catalog(rSourceName, rDestinationName, rFlowName), + PlanOnly: true, + }, + }, + }) +} + func testAccFlowConfig_base(rSourceName, rDestinationName string) string { return fmt.Sprintf(` data "aws_partition" "current" {} @@ -713,7 +747,7 @@ resource "aws_appflow_flow" "test" { s3_output_format_config { prefix_config { - prefix_type = "PATH" + prefix_type = "PATH" } } } @@ -932,6 +966,86 @@ resource "aws_appflow_flow" "test" { ) } +func testAccFlowConfig_metadata_catalog(rSourceName, rDestinationName, rFlowName string) string { + return acctest.ConfigCompose( + testAccFlowConfig_base(rSourceName, rDestinationName), + fmt.Sprintf(` +resource "aws_iam_role" "test" { + name = %[1]q + + assume_role_policy = < Date: Thu, 16 May 2024 12:50:12 -0400 Subject: [PATCH 02/10] fix tests --- internal/service/appflow/flow_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/service/appflow/flow_test.go b/internal/service/appflow/flow_test.go index 663cd6122c0e..0184456798a4 100644 --- a/internal/service/appflow/flow_test.go +++ b/internal/service/appflow/flow_test.go @@ -389,11 +389,9 @@ func TestAccAppFlowFlow_metadata_catalog(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckFlowExists(ctx, resourceName, &flowOutput), resource.TestCheckResourceAttr(resourceName, "metadata_catalog_config.#", acctest.Ct1), - resource.TestCheckTypeSetElemNestedAttrs(resourceName, "prefix_config.*", map[string]string{ - "prefix_heirarchy.#": acctest.Ct2, - "prefix_heirarchy.0": "SCHEMA_VERSION", - "prefix_heirarchy.1": "EXECUTION_ID", - }), + resource.TestCheckResourceAttr(resourceName, "destination_flow_config.0.destination_connector_properties.0.s3.0.s3_output_format_config.0.prefix_config.0.prefix_hierarchy.0", "SCHEMA_VERSION"), + resource.TestCheckResourceAttr(resourceName, "destination_flow_config.0.destination_connector_properties.0.s3.0.s3_output_format_config.0.prefix_config.0.prefix_hierarchy.1", "EXECUTION_ID"), + resource.TestCheckResourceAttr(resourceName, "destination_flow_config.0.destination_connector_properties.0.s3.0.s3_output_format_config.0.prefix_config.0.prefix_hierarchy.#", acctest.Ct2), ), }, { @@ -747,7 +745,7 @@ resource "aws_appflow_flow" "test" { s3_output_format_config { prefix_config { - prefix_type = "PATH" + prefix_type = "PATH" } } } @@ -1011,6 +1009,10 @@ resource "aws_appflow_flow" "test" { s3_output_format_config { prefix_config { prefix_type = "PATH" + prefix_hierarchy = [ + "SCHEMA_VERSION", + "EXECUTION_ID", + ] } } } From dc49b3ec4c4b273bba65beb00593e612319da3a8 Mon Sep 17 00:00:00 2001 From: Nick Hankins Date: Thu, 16 May 2024 13:14:42 -0400 Subject: [PATCH 03/10] add docs --- website/docs/r/appflow_flow.html.markdown | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/website/docs/r/appflow_flow.html.markdown b/website/docs/r/appflow_flow.html.markdown index 7761c4fb54e8..1d669ce3ebeb 100644 --- a/website/docs/r/appflow_flow.html.markdown +++ b/website/docs/r/appflow_flow.html.markdown @@ -141,6 +141,7 @@ 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. +* `metadata_catalog_config` - (Optional) A [Catalog](#metadata-catalog-config) that determines the configuration that Amazon AppFlow uses when it catalogs the data that’s transferred by the associated flow. When Amazon AppFlow catalogs the data from a flow, it stores metadata in a data catalog. ### Destination Flow Config @@ -252,6 +253,7 @@ EventBridge, Honeycode, and Marketo destination properties all support the follo * `prefix_format` - (Optional) Determines the level of granularity that's included in the prefix. Valid values are `YEAR`, `MONTH`, `DAY`, `HOUR`, and `MINUTE`. * `prefix_type` - (Optional) Determines the format of the prefix, and whether it applies to the file name, file path, or both. Valid values are `FILENAME`, `PATH`, and `PATH_AND_FILENAME`. +* `prefix_hierarchy` - (Optional) Determines whether the destination file path includes either or both of the selected elements. Valid values are `EXECUTION_ID` and `SCHEMA_VERSION` ##### Zendesk Destination Properties @@ -391,6 +393,13 @@ resource "aws_appflow_flow" "example" { } ``` +### Metadata Catalog Config +The `metadata_catalog_config` block only supports one attribute: `glue`, a block which in turn supports the following: + +* `database_name` - (Required) The name of an existing Glue database to store the metadata tables that Amazon AppFlow creates. +* `role_arn` - (Required) The ARN of an IAM role that grants AppFlow the permissions it needs to create Data Catalog tables, databases, and partitions. +* `table_prefix` - (Required) A naming prefix for each Data Catalog table that Amazon AppFlow creates + ## Attribute Reference This resource exports the following attributes in addition to the arguments above: From 6da5200be1076adc33d196a85d18a58b7fda78ce Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Tue, 23 Jul 2024 16:34:37 -0500 Subject: [PATCH 04/10] aws_appflow_flow: set detadata_data_catalog properties correctly --- internal/service/appflow/flow.go | 80 ++++++++++++++++++--------- internal/service/appflow/flow_test.go | 21 +++---- 2 files changed, 62 insertions(+), 39 deletions(-) diff --git a/internal/service/appflow/flow.go b/internal/service/appflow/flow.go index e025b1382acd..689f9c2cf2e9 100644 --- a/internal/service/appflow/flow.go +++ b/internal/service/appflow/flow.go @@ -398,6 +398,7 @@ func resourceFlow() *schema.Resource { "prefix_hierarchy": { Type: schema.TypeList, Optional: true, + Computed: true, Elem: &schema.Schema{ Type: schema.TypeString, ValidateDiagFunc: enum.Validate[types.PathPrefix](), @@ -1278,10 +1279,11 @@ func resourceFlow() *schema.Resource { "metadata_catalog_config": { Type: schema.TypeList, Optional: true, + Computed: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "glue": { + "glue_data_catalog": { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -1292,9 +1294,9 @@ func resourceFlow() *schema.Resource { Required: true, }, "role_arn": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`arn:.*:[0-9]+:role/.*`), "must be a valid ARN of an IAM Role"), + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: validation.ToDiagFunc(verify.ValidARN), }, "table_prefix": { Type: schema.TypeString, @@ -1328,8 +1330,7 @@ func resourceFlowCreate(ctx context.Context, d *schema.ResourceData, meta interf } if v, ok := d.GetOk("metadata_catalog_config"); ok { - m := v.([]interface{})[0].(map[string]interface{}) - input.MetadataCatalogConfig = expandMetadataCatalogConfig(m) + input.MetadataCatalogConfig = expandMetadataCatalogConfig(v.([]any)) } if v, ok := d.GetOk(names.AttrDescription); ok { @@ -1400,6 +1401,14 @@ func resourceFlowRead(ctx context.Context, d *schema.ResourceData, meta interfac d.Set("trigger_config", nil) } + if output.MetadataCatalogConfig != nil { + if err := d.Set("metadata_catalog_config", flattenMetadataCatalogConfig(output.MetadataCatalogConfig)); err != nil { + return sdkdiag.AppendErrorf(diags, "setting metadata_catalog_config: %s", err) + } + } else { + d.Set("metadata_catalog_config", nil) + } + setTagsOut(ctx, output.Tags) return diags @@ -1420,8 +1429,7 @@ func resourceFlowUpdate(ctx context.Context, d *schema.ResourceData, meta interf } if v, ok := d.GetOk("metadata_catalog_config"); ok { - m := v.([]interface{})[0].(map[string]interface{}) - input.MetadataCatalogConfig = expandMetadataCatalogConfig(m) + input.MetadataCatalogConfig = expandMetadataCatalogConfig(v.([]any)) } // always send description when updating a task @@ -1587,21 +1595,12 @@ func expandPrefixConfig(tfMap map[string]interface{}) *types.PrefixConfig { } if v, ok := tfMap["prefix_hierarchy"].([]interface{}); ok && len(v) > 0 && v[0] != nil { - a.PathPrefixHierarchy = expandPrefixHierarchies(v) + a.PathPrefixHierarchy = flex.ExpandStringyValueList[types.PathPrefix](v) } return a } -func expandPrefixHierarchies(l []interface{}) []types.PathPrefix { - var prefixes []types.PathPrefix - - for _, item := range l { - prefixes = append(prefixes, types.PathPrefix(item.(string))) - } - return prefixes -} - func expandDestinationFlowConfigs(tfList []interface{}) []types.DestinationFlowConfig { if len(tfList) == 0 { return nil @@ -2672,22 +2671,23 @@ func expandScheduledTriggerProperties(tfMap map[string]interface{}) *types.Sched return a } -func expandMetadataCatalogConfig(tfMap map[string]interface{}) *types.MetadataCatalogConfig { - if tfMap == nil { +func expandMetadataCatalogConfig(tfList []any) *types.MetadataCatalogConfig { + if len(tfList) == 0 { return nil } + m := tfList[0].(map[string]any) + a := &types.MetadataCatalogConfig{} - if v, ok := tfMap["glue"].([]interface{}); ok && len(v) > 0 && v[0] != nil { - a.GlueDataCatalog = expandGlueCatalogConfig(v[0].(map[string]interface{})) - return a + if v, ok := m["glue_data_catalog"].([]any); ok && len(v) > 0 && v[0] != nil { + a.GlueDataCatalog = expandGlueDataCatalog(v[0].(map[string]any)) } - return nil + return a } -func expandGlueCatalogConfig(tfMap map[string]interface{}) *types.GlueDataCatalogConfig { +func expandGlueDataCatalog(tfMap map[string]interface{}) *types.GlueDataCatalogConfig { if tfMap == nil { return nil } @@ -2709,6 +2709,32 @@ func expandGlueCatalogConfig(tfMap map[string]interface{}) *types.GlueDataCatalo return a } +func flattenMetadataCatalogConfig(in *types.MetadataCatalogConfig) []any { + if in == nil { + return nil + } + + m := map[string]any{ + "glue_data_catalog": flattenGlueDataCatalog(in.GlueDataCatalog), + } + + return []any{m} +} + +func flattenGlueDataCatalog(in *types.GlueDataCatalogConfig) []any { + if in == nil { + return nil + } + + m := map[string]any{ + "database_name": in.DatabaseName, + "role_arn": in.RoleArn, + "table_prefix": in.TablePrefix, + } + + return []any{m} +} + func flattenErrorHandlingConfig(errorHandlingConfig *types.ErrorHandlingConfig) map[string]interface{} { if errorHandlingConfig == nil { return nil @@ -2738,7 +2764,7 @@ func flattenPrefixConfig(prefixConfig *types.PrefixConfig) map[string]interface{ m["prefix_format"] = prefixConfig.PrefixFormat m["prefix_type"] = prefixConfig.PrefixType - m["prefix_hierarchy"] = prefixConfig.PathPrefixHierarchy + m["prefix_hierarchy"] = flex.FlattenStringyValueList(prefixConfig.PathPrefixHierarchy) return m } @@ -3604,7 +3630,7 @@ func flattenTask(task types.Task) map[string]interface{} { } if v := task.TaskProperties; v != nil { - m["task_properties"] = v + m["task_properties"] = flex.FlattenStringValueMap(v) } m["task_type"] = task.TaskType diff --git a/internal/service/appflow/flow_test.go b/internal/service/appflow/flow_test.go index 8654a7d9fc4f..7532afe6ddc5 100644 --- a/internal/service/appflow/flow_test.go +++ b/internal/service/appflow/flow_test.go @@ -11,7 +11,6 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/service/appflow" - "github.com/aws/aws-sdk-go-v2/service/appflow/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -309,12 +308,10 @@ func TestAccAppFlowFlow_disappears(t *testing.T) { }) } -func TestAccAppFlowFlow_metadata_catalog(t *testing.T) { +func TestAccAppFlowFlow_metadataCatalog(t *testing.T) { ctx := acctest.Context(t) - var flowOutput types.FlowDefinition - rSourceName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) - rDestinationName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) - rFlowName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + var flowOutput appflow.DescribeFlowOutput + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_appflow_flow.test" resource.ParallelTest(t, resource.TestCase{ @@ -324,7 +321,7 @@ func TestAccAppFlowFlow_metadata_catalog(t *testing.T) { CheckDestroy: testAccCheckFlowDestroy(ctx), Steps: []resource.TestStep{ { - Config: testAccFlowConfig_metadata_catalog(rSourceName, rDestinationName, rFlowName), + Config: testAccFlowConfig_metadata_catalog(rName), Check: resource.ComposeTestCheckFunc( testAccCheckFlowExists(ctx, resourceName, &flowOutput), resource.TestCheckResourceAttr(resourceName, "metadata_catalog_config.#", acctest.Ct1), @@ -334,7 +331,7 @@ func TestAccAppFlowFlow_metadata_catalog(t *testing.T) { ), }, { - Config: testAccFlowConfig_metadata_catalog(rSourceName, rDestinationName, rFlowName), + Config: testAccFlowConfig_metadata_catalog(rName), PlanOnly: true, }, }, @@ -794,9 +791,9 @@ resource "aws_appflow_flow" "test" { ) } -func testAccFlowConfig_metadata_catalog(rSourceName, rDestinationName, rFlowName string) string { +func testAccFlowConfig_metadata_catalog(rName string) string { return acctest.ConfigCompose( - testAccFlowConfig_base(rSourceName, rDestinationName), + testAccFlowConfig_base(rName), fmt.Sprintf(` resource "aws_iam_role" "test" { name = %[1]q @@ -863,7 +860,7 @@ resource "aws_appflow_flow" "test" { } metadata_catalog_config { - glue { + glue_data_catalog { database_name = "testdb_name" table_prefix = "test_prefix" role_arn = aws_iam_role.test.arn @@ -874,7 +871,7 @@ resource "aws_appflow_flow" "test" { trigger_type = "OnDemand" } } -`, rFlowName), +`, rName), ) } From 6dcbbb97cac46af255c892194c26551e1825eaff Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Tue, 23 Jul 2024 16:39:32 -0500 Subject: [PATCH 05/10] add CHANGELOG entry --- .changelog/37566.txt | 7 +++++++ internal/service/appflow/flow.go | 1 + 2 files changed, 8 insertions(+) create mode 100644 .changelog/37566.txt diff --git a/.changelog/37566.txt b/.changelog/37566.txt new file mode 100644 index 000000000000..9b2be6e05f3a --- /dev/null +++ b/.changelog/37566.txt @@ -0,0 +1,7 @@ +```release-note:enhancement +resource/aws_appflow_flow: Add `prefix_hierarchy` attribute to `destination_flow_config.s3.s3_output_format_config` +``` + +```release-note:enhancement +resource/aws_appflow_flow: Add `metadata_catalog_config` attribute +``` \ No newline at end of file diff --git a/internal/service/appflow/flow.go b/internal/service/appflow/flow.go index 689f9c2cf2e9..66726bee8e04 100644 --- a/internal/service/appflow/flow.go +++ b/internal/service/appflow/flow.go @@ -644,6 +644,7 @@ func resourceFlow() *schema.Resource { "prefix_hierarchy": { Type: schema.TypeList, Optional: true, + Computed: true, Elem: &schema.Schema{ Type: schema.TypeString, ValidateDiagFunc: enum.Validate[types.PathPrefix](), From b561c8a945d94923e2ccf240b3a83bf484328ad9 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Tue, 23 Jul 2024 16:40:57 -0500 Subject: [PATCH 06/10] tweak documentation --- website/docs/r/appflow_flow.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/appflow_flow.html.markdown b/website/docs/r/appflow_flow.html.markdown index 1d669ce3ebeb..dfb127c7e218 100644 --- a/website/docs/r/appflow_flow.html.markdown +++ b/website/docs/r/appflow_flow.html.markdown @@ -394,7 +394,7 @@ resource "aws_appflow_flow" "example" { ``` ### Metadata Catalog Config -The `metadata_catalog_config` block only supports one attribute: `glue`, a block which in turn supports the following: +The `metadata_catalog_config` block only supports one attribute: `glue_data_catalog`, a block which in turn supports the following: * `database_name` - (Required) The name of an existing Glue database to store the metadata tables that Amazon AppFlow creates. * `role_arn` - (Required) The ARN of an IAM role that grants AppFlow the permissions it needs to create Data Catalog tables, databases, and partitions. From 1feea689de98df519c78e84c1c11e7f4e5bf7206 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Tue, 23 Jul 2024 17:08:49 -0500 Subject: [PATCH 07/10] chore: linter --- internal/service/appflow/flow_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/appflow/flow_test.go b/internal/service/appflow/flow_test.go index 7532afe6ddc5..96887f025e7f 100644 --- a/internal/service/appflow/flow_test.go +++ b/internal/service/appflow/flow_test.go @@ -796,9 +796,9 @@ func testAccFlowConfig_metadata_catalog(rName string) string { testAccFlowConfig_base(rName), fmt.Sprintf(` resource "aws_iam_role" "test" { - name = %[1]q - - assume_role_policy = < Date: Tue, 23 Jul 2024 17:13:43 -0500 Subject: [PATCH 08/10] chore: linter --- website/docs/r/appflow_flow.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/appflow_flow.html.markdown b/website/docs/r/appflow_flow.html.markdown index dfb127c7e218..fa590de27f88 100644 --- a/website/docs/r/appflow_flow.html.markdown +++ b/website/docs/r/appflow_flow.html.markdown @@ -394,6 +394,7 @@ resource "aws_appflow_flow" "example" { ``` ### Metadata Catalog Config + The `metadata_catalog_config` block only supports one attribute: `glue_data_catalog`, a block which in turn supports the following: * `database_name` - (Required) The name of an existing Glue database to store the metadata tables that Amazon AppFlow creates. From 66102e280b8984d349dfee392508b23cc3b54dbf Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Tue, 23 Jul 2024 17:15:06 -0500 Subject: [PATCH 09/10] chore: semgrep fix --- internal/service/appflow/flow.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/service/appflow/flow.go b/internal/service/appflow/flow.go index 66726bee8e04..4a69c6a3a9dd 100644 --- a/internal/service/appflow/flow.go +++ b/internal/service/appflow/flow.go @@ -1290,11 +1290,11 @@ func resourceFlow() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database_name": { + names.AttrDatabaseName: { Type: schema.TypeString, Required: true, }, - "role_arn": { + names.AttrRoleARN: { Type: schema.TypeString, Required: true, ValidateDiagFunc: validation.ToDiagFunc(verify.ValidARN), @@ -2695,11 +2695,11 @@ func expandGlueDataCatalog(tfMap map[string]interface{}) *types.GlueDataCatalogC a := &types.GlueDataCatalogConfig{} - if v, ok := tfMap["database_name"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrDatabaseName].(string); ok && v != "" { a.DatabaseName = aws.String(v) } - if v, ok := tfMap["role_arn"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrRoleARN].(string); ok && v != "" { a.RoleArn = aws.String(v) } @@ -2728,8 +2728,8 @@ func flattenGlueDataCatalog(in *types.GlueDataCatalogConfig) []any { } m := map[string]any{ - "database_name": in.DatabaseName, - "role_arn": in.RoleArn, + names.AttrDatabaseName: in.DatabaseName, + names.AttrRoleARN: in.RoleArn, "table_prefix": in.TablePrefix, } From a6fd23bff9dd6ef286848282c9f8ae8b0a47559d Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Tue, 23 Jul 2024 17:17:49 -0500 Subject: [PATCH 10/10] fmt --- internal/service/appflow/flow.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/appflow/flow.go b/internal/service/appflow/flow.go index 4a69c6a3a9dd..1766f8238cba 100644 --- a/internal/service/appflow/flow.go +++ b/internal/service/appflow/flow.go @@ -2730,7 +2730,7 @@ func flattenGlueDataCatalog(in *types.GlueDataCatalogConfig) []any { m := map[string]any{ names.AttrDatabaseName: in.DatabaseName, names.AttrRoleARN: in.RoleArn, - "table_prefix": in.TablePrefix, + "table_prefix": in.TablePrefix, } return []any{m}