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: azurerm_eventgrid_partner_configuration #28676

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

Conversation

gerrytan
Copy link
Contributor

@gerrytan gerrytan commented Feb 4, 2025

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

New resource for Event Grid Partner Configuration

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • [] I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

Acceptance test ran with command: make acctests SERVICE='eventgrid' TESTARGS=' run="TestAccEventGridPartnerConfiguration_"' TESTTIMEOUT='120m'

Test output: link (access restricted, please DM me on Slack)

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

#13611 Note: please do not close the issue as there are other resources still yet to be implemented.

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

@@ -29,12 +29,15 @@ func (r Registration) WebsiteCategories() []string {
}

func (r Registration) DataSources() []sdk.DataSource {
return []sdk.DataSource{}
return []sdk.DataSource{
// todo: decide if this needs a data source
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this still needed? If not, please remove the comment.

Suggested change
// todo: decide if this needs a data source

Copy link
Collaborator

@wyattfry wyattfry left a comment

Choose a reason for hiding this comment

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

Thanks! Just a couple notes.

}

type PartnerAuthorization struct {
PartnerRegistrationImmutableId string `tfschema:"partner_registration_immutable_id"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Considering that IDs are generally immutable, could we rename this property?

Suggested change
PartnerRegistrationImmutableId string `tfschema:"partner_registration_immutable_id"`
PartnerRegistrationId string `tfschema:"partner_registration_id"`

MinItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"partner_registration_immutable_id": &schema.Schema{
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above

}

param := partnerconfigurations.PartnerConfiguration{
Location: pointer.To("global"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is location not configurable? If it is, then could we add an input property above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Location is not configurable, only "global" is a valid value. Please refer to the create screen in portal below. Note that there no location input.

return commonids.ValidateResourceGroupID
}

func expandAuthorizedPartnersList(partnerAuthorization *[]PartnerAuthorization) *[]partnerconfigurations.Partner {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func expandAuthorizedPartnersList(partnerAuthorization *[]PartnerAuthorization) *[]partnerconfigurations.Partner {
func expandAuthorizedPartnersList(partnerAuthorization []PartnerAuthorization) *[]partnerconfigurations.Partner {

In the model, it's defined as a value, not a pointer.

Comment on lines 237 to 241
partners := []partnerconfigurations.Partner{}

if partnerAuthorization == nil {
return &partners
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
partners := []partnerconfigurations.Partner{}
if partnerAuthorization == nil {
return &partners
}
if len(partnerAuthorization) == 0 {
return nil
}
partners := []partnerconfigurations.Partner{}

Sending an empty slice is not equivalent to sending a nil, which is preferred for an unspecified property.

Comment on lines 96 to 103
template := r.basic(data)
return fmt.Sprintf(`
%s

resource "azurerm_eventgrid_partner_configuration" "import" {
resource_group_name = azurerm_resource_group.test.name
}
`, template)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
template := r.basic(data)
return fmt.Sprintf(`
%s
resource "azurerm_eventgrid_partner_configuration" "import" {
resource_group_name = azurerm_resource_group.test.name
}
`, template)
return fmt.Sprintf(`
%s
resource "azurerm_eventgrid_partner_configuration" "import" {
resource_group_name = azurerm_resource_group.test.name
}
`, r.basic(data))

})
}

func TestAccEventGridPartnerConfiguration_complete(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please add more steps so the update path is also tested? e.g. complete and then basic. This will ensure that the other properties in complete also work in create.

authorization_expiration_time_in_utc = "%s"
}

tags = { "foo" = "bar" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
tags = { "foo" = "bar" }
tags = {
foo = "bar"
}

Just to make it more consistent with other test configurations.


* `partner_registration_immutable_id` - (Required) The immutable id of the corresponding partner registration.

* `authorization_expiration_time_in_utc` - (Optional) Expiration time of the partner authorization. If this timer expires, any request from this partner to create, update or delete resources in subscriber's context will fail. Value should be in RFC 3339 format in UTC time zone, for example: "2025-02-04T00:00:00Z". If not specified, the authorization will expire after `default_maximum_expiration_time_in_days`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* `authorization_expiration_time_in_utc` - (Optional) Expiration time of the partner authorization. If this timer expires, any request from this partner to create, update or delete resources in subscriber's context will fail. Value should be in RFC 3339 format in UTC time zone, for example: "2025-02-04T00:00:00Z". If not specified, the authorization will expire after `default_maximum_expiration_time_in_days`.
* `authorization_expiration_time_in_utc` - (Optional) Expiration time of the partner authorization. Value should be in RFC 3339 format in UTC time zone, for example: "2025-02-04T00:00:00Z".
-> **Note:** If the time from `authorization_expiration_time_in_utc` expires, any request from this partner to create, update or delete resources in the subscriber's context will fail. If not specified, the authorization will expire after `default_maximum_expiration_time_in_days`.

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions:

* `create` - (Defaults to 30 minutes) Used when creating the Event Grid Partner Configuration.
* `read` - (Defaults to 30 minutes) Used when retrieving the Event Grid Partner Configuration.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* `read` - (Defaults to 30 minutes) Used when retrieving the Event Grid Partner Configuration.
* `read` - (Defaults to 5 minutes) Used when retrieving the Event Grid Partner Configuration.

@gerrytan
Copy link
Contributor Author

Thx @wyattfry , I have addressed all the feedbacks (marked with 👍emoji) and all acctest passes (log attached below). Please give this another review.

  • acctest cmd: make acctests SERVICE='eventgrid' TESTARGS='-run="TestAccEventGridPartnerConfiguration_"' TESTTIMEOUT='120m'
  • output: acctest log at commit 6d3a022ed5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants