Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Resource: aws_quicksight_refresh_schedule #30841

Merged
merged 4 commits into from
Apr 25, 2023

Conversation

g-dx
Copy link
Contributor

@g-dx g-dx commented Apr 20, 2023

Description

This PR adds a new aws_quicksight_refresh_schedule resource, allowing practitioners to manage scheduled refreshes of Quicksight data sets via Terraform.

Relations

Closes #30788
Relates To #10990 & #30744

References

Output from Acceptance Testing

make testacc PKG=quicksight TESTS=TestAccQuickSightRefreshSchedule_
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/quicksight/... -v -count 1 -parallel 20 -run='TestAccQuickSightRefreshSchedule_'  -timeout 180m
=== RUN   TestAccQuickSightRefreshSchedule_basic
=== PAUSE TestAccQuickSightRefreshSchedule_basic
=== RUN   TestAccQuickSightRefreshSchedule_disappears
=== PAUSE TestAccQuickSightRefreshSchedule_disappears
=== RUN   TestAccQuickSightRefreshSchedule_weeklyRefresh
=== PAUSE TestAccQuickSightRefreshSchedule_weeklyRefresh
=== RUN   TestAccQuickSightRefreshSchedule_monthlyRefresh
=== PAUSE TestAccQuickSightRefreshSchedule_monthlyRefresh
=== CONT  TestAccQuickSightRefreshSchedule_basic
=== CONT  TestAccQuickSightRefreshSchedule_weeklyRefresh
=== CONT  TestAccQuickSightRefreshSchedule_disappears
=== CONT  TestAccQuickSightRefreshSchedule_monthlyRefresh
--- PASS: TestAccQuickSightRefreshSchedule_disappears (27.80s)
--- PASS: TestAccQuickSightRefreshSchedule_weeklyRefresh (29.59s)
--- PASS: TestAccQuickSightRefreshSchedule_basic (30.83s)
--- PASS: TestAccQuickSightRefreshSchedule_monthlyRefresh (31.13s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/quicksight	31.218s

@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. generators Relates to code generators. service/quicksight Issues and PRs that pertain to the quicksight service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XL Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. labels Apr 20, 2023
@g-dx g-dx force-pushed the f-aws_quicksight_refresh_schedule branch 4 times, most recently from 5b7c943 to 5dbd369 Compare April 20, 2023 12:36
@jar-b jar-b removed the needs-triage Waiting for first response or review from a maintainer. label Apr 20, 2023
@g-dx
Copy link
Contributor Author

g-dx commented Apr 21, 2023

@jar-b - after further reading of the API docs I've realised that refresh schedules can be created from data sets which do not have refresh properties defined. The only requirement is that they must be of FULL_REFRESH type rather than INCREMENTAL_REFRESH.

Accordingly, I've reworked the acceptance tests in this PR to use QuickSight S3 data sources, as is done in the aws_quicksight_data_set tests, rather than Athena which avoids the problems you encountered on my other PR here: #30778 (comment)

As such this PR is ready to review and land! 👌

@g-dx g-dx force-pushed the f-aws_quicksight_refresh_schedule branch 3 times, most recently from 5e98179 to b02a9b1 Compare April 22, 2023 07:44
Copy link
Member

@jar-b jar-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks in great shape, and really impressive to see a Plugin-Framework based resource given we haven't published any contributor documentation yet!

I do have one general suggestion, which is to align the schema a bit more closely with the API:

resource "aws_quicksight_refresh_schedule" "example" {
  # This is returned in both the root and inside the "RefreshSchedule" field of the 
  # DescribeRefreshSchedule API. To align with most other resources, this can stay 
  # at the schema root.
  arn =

  # Because this is required for delete calls (and the current Terraform ID), this could 
  # reasonably move into the root schema, despite technically being sent inside the 
  # schedule object for both create and update API calls.
  schedule_id = 

  aws_account_id =
  data_set_id    =

  schedule {
    refresh_type          = 
    # remove from here if moving to root
    schedule_id           = 
    start_after_date_time =
    schedule_frequency {
      interval        =
      time_of_the_day =
      timezone        =
      refresh_on_day {
        day_of_month =
        day_of_week  =
      }
    }
  }
}

The justification behind this is explained in the HashiCorp plugin best practices documentation, but specific to the AWS provider this design allows practitioners to swap more seamlessly between other tools (CLI, SDKs, etc.) and the Terraform provider.

In this case, the APIs do have some strange characteristics - such as Create using a Schedule field, while Describe calls it RefreshSchedule, or Arn being returned in two different levels of the Describe response - but moving most of the attributes inside a root schedule object is slightly more consistent with the AWS APIs.

@g-dx
Copy link
Contributor Author

g-dx commented Apr 24, 2023

@jar-b - thanks for the review.

Will make those changes now.

@g-dx g-dx force-pushed the f-aws_quicksight_refresh_schedule branch 4 times, most recently from 3cf4d39 to 1cf338a Compare April 24, 2023 20:26
@g-dx
Copy link
Contributor Author

g-dx commented Apr 24, 2023

@jar-b - that should be those changes all ready.

I went with the following resource structure in the end:

resource "aws_quicksight_refresh_schedule" "schedule" {
  arn            = "..."
  aws_account_id = "0123456789"
  data_set_id    = "id"
  schedule_id    = "example"

  schedule {
    refresh_type          = "FULL_REFRESH"
    start_after_date_time = "2023-12-18T00:00:00",
    schedule_frequency {
      interval        = "WEEKLY"
      time_of_the_day = "00:00"
      timezone        = "Europe/London"
      refresh_on_day {
        day_of_month = "1"
        day_of_week  = "MONDAY"
      }
    }
  }
}

Not exactly sure how I managed to misread the API structure so badly in the first place!

@g-dx g-dx force-pushed the f-aws_quicksight_refresh_schedule branch from 1cf338a to e80d508 Compare April 24, 2023 20:34
@g-dx g-dx force-pushed the f-aws_quicksight_refresh_schedule branch from e80d508 to 92b4e9e Compare April 25, 2023 07:16
Copy link
Member

@jar-b jar-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

$ make testacc PKG=quicksight TESTS=TestAccQuickSightRefreshSchedule_
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/quicksight/... -v -count 1 -parallel 20 -run='TestAccQuickSightRefreshSchedule_'  -timeout 180m
=== RUN   TestAccQuickSightRefreshSchedule_basic
=== PAUSE TestAccQuickSightRefreshSchedule_basic
=== RUN   TestAccQuickSightRefreshSchedule_disappears
=== PAUSE TestAccQuickSightRefreshSchedule_disappears
=== RUN   TestAccQuickSightRefreshSchedule_weeklyRefresh
=== PAUSE TestAccQuickSightRefreshSchedule_weeklyRefresh
=== RUN   TestAccQuickSightRefreshSchedule_monthlyRefresh
=== PAUSE TestAccQuickSightRefreshSchedule_monthlyRefresh
=== CONT  TestAccQuickSightRefreshSchedule_basic
=== CONT  TestAccQuickSightRefreshSchedule_weeklyRefresh
=== CONT  TestAccQuickSightRefreshSchedule_disappears
=== CONT  TestAccQuickSightRefreshSchedule_monthlyRefresh
--- PASS: TestAccQuickSightRefreshSchedule_disappears (29.51s)
--- PASS: TestAccQuickSightRefreshSchedule_weeklyRefresh (31.97s)
--- PASS: TestAccQuickSightRefreshSchedule_monthlyRefresh (32.03s)
--- PASS: TestAccQuickSightRefreshSchedule_basic (32.21s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/quicksight 35.375s

@jar-b jar-b merged commit 15f4d39 into hashicorp:main Apr 25, 2023
@github-actions github-actions bot added this to the v4.65.0 milestone Apr 25, 2023
@jar-b
Copy link
Member

jar-b commented Apr 25, 2023

Thanks for your contribution, @g-dx! 🥇 Really well done!

@g-dx g-dx deleted the f-aws_quicksight_refresh_schedule branch April 25, 2023 21:04
@github-actions
Copy link

This functionality has been released in v4.65.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. generators Relates to code generators. service/quicksight Issues and PRs that pertain to the quicksight service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New Resource]: aws_quicksight_refresh_schedule
2 participants