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 & data source: aws_grafana_workspace #22874

Merged
merged 52 commits into from
Feb 16, 2022

Conversation

AlexanderSchiff
Copy link
Contributor

@AlexanderSchiff AlexanderSchiff commented Feb 1, 2022

Community Note

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

Closes #16789

Output from acceptance testing:

$ make testacc TESTS=TestAccXXX PKG=grafana

...

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. size/XL Managed by automation to categorize the size of a PR. service/grafana Issues and PRs that pertain to the grafana service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Feb 1, 2022
@github-actions github-actions bot added the provider Pertains to the provider itself, rather than any interaction with AWS. label Feb 1, 2022
@AlexanderSchiff AlexanderSchiff marked this pull request as ready for review February 1, 2022 18:11
@justinretzolk justinretzolk added new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels Feb 1, 2022
@AlexanderSchiff
Copy link
Contributor Author

I need some help with my tests:

=== RUN   TestAccGrafanaWorkspace_basic
=== PAUSE TestAccGrafanaWorkspace_basic
=== CONT  TestAccGrafanaWorkspace_basic
    workspace_test.go:20: Step 1/2 error: After applying this test step, the plan was not empty.
        stdout:
        
        
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        
        Terraform will perform the following actions:
        
          # aws_grafana_workspace.test will be updated in-place
          ~ resource "aws_grafana_workspace" "test" {
                id                        = "g-545541a952"
                name                      = "tf-acc-test-3194149265356548228"
              - saml_configuration_status = "NOT_CONFIGURED" -> null
              - status                    = "ACTIVE" -> null
                # (4 unchanged attributes hidden)
            }
        
        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccGrafanaWorkspace_basic (154.84s)

FAIL

import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/managedgrafana"
"github.com/hashicorp/aws-sdk-go-base/tfawserr"
Copy link
Contributor

Choose a reason for hiding this comment

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

You will have to make changes to the import of tfawserr as required by #22860.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made that change. I am still getting an error on my tests, I am not sure what is wrong:

=== RUN   TestAccGrafanaWorkspace_basic
=== PAUSE TestAccGrafanaWorkspace_basic
=== CONT  TestAccGrafanaWorkspace_basic
=== CONT  TestAccGrafanaWorkspace_basic
    workspace_test.go:20: Step 1/2 error: After applying this test step, the plan was not empty.
        stdout:
        
        
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        
        Terraform will perform the following actions:
        
          # aws_grafana_workspace.test will be updated in-place
          ~ resource "aws_grafana_workspace" "test" {
                id                        = "g-717dfc8e45"
                name                      = "tf-acc-test-7310005638429688407"
              - saml_configuration_status = "NOT_CONFIGURED" -> null
              - status                    = "ACTIVE" -> null
                # (4 unchanged attributes hidden)
            }
        
        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccGrafanaWorkspace_basic (165.66s)

@github-actions
Copy link

github-actions bot commented Feb 3, 2022

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.

@github-actions
Copy link

github-actions bot commented Feb 3, 2022

Thank you for your contribution! 🚀

Please note that the CHANGELOG.md file contents are handled by the maintainers during merge. This is to prevent pull request merge conflicts, especially for contributions which may not be merged immediately. Please see the Contributing Guide for additional pull request review items.

Remove any changes to the CHANGELOG.md file and commit them in this pull request to prevent delays with reviewing and potentially merging this pull request.

Acceptance test output:

