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_storage_account: Add support for AzureDNSZone #22583

Merged
Merged
14 changes: 14 additions & 0 deletions internal/services/storage/storage_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,17 @@ func resourceStorageAccount() *pluginsdk.Resource {
Default: true,
},

"dns_endpoint_type": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
string(storage.DNSEndpointTypeStandard),
string(storage.DNSEndpointTypeAzureDNSZone),
}, false),
Default: string(storage.DNSEndpointTypeStandard),
ForceNew: true,
},

"default_to_oauth_authentication": {
Type: pluginsdk.TypeBool,
Optional: true,
Expand Down Expand Up @@ -1334,6 +1345,7 @@ func resourceStorageAccountCreate(d *pluginsdk.ResourceData, meta interface{}) e
if d.Get("public_network_access_enabled").(bool) {
publicNetworkAccess = storage.PublicNetworkAccessEnabled
}
dnsEndpointType := d.Get("dns_endpoint_type").(string)

accountTier := d.Get("account_tier").(string)
replicationType := d.Get("account_replication_type").(string)
Expand All @@ -1359,6 +1371,7 @@ func resourceStorageAccountCreate(d *pluginsdk.ResourceData, meta interface{}) e
SasPolicy: expandStorageAccountSASPolicy(d.Get("sas_policy").([]interface{})),
IsSftpEnabled: &isSftpEnabled,
IsLocalUserEnabled: pointer.To(d.Get("local_user_enabled").(bool)),
DNSEndpointType: storage.DNSEndpointType(dnsEndpointType),
},
}

Expand Down Expand Up @@ -2103,6 +2116,7 @@ func resourceStorageAccountRead(d *pluginsdk.ResourceData, meta interface{}) err
publicNetworkAccessEnabled = false
}
d.Set("public_network_access_enabled", publicNetworkAccessEnabled)
d.Set("dns_endpoint_type", props.DNSEndpointType)

if crossTenantReplication := props.AllowCrossTenantReplication; crossTenantReplication != nil {
d.Set("cross_tenant_replication_enabled", crossTenantReplication)
Expand Down
48 changes: 48 additions & 0 deletions internal/services/storage/storage_account_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,25 @@ func TestAccStorageAccount_premium(t *testing.T) {
})
}

func TestAccStorageAccount_DNSEndpointTypeAzure(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_storage_account", "test")
r := StorageAccountResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.dnsEndpointTypeAzure(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("account_tier").HasValue("Premium"),
check.That(data.ResourceName).Key("account_replication_type").HasValue("LRS"),
check.That(data.ResourceName).Key("tags.%").HasValue("1"),
check.That(data.ResourceName).Key("tags.environment").HasValue("production"),
),
},
data.ImportStep(),
})
}

func TestAccStorageAccount_disappears(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_storage_account", "test")
r := StorageAccountResource{}
Expand Down Expand Up @@ -1751,6 +1770,35 @@ resource "azurerm_management_lock" "test" {
`, template, data.RandomInteger)
}

func (r StorageAccountResource) dnsEndpointTypeAzure(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "test" {
name = "acctestRG-storage-%d"
location = "%s"
}

resource "azurerm_storage_account" "test" {
name = "unlikely23exst2acct%s"
resource_group_name = azurerm_resource_group.test.name

location = azurerm_resource_group.test.location
account_tier = "Premium"
account_replication_type = "LRS"

dns_endpoint_type = "AzureDnsZone"
allow_nested_items_to_be_public = false

tags = {
environment = "production"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (r StorageAccountResource) premium(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/storage_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ The following arguments are supported:

-> **NOTE:** SFTP support requires `is_hns_enabled` set to `true`. [More information on SFTP support can be found here](https://learn.microsoft.com/azure/storage/blobs/secure-file-transfer-protocol-support). Defaults to `false`

* `dns_endpoint_type` - (Optional) Which DNS endpoint type to use. Possible values are `Standard` and `AzureDnsZone`. Defailts to `Standard`. Changing this forces a new resource to be created.
favoretti marked this conversation as resolved.
Show resolved Hide resolved

* `tags` - (Optional) A mapping of tags to assign to the resource.

---
Expand Down
Loading