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

Mark Grafana API key as sensitive. #34105

Merged
merged 15 commits into from
Nov 16, 2023

Conversation

jrouly
Copy link
Contributor

@jrouly jrouly commented Oct 25, 2023

Description

The aws_grafana_workspace_api_key resource creates a Grafana API Key. The key attribute contains the value of the key.

The key attribute is not currently marked as sensitive, despite containing an authentication credential. This PR marks it as sensitive.

Resolves #34106.
Closes #34417.

Output from Acceptance Testing

I am not sure what the expectations for acceptance testing are, given it may cost money to run. I ran them and there were some successes, some failures, likely due to external constraints on my environment. I also do not think any of these tests are relevant to the change included in this PR.

$ make testacc PKG=grafana
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/grafana/... -v -count 1 -parallel 20   -timeout 360m
=== RUN   TestAccGrafana_serial
=== PAUSE TestAccGrafana_serial
=== CONT  TestAccGrafana_serial
=== RUN   TestAccGrafana_serial/Workspace
=== RUN   TestAccGrafana_serial/Workspace/sso
    acctest.go:1017: skipping tests: AccessDeniedException: User: arn:aws:sts::REDACTED:assumed-role/REDACTED is not authorized to perform: sso:ListInstances
=== RUN   TestAccGrafana_serial/Workspace/notificationDestinations
=== RUN   TestAccGrafana_serial/Workspace/tags
=== RUN   TestAccGrafana_serial/Workspace/version
=== RUN   TestAccGrafana_serial/Workspace/vpc
=== RUN   TestAccGrafana_serial/Workspace/configuration
=== RUN   TestAccGrafana_serial/Workspace/networkAccess
=== RUN   TestAccGrafana_serial/Workspace/saml
=== RUN   TestAccGrafana_serial/Workspace/disappears
=== RUN   TestAccGrafana_serial/Workspace/organization
    acctest.go:979: 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/ApiKey
