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 support for defining aws account name #1976

Merged
merged 8 commits into from
Jan 24, 2025
Merged

Conversation

thepalbi
Copy link
Contributor

@thepalbi thepalbi commented Jan 6, 2025

This PR adds support in the cloud-provider section of the provider, to define an optional name for a grafana_cloud_provider_aws_account resouce, which will help users keep a human readable name in the accounts.

Part of https://github.com/grafana/grafana-csp-app/issues/296

@thepalbi thepalbi requested review from a team as code owners January 6, 2025 21:32
Copy link

github-actions bot commented Jan 6, 2025

In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically.
To do so, a Grafana Labs employee must trigger the cloud acceptance tests workflow manually.

@tristanburgess
Copy link
Contributor

the tests have an error like

        Error: Value Conversion Error
        
          with data.grafana_cloud_provider_aws_account.test,
          on terraform_plugin_test.tf line 2, in data "grafana_cloud_provider_aws_account" "test":
           2: data "grafana_cloud_provider_aws_account" "test" {
        
        An unexpected error was encountered trying to convert tftypes.Value into
        cloudprovider.resourceAWSAccountModel. This is always an error in the
        provider. Please report the following to the provider developer:
        
        mismatch between struct and object: Struct defines fields not found in
        object: name.

looks like you need to add the field changes in https://github.com/grafana/terraform-provider-grafana/pull/1976/files#diff-2c8e971fa27a2dc1c948b60dbcb7111f4106eafe5ced1ccdf070a142c38db3b6 to the data source stuff as well:

https://github.com/grafana/terraform-provider-grafana/blob/main/internal/resources/cloudprovider/data_source_aws_account.go
https://github.com/grafana/terraform-provider-grafana/blob/main/internal/resources/cloudprovider/data_source_aws_account_test.go

@thepalbi thepalbi force-pushed the pablo/add-account-name branch from 6819096 to 39dcf88 Compare January 21, 2025 14:25
@thepalbi thepalbi requested a review from a team as a code owner January 21, 2025 16:25
@tristanburgess
Copy link
Contributor

looks like still a few errors from the tests

=== NAME  TestAccResourceAWSAccount
    resource_aws_account_test.go:29: Step 1/2 error: Error running pre-apply refresh: exit status 1
        
        Error: Incorrect attribute value type
        
          on terraform_plugin_test.tf line 10, in resource "grafana_cloud_provider_aws_account" "test":
          10: 	name = []
        
        Inappropriate value for attribute "name": string required.
--- FAIL: TestAccResourceAWSAccount (2.51s)
=== CONT  TestAccResourceAWSCloudWatchScrapeJob
2025/01/21 16:26:25 [DEBUG] POST ***/api/v2/stacks/***/aws/jobs/cloudwatch
2025/01/21 16:26:25 [DEBUG] POST ***/api/v2/stacks/***/aws/jobs/cloudwatch
2025/01/21 16:26:25 [DEBUG] GET ***/api/v2/stacks/***/aws/accounts/***
2025/01/21 16:26:27 [DEBUG] POST ***/api/v2/stacks/***/aws/jobs/cloudwatch
=== NAME  TestAccDataSourceAWSAccount
    data_source_aws_account_test.go:25: Step 1/1 error: Check failed: Check 3/8 error: data.grafana_cloud_provider_aws_account.test: Attribute 'name' not found
--- FAIL: TestAccDataSourceAWSAccount (7.08s)

@thepalbi thepalbi force-pushed the pablo/add-account-name branch 2 times, most recently from 2d3bf37 to e9cc3e3 Compare January 23, 2025 20:54
@thepalbi thepalbi force-pushed the pablo/add-account-name branch from e9cc3e3 to aac9f26 Compare January 23, 2025 21:38
@thepalbi
Copy link
Contributor Author

@tristanburgess this should be good now

@thepalbi thepalbi merged commit 8ad5c07 into main Jan 24, 2025
26 checks passed
@thepalbi thepalbi deleted the pablo/add-account-name branch January 24, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants