pulumi-aws icon indicating copy to clipboard operation
pulumi-aws copied to clipboard

Refreshing state with redshiftdata.Statement fails after query result expires

Open nickroberts opened this issue 3 years ago • 2 comments

What happened?

After a certain amount of time (3 days, it looks like), when Pulumi tries to refresh the state that includes a Redshift Data Statement, it fails.

Diagnostics:
  aws:redshiftdata:Statement (supplementalEppEncountersView):
    error: Preview failed: refreshing urn:pulumi:pdfs.qa::pdfs::aws:redshiftdata/statement:Statement::supplementalEppEncountersView: 1 error occurred:
    	* reading Redshift Data Statement (284bfee4-49dc-4ad1-ac90-0bba0580d568): ValidationException: Could not retrieve the query result as it has expired after 1658071606.

  pulumi:pulumi:Stack (pdfs-pdfs.qa):
    error: preview failed

Steps to reproduce

  1. Add a Redshift Data Statement:
const example = new aws.redshiftdata.Statement("example", {
    clusterIdentifier: aws_redshift_cluster.example.cluster_identifier,
    database: aws_redshift_cluster.example.database_name,
    dbUser: aws_redshift_cluster.example.master_username,
    sql: "CREATE GROUP group_name;",
});
  1. Refresh and update your stack:
pulumi up -ry
  1. Wait 3 days (or possibly manually change the id in your Pulumi state, but I'm not sure if that will work).

  2. Refresh (or refresh and update):

pulumi up -ry

It will fail with the above mentioned error when refreshing the state.

Expected Behavior

The state refreshes, and does not fail.

Actual Behavior

It fails while refreshing the state:

Diagnostics:
  aws:redshiftdata:Statement (supplementalEppEncountersView):
    error: Preview failed: refreshing urn:pulumi:pdfs.qa::pdfs::aws:redshiftdata/statement:Statement::supplementalEppEncountersView: 1 error occurred:
    	* reading Redshift Data Statement (284bfee4-49dc-4ad1-ac90-0bba0580d568): ValidationException: Could not retrieve the query result as it has expired after 1658071606.

  pulumi:pulumi:Stack (pdfs-pdfs.qa):
    error: preview failed

Versions used

CLI Version 3.36.0 Go Version go1.18.4 Go Compiler gc

Host OS darwin Version 13.0 Arch arm64

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

nickroberts avatar Jul 18 '22 15:07 nickroberts

Thanks for opening the issue and also validating this occurs in the terraform provider as well @nickroberts! We will track https://github.com/hashicorp/terraform-provider-aws/issues/25882 and update to pull in the fix.

Side note but I am not sure what the provider can do in this situation since the query has expired. The best that can be done is to recreate the resource? The provider itself can't interpret the expiration as the statement being deleted since the statement would then be leaked. Perhaps you are better off modeling the statement with the aws client in your chosen language instead (within or separate from the pulumi code).

viveklak avatar Jul 19 '22 22:07 viveklak

Yea...we were trying to use it as a quick and dirty way to create a view in Redshift. Looks like we are going to have to figure out a different way (which we need to, anyways, for more robust db migration scripts). Going to use boto3 and python to quickly handle this, in the meantime! Thanks!

nickroberts avatar Jul 20 '22 16:07 nickroberts