diff --git a/.changelog/35955.txt b/.changelog/35955.txt new file mode 100644 index 00000000000..2d69c72de81 --- /dev/null +++ b/.changelog/35955.txt @@ -0,0 +1,7 @@ +```release-note:enhancement +resource/aws_instance: Add configurable `read` timeout +``` + +```release-note:enhancement +resource/aws_spot_instance_request: Add configurable `read` timeout +``` \ No newline at end of file diff --git a/internal/service/ec2/ec2_instance.go b/internal/service/ec2/ec2_instance.go index 3043bf5652e..5429c1cc0e5 100644 --- a/internal/service/ec2/ec2_instance.go +++ b/internal/service/ec2/ec2_instance.go @@ -58,6 +58,7 @@ func ResourceInstance() *schema.Resource { Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(10 * time.Minute), + Read: schema.DefaultTimeout(15 * time.Minute), Update: schema.DefaultTimeout(10 * time.Minute), Delete: schema.DefaultTimeout(20 * time.Minute), }, @@ -1385,7 +1386,7 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte } if d.Get("get_password_data").(bool) { - passwordData, err := getInstancePasswordData(ctx, aws.StringValue(instance.InstanceId), conn) + passwordData, err := getInstancePasswordData(ctx, aws.StringValue(instance.InstanceId), conn, d.Timeout(schema.TimeoutRead)) if err != nil { return sdkdiag.AppendErrorf(diags, "reading EC2 Instance (%s): %s", d.Id(), err) } @@ -2680,7 +2681,7 @@ func readInstanceShutdownBehavior(ctx context.Context, d *schema.ResourceData, c return nil } -func getInstancePasswordData(ctx context.Context, instanceID string, conn *ec2.EC2) (string, error) { +func getInstancePasswordData(ctx context.Context, instanceID string, conn *ec2.EC2, timeout time.Duration) (string, error) { log.Printf("[INFO] Reading password data for instance %s", instanceID) var passwordData string @@ -2688,7 +2689,7 @@ func getInstancePasswordData(ctx context.Context, instanceID string, conn *ec2.E input := &ec2.GetPasswordDataInput{ InstanceId: aws.String(instanceID), } - err := retry.RetryContext(ctx, 15*time.Minute, func() *retry.RetryError { + err := retry.RetryContext(ctx, timeout, func() *retry.RetryError { var err error resp, err = conn.GetPasswordDataWithContext(ctx, input) diff --git a/internal/service/ec2/ec2_instance_data_source.go b/internal/service/ec2/ec2_instance_data_source.go index b56374c6163..3a9b5b44fb0 100644 --- a/internal/service/ec2/ec2_instance_data_source.go +++ b/internal/service/ec2/ec2_instance_data_source.go @@ -435,7 +435,7 @@ func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta in } if d.Get("get_password_data").(bool) { - passwordData, err := getInstancePasswordData(ctx, aws.StringValue(instance.InstanceId), conn) + passwordData, err := getInstancePasswordData(ctx, aws.StringValue(instance.InstanceId), conn, d.Timeout(schema.TimeoutRead)) if err != nil { return sdkdiag.AppendErrorf(diags, "reading EC2 Instance (%s): %s", aws.StringValue(instance.InstanceId), err) } diff --git a/internal/service/ec2/ec2_spot_instance_request.go b/internal/service/ec2/ec2_spot_instance_request.go index db39e66c415..4cd8c7519e7 100644 --- a/internal/service/ec2/ec2_spot_instance_request.go +++ b/internal/service/ec2/ec2_spot_instance_request.go @@ -40,6 +40,7 @@ func ResourceSpotInstanceRequest() *schema.Resource { Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(10 * time.Minute), + Read: schema.DefaultTimeout(15 * time.Minute), Delete: schema.DefaultTimeout(20 * time.Minute), }, @@ -348,7 +349,7 @@ func readInstance(ctx context.Context, d *schema.ResourceData, meta interface{}) } if d.Get("get_password_data").(bool) { - passwordData, err := getInstancePasswordData(ctx, *instance.InstanceId, conn) + passwordData, err := getInstancePasswordData(ctx, *instance.InstanceId, conn, d.Timeout(schema.TimeoutRead)) if err != nil { return sdkdiag.AppendFromErr(diags, err) } diff --git a/website/docs/r/instance.html.markdown b/website/docs/r/instance.html.markdown index d502a40f04f..e51894b20c1 100644 --- a/website/docs/r/instance.html.markdown +++ b/website/docs/r/instance.html.markdown @@ -440,6 +440,7 @@ For `instance_market_options`, in addition to the arguments above, the following [Configuration options](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts): * `create` - (Default `10m`) +* `read` - (Default `15m`) * `update` - (Default `10m`) * `delete` - (Default `20m`) diff --git a/website/docs/r/spot_instance_request.html.markdown b/website/docs/r/spot_instance_request.html.markdown index 1db8da80596..d4334f7503d 100644 --- a/website/docs/r/spot_instance_request.html.markdown +++ b/website/docs/r/spot_instance_request.html.markdown @@ -101,4 +101,5 @@ should only be used for informational purposes, not for resource dependencies: [Configuration options](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts): * `create` - (Default `10m`) +* `read` - (Default `15m`) * `delete` - (Default `20m`)