% make testacc TESTS=TestAccGrafanaWorkspace_saml PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafanaWorkspace_saml'  -timeout 180m
=== RUN   TestAccGrafanaWorkspace_saml
=== PAUSE TestAccGrafanaWorkspace_saml
=== CONT  TestAccGrafanaWorkspace_saml
--- PASS: TestAccGrafanaWorkspace_saml (155.85s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	159.551s
Acceptance test output:

% make testacc TESTS=TestAccGrafanaWorkspace_dataSources PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafanaWorkspace_dataSources'  -timeout 180m
=== RUN   TestAccGrafanaWorkspace_dataSources
=== PAUSE TestAccGrafanaWorkspace_dataSources
=== CONT  TestAccGrafanaWorkspace_dataSources
--- PASS: TestAccGrafanaWorkspace_dataSources (150.78s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	154.661s
Acceptance test output:

% make testacc TESTS=TestAccGrafanaWorkspace_permissionType PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafanaWorkspace_permissionType'  -timeout 180m
=== RUN   TestAccGrafanaWorkspace_permissionType
=== PAUSE TestAccGrafanaWorkspace_permissionType
=== CONT  TestAccGrafanaWorkspace_permissionType
--- PASS: TestAccGrafanaWorkspace_permissionType (159.83s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	163.457s
Acceptance test output:

% make testacc TESTS=TestAccGrafanaWorkspace_notificationDestinations PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafanaWorkspace_notificationDestinations'  -timeout 180m
=== RUN   TestAccGrafanaWorkspace_notificationDestinations
=== PAUSE TestAccGrafanaWorkspace_notificationDestinations
=== CONT  TestAccGrafanaWorkspace_notificationDestinations
--- PASS: TestAccGrafanaWorkspace_notificationDestinations (169.15s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	172.963s
Acceptance test output:

% make testacc TESTS=TestAccGrafanaWorkspace_organization PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafanaWorkspace_organization'  -timeout 180m
=== RUN   TestAccGrafanaWorkspace_organization
=== PAUSE TestAccGrafanaWorkspace_organization
=== CONT  TestAccGrafanaWorkspace_organization
    acctest.go:710: this AWS account must be the management account of an AWS Organization
--- SKIP: TestAccGrafanaWorkspace_organization (1.37s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	5.602s
% make testacc TESTS=TestAccGrafanaWorkspace_organization PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafanaWorkspace_organization'  -timeout 180m
=== RUN   TestAccGrafanaWorkspace_organization
=== PAUSE TestAccGrafanaWorkspace_organization
=== CONT  TestAccGrafanaWorkspace_organization
--- PASS: TestAccGrafanaWorkspace_organization (149.87s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	153.118s
Acceptance test output:

% make testacc TESTS=TestAccGrafanaWorkspace_sso PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafanaWorkspace_sso'  -timeout 180m
=== RUN   TestAccGrafanaWorkspace_sso
=== PAUSE TestAccGrafanaWorkspace_sso
=== CONT  TestAccGrafanaWorkspace_sso
    acctest.go:731: skipping tests: AccessDeniedException: User: arn:aws:sts::123456789012:assumed-role/xyz is not authorized to perform: sso:ListInstances
--- SKIP: TestAccGrafanaWorkspace_sso (5.50s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	10.984s
% make testacc TESTS=TestAccGrafanaWorkspace_sso PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafanaWorkspace_sso'  -timeout 180m
=== RUN   TestAccGrafanaWorkspace_sso
=== PAUSE TestAccGrafanaWorkspace_sso
=== CONT  TestAccGrafanaWorkspace_sso
--- PASS: TestAccGrafanaWorkspace_sso (151.30s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	156.984s
Acceptance test output:

% make testacc TESTS=TestAccGrafanaWorkspace_disappears PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafanaWorkspace_disappears'  -timeout 180m
=== RUN   TestAccGrafanaWorkspace_disappears
=== PAUSE TestAccGrafanaWorkspace_disappears
=== CONT  TestAccGrafanaWorkspace_disappears
--- PASS: TestAccGrafanaWorkspace_disappears (149.16s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	154.768s
…w, otherwise:

% make testacc TESTS=TestAccGrafanaWorkspace_updateAuthenticationProvider PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafanaWorkspace_updateAuthenticationProvider'  -timeout 180m
=== RUN   TestAccGrafanaWorkspace_updateAuthenticationProvider
=== PAUSE TestAccGrafanaWorkspace_updateAuthenticationProvider
=== CONT  TestAccGrafanaWorkspace_updateAuthenticationProvider
    workspace_test.go:132: Step 3/3 error: Error running apply: exit status 1

        Error: error updating Grafana Workspace (g-c1118c98ae) authentication providers: ValidationException: To enable SAML you must provide the SAML configuration struct.
        {
          RespMetadata: {
            StatusCode: 400,
            RequestID: "f65d4348-0f1d-4093-ac6a-ee61531eeea2"
          },
          Message_: "To enable SAML you must provide the SAML configuration struct."
        }

          with aws_grafana_workspace.test,
          on terraform_plugin_test.tf line 20, in resource "aws_grafana_workspace" "test":
          20: resource "aws_grafana_workspace" "test" {

--- FAIL: TestAccGrafanaWorkspace_updateAuthenticationProvider (158.85s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	164.194s
FAIL
make: *** [testacc] Error 1

Serialize acceptance tests.

Acceptance test output:

% make testacc TESTS=TestAccGrafana_serial PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafana_serial'  -timeout 180m
=== RUN   TestAccGrafana_serial
=== RUN   TestAccGrafana_serial/Workspace
=== RUN   TestAccGrafana_serial/Workspace/saml
=== RUN   TestAccGrafana_serial/Workspace/sso
    acctest.go:731: skipping tests: AccessDeniedException: User: arn:aws:sts::187416307283:assumed-role/terraform_team1_dev-developer/kewbank@hashicorp.com is not authorized to perform: sso:ListInstances
=== RUN   TestAccGrafana_serial/Workspace/disappears
=== RUN   TestAccGrafana_serial/Workspace/organization
    acctest.go:711: this AWS account must be the management account of an AWS Organization
=== RUN   TestAccGrafana_serial/Workspace/dataSources
=== RUN   TestAccGrafana_serial/Workspace/permissionType
=== RUN   TestAccGrafana_serial/Workspace/notificationDestinations
--- PASS: TestAccGrafana_serial (993.54s)
    --- PASS: TestAccGrafana_serial/Workspace (993.54s)
        --- PASS: TestAccGrafana_serial/Workspace/saml (316.99s)
        --- SKIP: TestAccGrafana_serial/Workspace/sso (0.42s)
        --- PASS: TestAccGrafana_serial/Workspace/disappears (147.69s)
        --- SKIP: TestAccGrafana_serial/Workspace/organization (0.32s)
        --- PASS: TestAccGrafana_serial/Workspace/dataSources (160.39s)
        --- PASS: TestAccGrafana_serial/Workspace/permissionType (185.30s)
        --- PASS: TestAccGrafana_serial/Workspace/notificationDestinations (182.43s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	999.459s
Acceptance test output:

% make testacc TESTS=TestAccGrafana_serial/DataSource PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafana_serial/DataSource'  -timeout 180m
=== RUN   TestAccGrafana_serial
=== RUN   TestAccGrafana_serial/DataSource
=== RUN   TestAccGrafana_serial/DataSource/basic
--- PASS: TestAccGrafana_serial (183.03s)
    --- PASS: TestAccGrafana_serial/DataSource (183.03s)
        --- PASS: TestAccGrafana_serial/DataSource/basic (183.03s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	188.846s
@ewbankkit ewbankkit changed the title aws_grafana_workspace New resource & data source: aws_grafana_workspace Feb 16, 2022
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

Commercial
% make testacc TESTS=TestAccGrafana_serial PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafana_serial'  -timeout 180m
=== RUN   TestAccGrafana_serial
=== RUN   TestAccGrafana_serial/Workspace
=== RUN   TestAccGrafana_serial/Workspace/dataSources
=== RUN   TestAccGrafana_serial/Workspace/permissionType
=== RUN   TestAccGrafana_serial/Workspace/notificationDestinations
=== RUN   TestAccGrafana_serial/Workspace/saml
=== RUN   TestAccGrafana_serial/Workspace/sso
=== RUN   TestAccGrafana_serial/Workspace/disappears
=== RUN   TestAccGrafana_serial/Workspace/organization
=== RUN   TestAccGrafana_serial/DataSource
=== RUN   TestAccGrafana_serial/DataSource/basic
--- PASS: TestAccGrafana_serial (1328.09s)
    --- PASS: TestAccGrafana_serial/Workspace (1182.73s)
        --- PASS: TestAccGrafana_serial/Workspace/dataSources (155.28s)
        --- PASS: TestAccGrafana_serial/Workspace/permissionType (225.56s)
        --- PASS: TestAccGrafana_serial/Workspace/notificationDestinations (169.48s)
        --- PASS: TestAccGrafana_serial/Workspace/saml (180.94s)
        --- PASS: TestAccGrafana_serial/Workspace/sso (154.15s)
        --- PASS: TestAccGrafana_serial/Workspace/disappears (145.36s)
        --- PASS: TestAccGrafana_serial/Workspace/organization (151.96s)
    --- PASS: TestAccGrafana_serial/DataSource (145.36s)
        --- PASS: TestAccGrafana_serial/DataSource/basic (145.36s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	1331.810s
GovCloud
% make testacc TESTS=TestAccGrafana_serial PKG=grafana 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20 -run='TestAccGrafana_serial'  -timeout 180m
=== RUN   TestAccGrafana_serial
=== RUN   TestAccGrafana_serial/DataSource
=== RUN   TestAccGrafana_serial/DataSource/basic
    acctest.go:610: skipping tests; partition aws-us-gov does not support grafana service
=== RUN   TestAccGrafana_serial/Workspace
=== RUN   TestAccGrafana_serial/Workspace/disappears
    acctest.go:610: skipping tests; partition aws-us-gov does not support grafana service
=== RUN   TestAccGrafana_serial/Workspace/organization
    acctest.go:610: skipping tests; partition aws-us-gov does not support grafana service
=== RUN   TestAccGrafana_serial/Workspace/dataSources
    acctest.go:610: skipping tests; partition aws-us-gov does not support grafana service
=== RUN   TestAccGrafana_serial/Workspace/permissionType
    acctest.go:610: skipping tests; partition aws-us-gov does not support grafana service
=== RUN   TestAccGrafana_serial/Workspace/notificationDestinations
    acctest.go:610: skipping tests; partition aws-us-gov does not support grafana service
=== RUN   TestAccGrafana_serial/Workspace/saml
    acctest.go:610: skipping tests; partition aws-us-gov does not support grafana service
=== RUN   TestAccGrafana_serial/Workspace/sso
    acctest.go:610: skipping tests; partition aws-us-gov does not support grafana service
--- PASS: TestAccGrafana_serial (1.03s)
    --- PASS: TestAccGrafana_serial/DataSource (1.03s)
        --- SKIP: TestAccGrafana_serial/DataSource/basic (1.03s)
    --- PASS: TestAccGrafana_serial/Workspace (0.00s)
        --- SKIP: TestAccGrafana_serial/Workspace/disappears (0.00s)
        --- SKIP: TestAccGrafana_serial/Workspace/organization (0.00s)
        --- SKIP: TestAccGrafana_serial/Workspace/dataSources (0.00s)
        --- SKIP: TestAccGrafana_serial/Workspace/permissionType (0.00s)
        --- SKIP: TestAccGrafana_serial/Workspace/notificationDestinations (0.00s)
        --- SKIP: TestAccGrafana_serial/Workspace/saml (0.00s)
        --- SKIP: TestAccGrafana_serial/Workspace/sso (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	4.776s

@ewbankkit
Copy link
Contributor

ewbankkit commented Feb 16, 2022

@AlexanderSchiff Thanks for the contribution 🎉 👏.
Overall the PR was in great shape.
I made some minor changes:

  • Removed created_date, last_updated_date and status from the resource but kept them in the data source
  • Made name Computed as if it's not specified in configuration AWS sets it to the workspace ID
  • Made authentication_providers ForceNew as updating workspace authentication to SAML requires a complex configuration - Maybe this can be a future additional resource
  • Named the required argument for the data source workspace_id

@ewbankkit ewbankkit merged commit 382127c into hashicorp:main Feb 16, 2022
@github-actions github-actions bot modified the milestones: Roadmap, v4.2.0 Feb 16, 2022
@ewbankkit ewbankkit modified the milestones: v4.2.0, Roadmap Feb 16, 2022
@ewbankkit ewbankkit mentioned this pull request Feb 16, 2022
@github-actions
Copy link

This functionality has been released in v4.2.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 14, 2022
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. new-data-source Introduces a new data source. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. 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.

Add support for Amazon Managed Service for Grafana
3 participants