=== RUN   TestAccGrafana_serial/ApiKey/basic
=== RUN   TestAccGrafana_serial/DataSource
=== RUN   TestAccGrafana_serial/DataSource/basic
=== RUN   TestAccGrafana_serial/LicenseAssociation
=== RUN   TestAccGrafana_serial/LicenseAssociation/enterpriseFreeTrial
    license_association_test.go:27: Step 1/1 error: Error running apply: exit status 1

        Error: creating Grafana License Association: ValidationException: Active marketplace agreement not found
        {
          RespMetadata: {
            StatusCode: 400,
            RequestID: "3fcd5c51-74f8-4d1e-90e0-ae02ca55d64e"
          },
          Message_: "Active marketplace agreement not found"
        }

          with aws_grafana_license_association.test,
          on terraform_plugin_test.tf line 27, in resource "aws_grafana_license_association" "test":
          27: resource "aws_grafana_license_association" "test" {

=== RUN   TestAccGrafana_serial/SamlConfiguration
=== RUN   TestAccGrafana_serial/SamlConfiguration/basic
    workspace_saml_configuration_test.go:26: Step 1/1 error: Check failed: 5 errors occurred:
        	* Check 2/8 error: aws_grafana_workspace_saml_configuration.test: Attribute 'admin_role_values.#' expected "1", got "0"
        	* Check 3/8 error: aws_grafana_workspace_saml_configuration.test: Attribute 'admin_role_values.0' not found
        	* Check 4/8 error: aws_grafana_workspace_saml_configuration.test: Attribute 'editor_role_values.#' expected "1", got "0"
        	* Check 5/8 error: aws_grafana_workspace_saml_configuration.test: Attribute 'editor_role_values.0' not found
        	* Check 6/8 error: aws_grafana_workspace_saml_configuration.test: Attribute 'idp_metadata_xml' expected to be set

=== RUN   TestAccGrafana_serial/SamlConfiguration/loginValidity
    workspace_saml_configuration_test.go:55: Step 1/1 error: Check failed: 6 errors occurred:
        	* Check 2/9 error: aws_grafana_workspace_saml_configuration.test: Attribute 'admin_role_values.#' expected "1", got "0"
        	* Check 3/9 error: aws_grafana_workspace_saml_configuration.test: Attribute 'admin_role_values.0' not found
        	* Check 4/9 error: aws_grafana_workspace_saml_configuration.test: Attribute 'editor_role_values.#' expected "1", got "0"
        	* Check 5/9 error: aws_grafana_workspace_saml_configuration.test: Attribute 'editor_role_values.0' not found
        	* Check 6/9 error: aws_grafana_workspace_saml_configuration.test: Attribute 'idp_metadata_xml' expected to be set
        	* Check 8/9 error: aws_grafana_workspace_saml_configuration.test: Attribute 'login_validity_duration' expected "1440", got "0"

=== RUN   TestAccGrafana_serial/SamlConfiguration/assertions
    workspace_saml_configuration_test.go:85: Step 1/1 error: Check failed: 9 errors occurred:
        	* Check 2/15 error: aws_grafana_workspace_saml_configuration.test: Attribute 'admin_role_values.#' expected "1", got "0"
        	* Check 3/15 error: aws_grafana_workspace_saml_configuration.test: Attribute 'admin_role_values.0' not found
        	* Check 4/15 error: aws_grafana_workspace_saml_configuration.test: Attribute 'editor_role_values.#' expected "1", got "0"
        	* Check 5/15 error: aws_grafana_workspace_saml_configuration.test: Attribute 'editor_role_values.0' not found
        	* Check 6/15 error: aws_grafana_workspace_saml_configuration.test: Attribute 'idp_metadata_xml' expected to be set
        	* Check 9/15 error: aws_grafana_workspace_saml_configuration.test: Attribute 'idp_metadata_xml' expected to be set
        	* Check 10/15 error: aws_grafana_workspace_saml_configuration.test: Attribute 'groups_assertion' expected "groups", got ""
        	* Check 13/15 error: aws_grafana_workspace_saml_configuration.test: Attribute 'org_assertion' expected "org", got ""
        	* Check 14/15 error: aws_grafana_workspace_saml_configuration.test: Attribute 'role_assertion' expected "role", got ""

=== RUN   TestAccGrafana_serial/RoleAssociation
=== RUN   TestAccGrafana_serial/RoleAssociation/groupsAdmin
    role_association_test.go:103: Environment variable GRAFANA_SSO_GROUP_ID is not set
=== RUN   TestAccGrafana_serial/RoleAssociation/groupsEditor
    role_association_test.go:141: Environment variable GRAFANA_SSO_GROUP_ID is not set
=== RUN   TestAccGrafana_serial/RoleAssociation/usersAndGroupsAdmin
    role_association_test.go:179: Environment variable GRAFANA_SSO_USER_ID is not set
=== RUN   TestAccGrafana_serial/RoleAssociation/usersAndGroupsEditor
    role_association_test.go:224: Environment variable GRAFANA_SSO_USER_ID is not set
=== RUN   TestAccGrafana_serial/RoleAssociation/usersAdmin
    role_association_test.go:27: Environment variable GRAFANA_SSO_USER_ID is not set
=== RUN   TestAccGrafana_serial/RoleAssociation/usersEditor
    role_association_test.go:65: Environment variable GRAFANA_SSO_USER_ID is not set
--- FAIL: TestAccGrafana_serial (7995.53s)
    --- PASS: TestAccGrafana_serial/Workspace (5829.61s)
        --- SKIP: TestAccGrafana_serial/Workspace/sso (1.12s)
        --- PASS: TestAccGrafana_serial/Workspace/notificationDestinations (380.76s)
        --- PASS: TestAccGrafana_serial/Workspace/tags (422.92s)
        --- PASS: TestAccGrafana_serial/Workspace/version (664.67s)
        --- PASS: TestAccGrafana_serial/Workspace/vpc (1444.72s)
        --- PASS: TestAccGrafana_serial/Workspace/configuration (626.77s)
        --- PASS: TestAccGrafana_serial/Workspace/networkAccess (843.36s)
        --- PASS: TestAccGrafana_serial/Workspace/saml (355.18s)
        --- PASS: TestAccGrafana_serial/Workspace/disappears (350.28s)
        --- SKIP: TestAccGrafana_serial/Workspace/organization (0.47s)
        --- PASS: TestAccGrafana_serial/Workspace/dataSources (355.44s)
        --- PASS: TestAccGrafana_serial/Workspace/permissionType (383.93s)
    --- PASS: TestAccGrafana_serial/ApiKey (382.17s)
        --- PASS: TestAccGrafana_serial/ApiKey/basic (382.17s)
    --- PASS: TestAccGrafana_serial/DataSource (383.79s)
        --- PASS: TestAccGrafana_serial/DataSource/basic (383.79s)
    --- FAIL: TestAccGrafana_serial/LicenseAssociation (342.94s)
        --- FAIL: TestAccGrafana_serial/LicenseAssociation/enterpriseFreeTrial (342.94s)
    --- FAIL: TestAccGrafana_serial/SamlConfiguration (1057.02s)
        --- FAIL: TestAccGrafana_serial/SamlConfiguration/basic (341.93s)
        --- FAIL: TestAccGrafana_serial/SamlConfiguration/loginValidity (342.03s)
        --- FAIL: TestAccGrafana_serial/SamlConfiguration/assertions (373.05s)
    --- PASS: TestAccGrafana_serial/RoleAssociation (0.00s)
        --- SKIP: TestAccGrafana_serial/RoleAssociation/groupsAdmin (0.00s)
        --- SKIP: TestAccGrafana_serial/RoleAssociation/groupsEditor (0.00s)
        --- SKIP: TestAccGrafana_serial/RoleAssociation/usersAndGroupsAdmin (0.00s)
        --- SKIP: TestAccGrafana_serial/RoleAssociation/usersAndGroupsEditor (0.00s)
        --- SKIP: TestAccGrafana_serial/RoleAssociation/usersAdmin (0.00s)
        --- SKIP: TestAccGrafana_serial/RoleAssociation/usersEditor (0.00s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	7998.678s
FAIL
make: *** [testacc] Error 1

@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 service/grafana Issues and PRs that pertain to the grafana service. size/XS Managed by automation to categorize the size of a PR. and removed service/grafana Issues and PRs that pertain to the grafana service. labels Oct 25, 2023
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 25, 2023
@github-actions github-actions bot added the service/grafana Issues and PRs that pertain to the grafana service. label Oct 25, 2023
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @jrouly 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTOR guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Oct 25, 2023
Copy link
Collaborator

@DrFaust92 DrFaust92 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 TESTARGS='-run=TestAccGrafana_serial/Workspace/configuration' 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/Workspace/configuration -timeout 360m
=== RUN   TestAccGrafana_serial
=== PAUSE TestAccGrafana_serial
=== CONT  TestAccGrafana_serial
=== RUN   TestAccGrafana_serial/Workspace
=== RUN   TestAccGrafana_serial/Workspace/configuration
--- PASS: TestAccGrafana_serial (621.17s)
    --- PASS: TestAccGrafana_serial/Workspace (621.17s)
        --- PASS: TestAccGrafana_serial/Workspace/configuration (621.17s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	631.729s
@github-actions github-actions bot added size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/fms Issues and PRs that pertain to the fms service. and removed size/XS Managed by automation to categorize the size of a PR. labels Nov 15, 2023
% make testacc TESTARGS='-run=TestAccGrafana_serial/Workspace/' 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/Workspace/ -timeout 360m
=== RUN   TestAccGrafana_serial
=== PAUSE TestAccGrafana_serial
=== CONT  TestAccGrafana_serial
=== RUN   TestAccGrafana_serial/Workspace
=== RUN   TestAccGrafana_serial/Workspace/tags
=== RUN   TestAccGrafana_serial/Workspace/saml
=== RUN   TestAccGrafana_serial/Workspace/organization
    acctest.go:1009: 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
=== RUN   TestAccGrafana_serial/Workspace/version
=== RUN   TestAccGrafana_serial/Workspace/sso
    acctest.go:1051: skipping tests; no SSO Instances found.
=== RUN   TestAccGrafana_serial/Workspace/disappears
=== RUN   TestAccGrafana_serial/Workspace/vpc
    workspace_test.go:114: Step 1/4 error: Error running apply: exit status 1

        Error: creating EC2 VPC: operation error EC2: CreateVpc, https response error StatusCode: 400, RequestID: ebca4a7c-ac66-436c-b2aa-1975e1b66e08, api error VpcLimitExceeded: The maximum number of VPCs has been reached.

          with aws_vpc.test,
          on terraform_plugin_test.tf line 30, in resource "aws_vpc" "test":
          30: resource "aws_vpc" "test" {

=== RUN   TestAccGrafana_serial/Workspace/configuration
=== RUN   TestAccGrafana_serial/Workspace/networkAccess
--- FAIL: TestAccGrafana_serial (4103.41s)
    --- FAIL: TestAccGrafana_serial/Workspace (4103.41s)
        --- PASS: TestAccGrafana_serial/Workspace/tags (358.91s)
        --- PASS: TestAccGrafana_serial/Workspace/saml (320.42s)
        --- SKIP: TestAccGrafana_serial/Workspace/organization (0.70s)
        --- PASS: TestAccGrafana_serial/Workspace/dataSources (321.41s)
        --- PASS: TestAccGrafana_serial/Workspace/permissionType (348.85s)
        --- PASS: TestAccGrafana_serial/Workspace/notificationDestinations (349.90s)
        --- PASS: TestAccGrafana_serial/Workspace/version (601.81s)
        --- SKIP: TestAccGrafana_serial/Workspace/sso (0.45s)
        --- PASS: TestAccGrafana_serial/Workspace/disappears (318.63s)
        --- FAIL: TestAccGrafana_serial/Workspace/vpc (11.98s)
        --- PASS: TestAccGrafana_serial/Workspace/configuration (666.38s)
        --- PASS: TestAccGrafana_serial/Workspace/networkAccess (803.97s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	4109.237s
FAIL
make: *** [testacc] Error 1
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 🚀.

% make testacc TESTARGS='-run=TestAccGrafana_serial/Workspace/configuration\|TestAccGrafana_serial/Workspace/version' 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/Workspace/configuration\|TestAccGrafana_serial/Workspace/version -timeout 360m
=== RUN   TestAccGrafana_serial
=== PAUSE TestAccGrafana_serial
=== CONT  TestAccGrafana_serial
=== RUN   TestAccGrafana_serial/Workspace
=== RUN   TestAccGrafana_serial/Workspace/configuration
=== RUN   TestAccGrafana_serial/Workspace/version
--- PASS: TestAccGrafana_serial (1378.00s)
    --- PASS: TestAccGrafana_serial/Workspace (1378.00s)
        --- PASS: TestAccGrafana_serial/Workspace/configuration (746.14s)
        --- PASS: TestAccGrafana_serial/Workspace/version (631.86s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/grafana	1383.634s

@ewbankkit
Copy link
Contributor

@jrouly Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit c386a9b into hashicorp:main Nov 16, 2023
37 checks passed
@github-actions github-actions bot added this to the v5.26.0 milestone Nov 16, 2023
Copy link

This functionality has been released in v5.26.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!

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 Dec 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/fms Issues and PRs that pertain to the fms service. service/grafana Issues and PRs that pertain to the grafana service. size/L 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
4 participants