Skip to content

Commit

Permalink
Fix "Error: updating Kinesis Firehose Delivery Stream (tf-acc-test-19…
Browse files Browse the repository at this point in the history
…787509517258576): operation error Firehose: UpdateDestination, https response error StatusCode: 400, RequestID: e37d3184-7f21-2c18-bd8a-7dcdd054ed55, api error ValidationException: 1 validation error detected: Value at 'snowflakeDestinationUpdate.snowflakeRoleConfiguration.snowflakeRole' failed to satisfy constraint: Member must have length greater than or equal to 1" on deleting the configuration

Signed-off-by: Takahiro Nakayama <civitaspo@gmail.com>
  • Loading branch information
civitaspo committed Jun 27, 2024
1 parent 7247c2c commit cefe73a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions internal/service/firehose/delivery_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -3120,16 +3120,22 @@ func expandSnowflakeRetryOptions(tfMap map[string]interface{}) *types.SnowflakeR
}

func expandSnowflakeRoleConfiguration(tfMap map[string]interface{}) *types.SnowflakeRoleConfiguration {
tfList := tfMap["snowflake_role_configuration"].([]interface{})
if len(tfList) == 0 {
return nil
config := tfMap["snowflake_role_configuration"].([]interface{})
if len(config) == 0 || config[0] == nil {
// It is possible to just pass nil here, but this seems to be the
// canonical form that AWS uses, and is less likely to produce diffs.
return &types.SnowflakeRoleConfiguration{
Enabled: aws.Bool(false),
}
}

tfMap = tfList[0].(map[string]interface{})

snowflakeRoleConfiguration := config[0].(map[string]interface{})
apiObject := &types.SnowflakeRoleConfiguration{
Enabled: aws.Bool(tfMap[names.AttrEnabled].(bool)),
SnowflakeRole: aws.String(tfMap["snowflake_role"].(string)),
Enabled: aws.Bool(snowflakeRoleConfiguration[names.AttrEnabled].(bool)),
}

if v, ok := snowflakeRoleConfiguration["snowflake_role"]; ok && len(v.(string)) > 0 {
apiObject.SnowflakeRole = aws.String(v.(string))
}

return apiObject
Expand Down Expand Up @@ -3961,7 +3967,9 @@ func flattenSnowflakeRoleConfiguration(apiObject *types.SnowflakeRoleConfigurati

m := map[string]interface{}{
names.AttrEnabled: aws.ToBool(apiObject.Enabled),
"snowflake_role": aws.ToString(apiObject.SnowflakeRole),
}
if aws.ToBool(apiObject.Enabled) {
m["snowflake_role"] = aws.ToString(apiObject.SnowflakeRole)
}

return []map[string]interface{}{m}
Expand Down

0 comments on commit cefe73a

Please sign in to comment.