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

Add Grafana service account #38101

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

bonclay7
Copy link
Contributor

@bonclay7 bonclay7 commented Jun 24, 2024

Description

Adds support for Grafana Service Account with Amazon Managed Grafana

Relations

Closes #37645

References

Output from Acceptance Testing

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.4 test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafanaWorkspaceServiceAccountToken'  -timeout 360m
=== RUN   TestAccGrafanaWorkspaceServiceAccountToken_basic
=== PAUSE TestAccGrafanaWorkspaceServiceAccountToken_basic
=== RUN   TestAccGrafanaWorkspaceServiceAccountToken_disappears
=== PAUSE TestAccGrafanaWorkspaceServiceAccountToken_disappears
=== CONT  TestAccGrafanaWorkspaceServiceAccountToken_basic
=== CONT  TestAccGrafanaWorkspaceServiceAccountToken_disappears
--- PASS: TestAccGrafanaWorkspaceServiceAccountToken_basic (297.83s)
--- PASS: TestAccGrafanaWorkspaceServiceAccountToken_disappears (331.44s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	337.234s
...

@bonclay7 bonclay7 requested a review from a team as a code owner June 24, 2024 23:20
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.

@bonclay7 bonclay7 marked this pull request as draft June 24, 2024 23:20
@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. linter Pertains to changes to or issues with the various linters. client-connections Pertains to the AWS Client and service connections. generators Relates to code generators. service/grafana Issues and PRs that pertain to the grafana service. labels Jun 24, 2024
@terraform-aws-provider terraform-aws-provider bot added needs-triage Waiting for first response or review from a maintainer. partner Contribution from a partner. labels Jun 24, 2024
Copy link

Thank you for your contribution! 🚀

Please note that typically Go dependency changes are handled in this repository by dependabot or the maintainers. This is to prevent pull request merge conflicts and further delay reviews of contributions. Remove any changes to the go.mod or go.sum files and commit them into this pull request.

Additional details:

  • Check open pull requests with the dependencies label to view other dependency updates.
  • If this pull request includes an update the AWS Go SDK (or any other dependency) version, only updates submitted via dependabot will be merged. This pull request will need to remove these changes and will need to be rebased after the existing dependency update via dependabot has been merged for this pull request to be reviewed.
  • If this pull request is for supporting a new AWS service:
    • Ensure the new AWS service changes are following the Contributing Guide section on new services, in particular that the dependency addition and initial provider support are in a separate pull request from other changes (e.g. new resources). Contributions not following this item will not be reviewed until the changes are split.
    • If this pull request is already a separate pull request from the above item, you can ignore this message.

@justinretzolk justinretzolk added new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels Jun 25, 2024
@bonclay7 bonclay7 marked this pull request as ready for review June 26, 2024 21:03
@bonclay7
Copy link
Contributor Author

Got a few questions for reviewers myself

@@ -227,3 +227,4 @@ vpc_endpoint_id,VPCEndpointID
vpc_id,VPCID
vpc_security_group_ids,VPCSecurityGroupIDs
weight,Weight
workspace_id,WorkspaceID
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this names constant, but it triggers a refactor for all the places where there are string litterals with "workspace_id" https://github.com/hashicorp/terraform-provider-aws/actions/runs/9664687528/job/26659952436?pr=38101

Should I go ahead and use names.AttrWorkspaceID or should I revert this commit instead?

PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, names.Grafana) },
ErrorCheck: acctest.ErrorCheck(t, grafana.ServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckWorkspaceServiceAccountDestroy(ctx),
Copy link
Contributor Author

@bonclay7 bonclay7 Jun 26, 2024

Choose a reason for hiding this comment

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

CheckDestroy throws an error that looks like a race condition and I don't know how to fix it.

make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Building provider...
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.4 test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccWorkspaceServiceAccount'  -timeout 360m
=== RUN   TestAccWorkspaceServiceAccount_basic
=== PAUSE TestAccWorkspaceServiceAccount_basic
=== RUN   TestAccWorkspaceServiceAccount_disappears
=== PAUSE TestAccWorkspaceServiceAccount_disappears
=== CONT  TestAccWorkspaceServiceAccount_basic
=== CONT  TestAccWorkspaceServiceAccount_disappears
--- PASS: TestAccWorkspaceServiceAccount_disappears (339.76s)
=== NAME  TestAccWorkspaceServiceAccount_basic
    workspace_service_account_test.go:29: Error running post-test destroy, there may be dangling resources: operation error grafana: ListWorkspaceServiceAccounts, https response error StatusCode: 404, RequestID: 108fce02-80f4-49d1-8541-4d78d559a454, ResourceNotFoundException: Workspace with id=g-ca7016d798 of account=339743103717 does not exist.
--- FAIL: TestAccWorkspaceServiceAccount_basic (369.06s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	374.937s
FAIL
make: *** [testacc] Error 1

However, the same tests outside with a normal main.tf and apply/destroy do not generate any error. Any insights on how to move forward?

I think the workspace gets destroyed before the service token is deleted.

Copy link
Contributor Author

@bonclay7 bonclay7 Jun 27, 2024

Choose a reason for hiding this comment

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

used acctest.CheckDestroyNoop on CheckDestroy. Happy to revisit if there's another path

@bonclay7
Copy link
Contributor Author

bonclay7 commented Jun 26, 2024

3rd question - should the implementation of service account token (which share a lot with this PR) continue with the same PR or be separate and branched out of this one?

@bonclay7
Copy link
Contributor Author

any insights on this @justinretzolk @ewbankkit?

As service account by itself is not really useful, I merged locally my branch
on service account token. Happy to drop this commit if it needs to be submitted
separately

commit 6b70e6e59b7dc0bd1ac652ce3038413f65c11e8b
Author: Rodrigue Koffi <[email protected]>
Date:   Thu Jun 27 21:55:00 2024 +0200

    Add service account token doc

commit bd3fad4e84eb75815516cd658dc155ece76f5791
Author: Rodrigue Koffi <[email protected]>
Date:   Thu Jun 27 16:05:28 2024 +0200

    Optimize tests paths

commit 560148e983736a2e193442d24782e5c755be2fca
Author: Rodrigue Koffi <[email protected]>
Date:   Thu Jun 27 12:41:41 2024 +0200

    Add acceptance testing

commit 39090f6e22252ff979405715a6e0f094f383933b
Author: Rodrigue Koffi <[email protected]>
Date:   Thu Jun 27 11:32:00 2024 +0200

    Add service account token resource
@bonclay7
Copy link
Contributor Author

make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Building provider...
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.4 test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafanaWorkspaceServiceAccountToken'  -timeout 360m
=== RUN   TestAccGrafanaWorkspaceServiceAccountToken_basic
=== PAUSE TestAccGrafanaWorkspaceServiceAccountToken_basic
=== RUN   TestAccGrafanaWorkspaceServiceAccountToken_disappears
=== PAUSE TestAccGrafanaWorkspaceServiceAccountToken_disappears
=== CONT  TestAccGrafanaWorkspaceServiceAccountToken_basic
=== CONT  TestAccGrafanaWorkspaceServiceAccountToken_disappears
--- PASS: TestAccGrafanaWorkspaceServiceAccountToken_basic (297.83s)
--- PASS: TestAccGrafanaWorkspaceServiceAccountToken_disappears (331.44s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	337.234s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client-connections Pertains to the AWS Client and service connections. documentation Introduces or discusses updates to documentation. generators Relates to code generators. linter Pertains to changes to or issues with the various linters. new-resource Introduces a new resource. partner Contribution from a partner. service/grafana Issues and PRs that pertain to the grafana 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]: Add support for Grafana Service Account and Token
2 participants