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

azurerm_lighthouse_assignment - Upgrade API version to enable eligible_authorization #25473

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/services/lighthouse/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package client
import (
"fmt"

"github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2019-06-01/registrationassignments"
"github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2022-10-01/registrationassignments"
"github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2022-10-01/registrationdefinitions"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2019-06-01/registrationassignments"
"github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2022-10-01/registrationassignments"
"github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2022-10-01/registrationdefinitions"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"

"github.com/google/uuid"
"github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2019-06-01/registrationassignments"
"github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2022-10-01/registrationassignments"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -92,6 +92,27 @@ func TestAccLighthouseAssignment_emptyID(t *testing.T) {
})
}

func TestAccLighthouseAssignment_eligibleAuthorization(t *testing.T) {
secondTenantID := os.Getenv("ARM_TENANT_ID_ALT")
principalID := os.Getenv("ARM_USER_GROUP_ID_ALT_TENANT")
if secondTenantID == "" || principalID == "" {
t.Skip("Skipping as ARM_TENANT_ID_ALT and/or ARM_USER_GROUP_ID_ALT_TENANT are not specified")
}

data := acceptance.BuildTestData(t, "azurerm_lighthouse_assignment", "test")
r := LighthouseAssignmentResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.eligibleAuthorization(uuid.New().String(), secondTenantID, principalID, data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (LighthouseAssignmentResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := registrationassignments.ParseScopedRegistrationAssignmentID(state.ID)
if err != nil {
Expand Down Expand Up @@ -185,3 +206,55 @@ resource "azurerm_lighthouse_assignment" "test" {
}
`, data.RandomInteger, secondTenantID, principalID)
}

func (LighthouseAssignmentResource) eligibleAuthorization(id string, secondTenantID string, principalID string, data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

data "azurerm_role_definition" "contributor" {
role_definition_id = "b24988ac-6180-42a0-ab88-20f7382dd24c" // Contributor role
}

data "azurerm_role_definition" "reader" {
role_definition_id = "acdd72a7-3385-48ef-bd42-f606fba81ae7"
}

data "azurerm_subscription" "test" {}

resource "azurerm_lighthouse_definition" "test" {
name = "acctest-LD-%d"
managing_tenant_id = "%s"
scope = data.azurerm_subscription.test.id

authorization {
principal_id = "%s"
role_definition_id = data.azurerm_role_definition.reader.role_definition_id
principal_display_name = "Reader"
}

eligible_authorization {
principal_id = "%s"
role_definition_id = data.azurerm_role_definition.contributor.role_definition_id
principal_display_name = "Tier 1 Support"

just_in_time_access_policy {
multi_factor_auth_provider = "Azure"
maximum_activation_duration = "PT7H"

approver {
principal_id = "%s"
principal_display_name = "Tier 2 Support"
}
}
}
}

resource "azurerm_lighthouse_assignment" "test" {
name = "%s"
scope = data.azurerm_subscription.test.id
lighthouse_definition_id = azurerm_lighthouse_definition.test.id
}
`, data.RandomInteger, secondTenantID, principalID, principalID, principalID, id)
}

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/managedapplications/2021-07-0
github.com/hashicorp/go-azure-sdk/resource-manager/managedapplications/2021-07-01/applications
github.com/hashicorp/go-azure-sdk/resource-manager/managedidentity/2023-01-31
github.com/hashicorp/go-azure-sdk/resource-manager/managedidentity/2023-01-31/managedidentities
github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2019-06-01/registrationassignments
github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2022-10-01/registrationassignments
github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2022-10-01/registrationdefinitions
github.com/hashicorp/go-azure-sdk/resource-manager/maps/2021-02-01/accounts
github.com/hashicorp/go-azure-sdk/resource-manager/maps/2021-02-01/creators
Expand Down
Loading