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_static_site - identity supports SystemAssigned, UserAssigned #15834

Merged
merged 3 commits into from
Mar 18, 2022
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
10 changes: 5 additions & 5 deletions internal/services/web/static_site_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func resourceStaticSite() *pluginsdk.Resource {
Computed: true,
},

"identity": commonschema.SystemOrUserAssignedIdentityOptional(),
"identity": commonschema.SystemAssignedUserAssignedIdentityOptional(),

"api_key": {
Type: pluginsdk.TypeString,
Expand Down Expand Up @@ -235,7 +235,7 @@ func resourceStaticSiteDelete(d *pluginsdk.ResourceData, meta interface{}) error
}

func expandStaticSiteIdentity(input []interface{}) (*web.ManagedServiceIdentity, error) {
config, err := identity.ExpandSystemOrUserAssignedMap(input)
config, err := identity.ExpandSystemAndUserAssignedMap(input)
if err != nil {
return nil, err
}
Expand All @@ -259,10 +259,10 @@ func expandStaticSiteIdentity(input []interface{}) (*web.ManagedServiceIdentity,
}

func flattenStaticSiteIdentity(input *web.ManagedServiceIdentity) (*[]interface{}, error) {
var transform *identity.SystemOrUserAssignedMap
var transform *identity.SystemAndUserAssignedMap

if input != nil {
transform = &identity.SystemOrUserAssignedMap{
transform = &identity.SystemAndUserAssignedMap{
Type: identity.Type(string(input.Type)),
IdentityIds: make(map[string]identity.UserAssignedIdentityDetails),
}
Expand All @@ -281,5 +281,5 @@ func flattenStaticSiteIdentity(input *web.ManagedServiceIdentity) (*[]interface{
}
}

return identity.FlattenSystemOrUserAssignedMap(transform)
return identity.FlattenSystemAndUserAssignedMap(transform)
}
17 changes: 9 additions & 8 deletions internal/services/web/static_site_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,20 @@ func TestAccAzureStaticSite_identity(t *testing.T) {
},
data.ImportStep(),
{
Config: r.withSystemAssignedUserAssignedIdentity(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.basic(data),
Config: r.withUserAssignedIdentity(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
magodo marked this conversation as resolved.
Show resolved Hide resolved
// TODO: re-enable this once the API issue is resolved: https://github.com/Azure/azure-rest-api-specs/issues/18253
// {
// Config: r.basic(data),
// Check: acceptance.ComposeTestCheckFunc(
// check.That(data.ResourceName).ExistsInAzure(r),
// ),
// },
// data.ImportStep(),
})
}

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/static_site.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The following arguments are supported:

An `identity` block supports the following:

* `type` - (Required) The Type of Managed Identity assigned to this Static Site resource. Possible values are `SystemAssigned` and `UserAssigned`.
* `type` - (Required) The Type of Managed Identity assigned to this Static Site resource. Possible values are `SystemAssigned`, `UserAssigned` and `SystemAssigned, UserAssigned`.

* `identity_ids` - (Optional) A list of Managed Identity ID's which should be assigned to this Static Site resource.

Expand Down