Skip to content

Commit

Permalink
Merge pull request #36544 from msvbhat/f-aws_db_snapshot-include-orig…
Browse files Browse the repository at this point in the history
…inal-snapshot-create-time

Add original_snapshot_create_time for aws_db_snapshot data source
  • Loading branch information
ewbankkit authored Mar 25, 2024
2 parents 7cadc68 + a88371f commit efe33f8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .changelog/36544.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:enhancement
data-source/aws_db_snapshot: Add `original_snapshot_create_time` attribute
```

7 changes: 7 additions & 0 deletions internal/service/rds/snapshot_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func DataSourceSnapshot() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"original_snapshot_create_time": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
Expand Down Expand Up @@ -188,6 +192,9 @@ func dataSourceSnapshotRead(ctx context.Context, d *schema.ResourceData, meta in
d.Set("kms_key_id", snapshot.KmsKeyId)
d.Set("license_model", snapshot.LicenseModel)
d.Set("option_group_name", snapshot.OptionGroupName)
if snapshot.OriginalSnapshotCreateTime != nil {
d.Set("original_snapshot_create_time", snapshot.OriginalSnapshotCreateTime.Format(time.RFC3339))
}
d.Set("port", snapshot.Port)
d.Set("source_db_snapshot_identifier", snapshot.SourceDBSnapshotIdentifier)
d.Set("source_region", snapshot.SourceRegion)
Expand Down
4 changes: 4 additions & 0 deletions internal/service/rds/snapshot_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ func TestAccRDSSnapshotDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttrPair(ds1Name, "db_snapshot_arn", resourceName, "db_snapshot_arn"),
resource.TestCheckResourceAttrPair(ds1Name, "db_snapshot_identifier", resourceName, "db_snapshot_identifier"),
resource.TestCheckResourceAttrPair(ds1Name, "tags.%", resourceName, "tags.%"),
resource.TestCheckResourceAttrSet(ds1Name, "snapshot_create_time"),
resource.TestCheckResourceAttrSet(ds1Name, "original_snapshot_create_time"),
resource.TestCheckResourceAttr(ds1Name, "tags.Name", rName),

resource.TestCheckResourceAttrPair(ds2Name, "db_instance_identifier", resourceName, "db_instance_identifier"),
resource.TestCheckResourceAttrPair(ds2Name, "db_snapshot_arn", resourceName, "db_snapshot_arn"),
resource.TestCheckResourceAttrPair(ds2Name, "db_snapshot_identifier", resourceName, "db_snapshot_identifier"),
resource.TestCheckResourceAttrSet(ds2Name, "snapshot_create_time"),
resource.TestCheckResourceAttrSet(ds2Name, "original_snapshot_create_time"),
resource.TestCheckResourceAttrPair(ds1Name, "tags.%", resourceName, "tags.%"),
resource.TestCheckResourceAttr(ds2Name, "tags.Name", rName),
),
Expand Down
2 changes: 1 addition & 1 deletion website/docs/cdktf/python/d/db_snapshot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ This data source exports the following attributes in addition to the arguments a
* `vpc_id` - ID of the VPC associated with the DB snapshot.
* `snapshot_create_time` - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC).

<!-- cache-key: cdktf-0.20.1 input-9f41210b58c8bb6be2c45a9fec8d65b0d0e6ca683037a4f7c19bc634c7236062 -->
<!-- cache-key: cdktf-0.20.1 input-9f41210b58c8bb6be2c45a9fec8d65b0d0e6ca683037a4f7c19bc634c7236062 -->
3 changes: 2 additions & 1 deletion website/docs/d/db_snapshot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ This data source exports the following attributes in addition to the arguments a
* `status` - Status of this DB snapshot.
* `storage_type` - Storage type associated with DB snapshot.
* `vpc_id` - ID of the VPC associated with the DB snapshot.
* `snapshot_create_time` - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC).
* `snapshot_create_time` - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Changes for the copy when the snapshot is copied.
* `original_snapshot_create_time` - Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Doesn't change when the snapshot is copied.

0 comments on commit efe33f8

Please sign in to comment.