Skip to content

Commit

Permalink
Merge pull request #29635 from bjernie/f-added-timeouts-to-qldb-ledger
Browse files Browse the repository at this point in the history
Added timeouts to QLDB ledger
  • Loading branch information
johnsonaj authored Mar 10, 2023
2 parents 2caf9eb + fd9990c commit a9ad032
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/29635.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_qldb_ledger: Add configurable timeouts
```
17 changes: 11 additions & 6 deletions internal/service/qldb/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func ResourceLedger() *schema.Resource {
StateContext: schema.ImportStatePassthroughContext,
},

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},

Schema: map[string]*schema.Schema{
"arn": {
Type: schema.TypeString,
Expand Down Expand Up @@ -100,7 +105,7 @@ func resourceLedgerCreate(ctx context.Context, d *schema.ResourceData, meta inte

d.SetId(aws.StringValue(output.Name))

if _, err := waitLedgerCreated(ctx, conn, d.Id()); err != nil {
if _, err := waitLedgerCreated(ctx, conn, d.Timeout(schema.TimeoutCreate), d.Id()); err != nil {
return diag.Errorf("waiting for QLDB Ledger (%s) create: %s", d.Id(), err)
}

Expand Down Expand Up @@ -217,7 +222,7 @@ func resourceLedgerDelete(ctx context.Context, d *schema.ResourceData, meta inte
return diag.Errorf("deleting QLDB Ledger (%s): %s", d.Id(), err)
}

if _, err := waitLedgerDeleted(ctx, conn, d.Id()); err != nil {
if _, err := waitLedgerDeleted(ctx, conn, d.Timeout(schema.TimeoutDelete), d.Id()); err != nil {
return diag.Errorf("waiting for QLDB Ledger (%s) delete: %s", d.Id(), err)
}

Expand Down Expand Up @@ -272,12 +277,12 @@ func statusLedgerState(ctx context.Context, conn *qldb.QLDB, name string) resour
}
}

func waitLedgerCreated(ctx context.Context, conn *qldb.QLDB, name string) (*qldb.DescribeLedgerOutput, error) {
func waitLedgerCreated(ctx context.Context, conn *qldb.QLDB, timeout time.Duration, name string) (*qldb.DescribeLedgerOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{qldb.LedgerStateCreating},
Target: []string{qldb.LedgerStateActive},
Refresh: statusLedgerState(ctx, conn, name),
Timeout: 8 * time.Minute,
Timeout: timeout,
MinTimeout: 3 * time.Second,
}

Expand All @@ -290,12 +295,12 @@ func waitLedgerCreated(ctx context.Context, conn *qldb.QLDB, name string) (*qldb
return nil, err
}

func waitLedgerDeleted(ctx context.Context, conn *qldb.QLDB, name string) (*qldb.DescribeLedgerOutput, error) {
func waitLedgerDeleted(ctx context.Context, conn *qldb.QLDB, timeout time.Duration, name string) (*qldb.DescribeLedgerOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{qldb.LedgerStateActive, qldb.LedgerStateDeleting},
Target: []string{},
Refresh: statusLedgerState(ctx, conn, name),
Timeout: 5 * time.Minute,
Timeout: timeout,
MinTimeout: 1 * time.Second,
}

Expand Down
7 changes: 7 additions & 0 deletions website/docs/r/qldb_ledger.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ In addition to all arguments above, the following attributes are exported:
* `arn` - The ARN of the QLDB Ledger
* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block).

## Timeouts

[Configuration options](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts):

- `create` - (Default `10m`)
- `delete` - (Default `10m`)

## Import

QLDB Ledgers can be imported using the `name`, e.g.,
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/rds_cluster_activity_stream.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Database Activity Streams have some limits and requirements, refer to the [Monit

~> **Note:** This resource always calls the RDS [`StartActivityStream`][2] API with the `ApplyImmediately` parameter set to `true`. This is because the Terraform needs the activity stream to be started in order for it to get the associated attributes.

~> **Note:** This resource depends on having at least one `aws_rds_cluster_instance` created. To avoid race conditions when all resources are being created together, add an explicit resource reference using the [resource `depends_on` meta-argument](/docs/configuration/resources.html#depends_on-explicit-resource-dependencies).
~> **Note:** This resource depends on having at least one `aws_rds_cluster_instance` created. To avoid race conditions when all resources are being created together, add an explicit resource reference using the [resource `depends_on` meta-argument](https://www.terraform.io/docs/configuration/resources.html#depends_on-explicit-resource-dependencies).

~> **Note:** This resource is available in all regions except the following: `cn-north-1`, `cn-northwest-1`, `us-gov-east-1`, `us-gov-west-1`

Expand Down

0 comments on commit a9ad032

Please sign in to comment.