Skip to content

Commit

Permalink
Merge pull request #38098 from rob93c/add-kinesis-timestamp-precision
Browse files Browse the repository at this point in the history
Add `approximate_creation_date_time_precision` to `aws_dynamodb_kinesis_streaming_destination`
  • Loading branch information
ewbankkit authored Oct 23, 2024
2 parents af82368 + fadb835 commit 20fac1c
Show file tree
Hide file tree
Showing 8 changed files with 847 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .changelog/38098.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_dynamodb_kinesis_streaming_destination: Add `approximate_creation_date_time_precision` argument
```
3 changes: 3 additions & 0 deletions .changelog/39844.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_kinesis_firehose_delivery_stream: Add `iceberg_configuration` argument
```
18 changes: 17 additions & 1 deletion internal/service/dynamodb/kinesis_streaming_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ func resourceKinesisStreamingDestination() *schema.Resource {
},

Schema: map[string]*schema.Schema{
"approximate_creation_date_time_precision": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateDiagFunc: enum.Validate[awstypes.ApproximateCreationDateTimePrecision](),
},
names.AttrStreamARN: {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -73,6 +80,12 @@ func resourceKinesisStreamingDestinationCreate(ctx context.Context, d *schema.Re
TableName: aws.String(tableName),
}

if v, ok := d.GetOk("approximate_creation_date_time_precision"); ok {
input.EnableKinesisStreamingConfiguration = &awstypes.EnableKinesisStreamingConfiguration{
ApproximateCreationDateTimePrecision: awstypes.ApproximateCreationDateTimePrecision(v.(string)),
}
}

if _, err := conn.EnableKinesisStreamingDestination(ctx, input); err != nil {
return sdkdiag.AppendErrorf(diags, "enabling DynamoDB Kinesis Streaming Destination (%s): %s", id, err)
}
Expand Down Expand Up @@ -108,6 +121,7 @@ func resourceKinesisStreamingDestinationRead(ctx context.Context, d *schema.Reso
return sdkdiag.AppendErrorf(diags, "reading DynamoDB Kinesis Streaming Destination (%s): %s", d.Id(), err)
}

d.Set("approximate_creation_date_time_precision", output.ApproximateCreationDateTimePrecision)
d.Set(names.AttrStreamARN, output.StreamArn)
d.Set(names.AttrTableName, tableName)

Expand All @@ -131,7 +145,7 @@ func resourceKinesisStreamingDestinationDelete(ctx context.Context, d *schema.Re
}

if err != nil {
return sdkdiag.AppendErrorf(diags, "disabling DynamoDB Kinesis Streaming Destination (%s): %s", d.Id(), err)
return sdkdiag.AppendErrorf(diags, "reading DynamoDB Kinesis Streaming Destination (%s): %s", d.Id(), err)
}

log.Printf("[DEBUG] Deleting DynamoDB Kinesis Streaming Destination: %s", d.Id())
Expand Down Expand Up @@ -243,6 +257,7 @@ func waitKinesisStreamingDestinationActive(ctx context.Context, conn *dynamodb.C

if output, ok := outputRaw.(*awstypes.KinesisDataStreamDestination); ok {
tfresource.SetLastError(err, errors.New(aws.ToString(output.DestinationStatusDescription)))

return output, err
}

Expand All @@ -264,6 +279,7 @@ func waitKinesisStreamingDestinationDisabled(ctx context.Context, conn *dynamodb

if output, ok := outputRaw.(*awstypes.KinesisDataStreamDestination); ok {
tfresource.SetLastError(err, errors.New(aws.ToString(output.DestinationStatusDescription)))

return output, err
}

Expand Down
48 changes: 46 additions & 2 deletions internal/service/dynamodb/kinesis_streaming_destination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,38 @@ func TestAccDynamoDBKinesisStreamingDestination_basic(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccKinesisStreamingDestinationConfig_basic(rName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckKinesisStreamingDestinationExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "approximate_creation_date_time_precision", ""),
acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrStreamARN, "kinesis", regexache.MustCompile(fmt.Sprintf("stream/%s", rName))),
resource.TestCheckResourceAttr(resourceName, names.AttrTableName, rName),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccDynamoDBKinesisStreamingDestination_approximateCreationDateTimePrecision(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_dynamodb_kinesis_streaming_destination.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.DynamoDBServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckKinesisStreamingDestinationDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccKinesisStreamingDestinationConfig_approximateCreationDateTimePrecision(rName, "MICROSECOND"),
Check: resource.ComposeTestCheckFunc(
testAccCheckKinesisStreamingDestinationExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "approximate_creation_date_time_precision", "MICROSECOND"),
acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrStreamARN, "kinesis", regexache.MustCompile(fmt.Sprintf("stream/%s", rName))),
resource.TestCheckResourceAttr(resourceName, names.AttrTableName, rName),
),
Expand Down Expand Up @@ -95,7 +125,7 @@ func TestAccDynamoDBKinesisStreamingDestination_Disappears_dynamoDBTable(t *test
})
}

func testAccKinesisStreamingDestinationConfig_basic(rName string) string {
func testAccKinesisStreamingDestinationConfig_base(rName string) string {
return fmt.Sprintf(`
resource "aws_dynamodb_table" "test" {
name = %[1]q
Expand All @@ -113,12 +143,26 @@ resource "aws_kinesis_stream" "test" {
name = %[1]q
shard_count = 2
}
`, rName)
}

func testAccKinesisStreamingDestinationConfig_basic(rName string) string {
return acctest.ConfigCompose(testAccKinesisStreamingDestinationConfig_base(rName), `
resource "aws_dynamodb_kinesis_streaming_destination" "test" {
table_name = aws_dynamodb_table.test.name
stream_arn = aws_kinesis_stream.test.arn
}
`, rName)
`)
}

func testAccKinesisStreamingDestinationConfig_approximateCreationDateTimePrecision(rName, precision string) string {
return acctest.ConfigCompose(testAccKinesisStreamingDestinationConfig_base(rName), fmt.Sprintf(`
resource "aws_dynamodb_kinesis_streaming_destination" "test" {
table_name = aws_dynamodb_table.test.name
stream_arn = aws_kinesis_stream.test.arn
approximate_creation_date_time_precision = %[1]q
}
`, precision))
}

func testAccCheckKinesisStreamingDestinationExists(ctx context.Context, n string) resource.TestCheckFunc {
Expand Down
Loading

0 comments on commit 20fac1c

Please sign in to comment.