diff --git a/internal/services/compute/shared_image_gallery_resource.go b/internal/services/compute/shared_image_gallery_resource.go index e3f0289327bd..b2b5308d2f3e 100644 --- a/internal/services/compute/shared_image_gallery_resource.go +++ b/internal/services/compute/shared_image_gallery_resource.go @@ -71,6 +71,8 @@ func resourceSharedImageGallery() *pluginsdk.Resource { ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ string(galleries.GallerySharingPermissionTypesCommunity), + string(galleries.GallerySharingPermissionTypesGroups), + string(galleries.GallerySharingPermissionTypesPrivate), }, false), }, diff --git a/internal/services/compute/shared_image_gallery_resource_test.go b/internal/services/compute/shared_image_gallery_resource_test.go index a3af428402d3..9dc421493781 100644 --- a/internal/services/compute/shared_image_gallery_resource_test.go +++ b/internal/services/compute/shared_image_gallery_resource_test.go @@ -111,6 +111,36 @@ func TestAccSharedImageGallery_communityGallery(t *testing.T) { }) } +func TestAccSharedImageGallery_groupsGallery(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_shared_image_gallery", "test") + r := SharedImageGalleryResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.groupsGallery(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccSharedImageGallery_privateGallery(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_shared_image_gallery", "test") + r := SharedImageGalleryResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.privateGallery(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (t SharedImageGalleryResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := galleries.ParseGalleryID(state.ID) if err != nil { @@ -213,3 +243,49 @@ resource "azurerm_shared_image_gallery" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } + +func (SharedImageGalleryResource) groupsGallery(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_shared_image_gallery" "test" { + name = "acctestsig%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + sharing { + permission = "Groups" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} + +func (SharedImageGalleryResource) privateGallery(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_shared_image_gallery" "test" { + name = "acctestsig%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + sharing { + permission = "Private" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} diff --git a/website/docs/r/shared_image_gallery.html.markdown b/website/docs/r/shared_image_gallery.html.markdown index a11d93deb059..eeb037b9ee80 100644 --- a/website/docs/r/shared_image_gallery.html.markdown +++ b/website/docs/r/shared_image_gallery.html.markdown @@ -52,7 +52,7 @@ The following arguments are supported: A `sharing` block supports the following: -* `permission` - (Required) The permission of the Shared Image Gallery when sharing. The only possible value now is `Community`. Changing this forces a new resource to be created. +* `permission` - (Required) The permission of the Shared Image Gallery when sharing. Possible values are `Community`, `Groups` and `Private`. Changing this forces a new resource to be created. -> **Note:** This requires that the Preview Feature `Microsoft.Compute/CommunityGalleries` is enabled, see [the documentation](https://learn.microsoft.com/azure/virtual-machines/share-gallery-community?tabs=cli) for more information.