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 the Azure credentials resource #1907

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

Conversation

andriikushch
Copy link

@andriikushch andriikushch commented Nov 14, 2024

This PR introduces the grafana_cloud_provider_azure_credential resource and data source to the Grafana Terraform provider. The new resource allows users to manage Azure credentials within their Grafana Cloud stack. The data source enables users to retrieve information about existing Azure credentials.

Copy link

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.

@andriikushch andriikushch marked this pull request as ready for review November 15, 2024 09:58
@andriikushch andriikushch requested review from a team as code owners November 15, 2024 09:58
Description: "The name of the Azure Credential.",
Required: true,
},
"client_id": schema.StringAttribute{
Copy link
Contributor

@tristanburgess tristanburgess Nov 26, 2024

Choose a reason for hiding this comment

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

For a Terraform data source, we should only mark fields required if the user must supply values for them to be able to look up a unique resource. All other fields should be marked only as Computed: true, see e.g.

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

versus

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

StackID types.String `tfsdk:"stack_id"`
ClientSecret types.String `tfsdk:"client_secret"`
ResourceID types.String `tfsdk:"resource_id"`
ResourceTagFilters []TagFilter `tfsdk:"resource_tag_filter"`
Copy link
Contributor

@tristanburgess tristanburgess Nov 26, 2024

Choose a reason for hiding this comment

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

I've recently found out that if we use Go slice types directly here, instead of the Terraform type e.g. List, you can get errors when a value is planned by Terraform with a state other than the normal state e.g. Unknown. See https://github.com/grafana/cloud-onboarding/issues/8084. I'm still working through what the right pattern is myself, possibly handing off to @thepalbi on Wednesday, but this will need to be fixed here as well.

},
},
Blocks: map[string]schema.Block{
"resource_tag_filter": schema.ListNestedBlock{
Copy link
Contributor

Choose a reason for hiding this comment

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

"resource_discovery_tag_filter": schema.ListNestedBlock{
calls a similar field resource_discovery_tag_filter, should we make things consistent, or is it an Azure thing?

// Tests both managed resource and data source
func TestAcc_AzureCredential(t *testing.T) {
resourceID := "3"
// Mock the Connections API response for Create, Get, and Delete
Copy link
Contributor

Choose a reason for hiding this comment

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

comment leftover from copy

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.

3 participants