From f9f7ac0ae2e222c50b4e9370a7793406d045509b Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 15 Oct 2024 10:06:44 -0400 Subject: [PATCH] Cosmetics. --- .changelog/37773.txt | 2 +- .changelog/37799.txt | 2 +- internal/service/events/target.go | 57 ++++++++++--------- .../r/cloudwatch_event_target.html.markdown | 2 +- 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/.changelog/37773.txt b/.changelog/37773.txt index f81a4c2b0e63..06f64830ccbf 100644 --- a/.changelog/37773.txt +++ b/.changelog/37773.txt @@ -1,3 +1,3 @@ ```release-note:enhancement -resource/aws_cloudwatch_event_target: Add `appsync_target` argument +resource/aws_cloudwatch_event_target: Add `appsync_target` configuration block ``` diff --git a/.changelog/37799.txt b/.changelog/37799.txt index 75660006c8e5..88ca6858b890 100644 --- a/.changelog/37799.txt +++ b/.changelog/37799.txt @@ -1,3 +1,3 @@ ```release-note:enhancement -resource/aws_dynamodb_table: Add `on_demand_throughput` and `global_secondary_index.on_demand_throughput` arguments +resource/aws_dynamodb_table: Add `on_demand_throughput` and `global_secondary_index.on_demand_throughput` arguments ``` \ No newline at end of file diff --git a/internal/service/events/target.go b/internal/service/events/target.go index 71ea88f4cbab..6935482e3d06 100644 --- a/internal/service/events/target.go +++ b/internal/service/events/target.go @@ -68,6 +68,20 @@ func resourceTarget() *schema.Resource { }, Schema: map[string]*schema.Schema{ + "appsync_target": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "graphql_operation": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: validation.ToDiagFunc(validation.StringLenBetween(1, 1048576)), + }, + }, + }, + }, names.AttrARN: { Type: schema.TypeString, Required: true, @@ -489,20 +503,6 @@ func resourceTarget() *schema.Resource { ForceNew: true, ValidateFunc: validateTargetID, }, - "appsync_target": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "graphql_operation": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: validation.ToDiagFunc(validation.StringLenBetween(1, 1048576)), - }, - }, - }, - }, }, } } @@ -636,7 +636,7 @@ func resourceTargetRead(ctx context.Context, d *schema.ResourceData, meta interf } if target.AppSyncParameters != nil { - if err := d.Set("appsync_target", flattenTargetAppSyncParameters(target.AppSyncParameters)); err != nil { + if err := d.Set("appsync_target", flattenAppSyncParameters(target.AppSyncParameters)); err != nil { return sdkdiag.AppendErrorf(diags, "setting appsync_target: %s", err) } } @@ -892,7 +892,7 @@ func expandPutTargetsInput(ctx context.Context, d *schema.ResourceData) *eventbr } if v, ok := d.GetOk("appsync_target"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { - target.AppSyncParameters = expandTargetAppSyncParameters(v.([]interface{})) + target.AppSyncParameters = expandAppSyncParameters(v.([]interface{})) } input := &eventbridge.PutTargetsInput{ @@ -1509,21 +1509,22 @@ func flattenTargetCapacityProviderStrategy(cps []types.CapacityProviderStrategyI return results } -func flattenTargetAppSyncParameters(appSyncParameters *types.AppSyncParameters) []map[string]interface{} { - config := make(map[string]interface{}) - config["graphql_operation"] = aws.ToString(appSyncParameters.GraphQLOperation) - result := []map[string]interface{}{config} - return result +func flattenAppSyncParameters(apiObject *types.AppSyncParameters) []map[string]interface{} { + tfMap := make(map[string]interface{}) + tfMap["graphql_operation"] = aws.ToString(apiObject.GraphQLOperation) + + return []map[string]interface{}{tfMap} } -func expandTargetAppSyncParameters(config []interface{}) *types.AppSyncParameters { - appSyncParameters := &types.AppSyncParameters{} - for _, c := range config { - param := c.(map[string]interface{}) - if v, ok := param["graphql_operation"].(string); ok && v != "" { - appSyncParameters.GraphQLOperation = aws.String(v) +func expandAppSyncParameters(tfList []interface{}) *types.AppSyncParameters { + apiObject := &types.AppSyncParameters{} + + for _, tfMapRaw := range tfList { + tfMap := tfMapRaw.(map[string]interface{}) + if v, ok := tfMap["graphql_operation"].(string); ok && v != "" { + apiObject.GraphQLOperation = aws.String(v) } } - return appSyncParameters + return apiObject } diff --git a/website/docs/r/cloudwatch_event_target.html.markdown b/website/docs/r/cloudwatch_event_target.html.markdown index ee56018f71c7..443a62f93d34 100644 --- a/website/docs/r/cloudwatch_event_target.html.markdown +++ b/website/docs/r/cloudwatch_event_target.html.markdown @@ -558,6 +558,7 @@ The following arguments are required: The following arguments are optional: +* `appsync_target` - (Optional) Parameters used when you are using the rule to invoke an AppSync GraphQL API mutation. Documented below. A maximum of 1 are allowed. * `batch_target` - (Optional) Parameters used when you are using the rule to invoke an Amazon Batch Job. Documented below. A maximum of 1 are allowed. * `dead_letter_config` - (Optional) Parameters used when you are providing a dead letter config. Documented below. A maximum of 1 are allowed. * `ecs_target` - (Optional) Parameters used when you are using the rule to invoke Amazon ECS Task. Documented below. A maximum of 1 are allowed. @@ -576,7 +577,6 @@ The following arguments are optional: * `sagemaker_pipeline_target` - (Optional) Parameters used when you are using the rule to invoke an Amazon SageMaker Pipeline. Documented below. A maximum of 1 are allowed. * `sqs_target` - (Optional) Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed. * `target_id` - (Optional) The unique target assignment ID. If missing, will generate a random, unique id. -* `appsync_target` - (Optional) Parameters used when you are using the rule to invoke an AppSync GraphQL API mutation. Documented below. A maximum of 1 are allowed. ### batch_target