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/azurerm_storage_account_blob_properties/azurerm_storage_account_queue_properties/azurerm_storage_account_share_properties/azurerm_storage_account_static_website_properties - split data plane into separate resources #26733

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f4353f1
Initial Check-in...
WodansSon Jul 23, 2024
a3efc44
Merge branch 'main' into e_storage_account_dataplane
WodansSon Aug 1, 2024
726c178
Remove new datasource and documentation...
WodansSon Aug 12, 2024
060b921
Move computed queue fields back to main resource...
WodansSon Aug 12, 2024
52d0984
Move check for fields higher in create...
WodansSon Aug 13, 2024
3523b94
Add resource placholders and new resource docs...
WodansSon Aug 13, 2024
6dd49a8
Make new resource names consistent...
WodansSon Aug 13, 2024
8133fa8
Update static website error msgs in main storage account resource...
WodansSon Aug 13, 2024
867f8d1
Add storage feature flag...
WodansSon Aug 15, 2024
4ac8355
Merge branch 'main' into e_storage_account_dataplane
WodansSon Aug 15, 2024
0af59bf
Add new resources and update documentation...
WodansSon Aug 16, 2024
fca8231
Add create failure and update docs...
WodansSon Aug 16, 2024
15056fe
Fix static website documentation...
WodansSon Aug 16, 2024
5ab8a57
Fix static website doc again...
WodansSon Aug 16, 2024
efd93f6
Merge branch 'main' of https://github.com/hashicorp/terraform-provide…
WodansSon Aug 16, 2024
0a2fd96
Added new resources and update test cases...
WodansSon Aug 17, 2024
32fc527
Update deprecated message...
WodansSon Aug 17, 2024
05930cd
generate ./internal/services/provider
WodansSon Aug 17, 2024
541c2d5
Update feature block documentation...
WodansSon Aug 18, 2024
b79703a
Update documentation disclaimers block...
WodansSon Aug 18, 2024
50d6579
Update change version from 3.116.1 to 3.117.0...
WodansSon Aug 19, 2024
12ff28b
Update documentation disclaimer...
WodansSon Aug 20, 2024
19618cf
Update feature flag name and function...
WodansSon Aug 21, 2024
74c57d2
Add log debug output when dataplane has been skipped...
WodansSon Aug 21, 2024
9ba8d31
Add note to documentation for private endpoint DNS zone values...
WodansSon Aug 21, 2024
095a9be
Not done, but very close... checking in progress...
WodansSon Sep 11, 2024
beac52c
Standardize debug output...
WodansSon Sep 12, 2024
a9fe7ec
go generate...
WodansSon Sep 12, 2024
cdc26ef
Fix unit tests...
WodansSon Sep 12, 2024
5df2d94
Correct missed debug output...
WodansSon Sep 12, 2024
f185605
Update/Add documentation for new resources...
WodansSon Sep 13, 2024
e7f1ac6
Fix lint error...
WodansSon Sep 13, 2024
535fbcc
Fix lint error...
WodansSon Sep 13, 2024
d248af0
Remove new lines from blob disclaimers section...
WodansSon Sep 13, 2024
43c7e68
Update documentation 'NOTE' to 'Note' per new Hashi standard...
WodansSon Sep 13, 2024
0d4ce71
Update title for azurerm_storage_account_static_website_properties do…
WodansSon Sep 13, 2024
ce45b73
Update log output...
WodansSon Sep 13, 2024
f1eabc2
Flatten Static Website schema...
WodansSon Sep 14, 2024
2a19723
Flatten Share schema...
WodansSon Sep 15, 2024
67c529d
Check-in progress, mid-change...
WodansSon Sep 17, 2024
0ea6bfd
Flatten queue properties schema...
WodansSon Sep 18, 2024
79e63bb
Remove global feature flag in favor of a resource field...
WodansSon Sep 20, 2024
e448212
Flatten blob properties schema...
WodansSon Sep 21, 2024
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
1 change: 1 addition & 0 deletions internal/services/storage/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource {
"azurerm_storage_account_blob_container_sas": dataSourceStorageAccountBlobContainerSharedAccessSignature(),
"azurerm_storage_account_sas": dataSourceStorageAccountSharedAccessSignature(),
"azurerm_storage_account": dataSourceStorageAccount(),
"azurerm_storage_account_queue_properties": dataSourceStorageAccountQueueProperties(),
"azurerm_storage_blob": dataSourceStorageBlob(),
"azurerm_storage_container": dataSourceStorageContainer(),
"azurerm_storage_encryption_scope": dataSourceStorageEncryptionScope(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func resourceStorageAccountCustomerManagedKeyCreateUpdate(d *pluginsdk.ResourceD
}
}
if !softDeleteEnabled || !purgeProtectionEnabled {
return fmt.Errorf("Key Vault %q (Resource Group %q) must be configured for both Purge Protection and Soft Delete", keyVaultID.VaultName, keyVaultID.ResourceGroupName)
return fmt.Errorf("key vault %q (Resource Group %q) must be configured for both Purge Protection and Soft Delete", keyVaultID.VaultName, keyVaultID.ResourceGroupName)
}

keyVaultBaseURL, err := keyVaultsClient.BaseUriForKeyVault(ctx, *keyVaultID)
Expand All @@ -196,7 +196,7 @@ func resourceStorageAccountCustomerManagedKeyCreateUpdate(d *pluginsdk.ResourceD
keyVersion = ""
keyVaultURI = keyId.BaseUri()
} else {
return fmt.Errorf("Failed to parse '%s' as HSM key ID", managedHSMKeyId)
return fmt.Errorf("failed to parse '%s' as HSM key ID", managedHSMKeyId)
}
}

Expand Down
111 changes: 69 additions & 42 deletions internal/services/storage/storage_account_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,46 +173,6 @@ func dataSourceStorageAccount() *pluginsdk.Resource {
Computed: true,
},

"primary_queue_endpoint": {
Type: pluginsdk.TypeString,
Computed: true,
},

"primary_queue_host": {
Type: pluginsdk.TypeString,
Computed: true,
},

"primary_queue_microsoft_endpoint": {
Type: pluginsdk.TypeString,
Computed: true,
},

"primary_queue_microsoft_host": {
Type: pluginsdk.TypeString,
Computed: true,
},

"secondary_queue_endpoint": {
Type: pluginsdk.TypeString,
Computed: true,
},

"secondary_queue_host": {
Type: pluginsdk.TypeString,
Computed: true,
},

"secondary_queue_microsoft_endpoint": {
Type: pluginsdk.TypeString,
Computed: true,
},

"secondary_queue_microsoft_host": {
Type: pluginsdk.TypeString,
Computed: true,
},

"primary_table_endpoint": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -539,9 +499,60 @@ func dataSourceStorageAccount() *pluginsdk.Resource {
}

if !features.FourPointOhBeta() {
// TODO 4.0: change this from enable_* to *_enabled
resource.Schema["enable_https_traffic_only"] = &pluginsdk.Schema{
Type: pluginsdk.TypeBool,
Computed: true,
Type: pluginsdk.TypeBool,
Computed: true,
Deprecated: "the `enable_https_traffic_only` field has been deprecated in favour of `https_traffic_only_enabled` in v4.0 of the provider.",
ConflictsWith: []string{"https_traffic_only_enabled"},
}

resource.Schema["primary_queue_endpoint"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Computed: true,
Deprecated: "`primary_queue_endpoint` will be moved to the `azurerm_storage_account_queue_properties` data source in v4.0 of the provider.",
}

resource.Schema["primary_queue_host"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Computed: true,
Deprecated: "`primary_queue_host` will be moved to the `azurerm_storage_account_queue_properties` data source in v4.0 of the provider.",
}

resource.Schema["primary_queue_microsoft_endpoint"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Computed: true,
Deprecated: "`primary_queue_microsoft_endpoint` will be moved to the `azurerm_storage_account_queue_properties` data source in v4.0 of the provider.",
}

resource.Schema["primary_queue_microsoft_host"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Computed: true,
Deprecated: "`primary_queue_microsoft_host` will be moved to the `azurerm_storage_account_queue_properties` data source in v4.0 of the provider.",
}

resource.Schema["secondary_queue_endpoint"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Computed: true,
Deprecated: "`secondary_queue_endpoint` will be moved to the `azurerm_storage_account_queue_properties` data source in v4.0 of the provider.",
}

resource.Schema["secondary_queue_host"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Computed: true,
Deprecated: "`secondary_queue_host` will be moved to the `azurerm_storage_account_queue_properties` data source in v4.0 of the provider.",
}

resource.Schema["secondary_queue_microsoft_endpoint"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Computed: true,
Deprecated: "`secondary_queue_microsoft_endpoint` will be moved to the `azurerm_storage_account_queue_properties` data source in v4.0 of the provider.",
}

resource.Schema["secondary_queue_microsoft_host"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Computed: true,
Deprecated: "`secondary_queue_microsoft_host` will be moved to the `azurerm_storage_account_queue_properties` data source in v4.0 of the provider.",
}
}

Expand Down Expand Up @@ -611,6 +622,11 @@ func dataSourceStorageAccountRead(d *pluginsdk.ResourceData, meta interface{}) e
if err := d.Set("custom_domain", flattenAccountCustomDomain(props.CustomDomain)); err != nil {
return fmt.Errorf("setting `custom_domain`: %+v", err)
}

if !features.FourPointOhBeta() {
d.Set("enable_https_traffic_only", pointer.From(props.SupportsHTTPSTrafficOnly))
}

d.Set("https_traffic_only_enabled", pointer.From(props.SupportsHTTPSTrafficOnly))
d.Set("is_hns_enabled", pointer.From(props.IsHnsEnabled))
d.Set("nfsv3_enabled", pointer.From(props.IsNfsV3Enabled))
Expand Down Expand Up @@ -670,15 +686,26 @@ func dataSourceStorageAccountRead(d *pluginsdk.ResourceData, meta interface{}) e
routingPreference = model.Properties.RoutingPreference
secondaryEndpoints = model.Properties.SecondaryEndpoints
}

endpoints := flattenAccountEndpoints(primaryEndpoints, secondaryEndpoints, routingPreference)
if err := endpoints.set(d); err != nil {
return err
}

// Only set the Queue Endpoints in v3.x since in v4.0 these properties will be
// moved to the 'azurerm_storage_account_queue_properties' data source...
if !features.FourPointOhBeta() {
queueEndpoints := flattenAccountQueueEndpoints(primaryEndpoints, secondaryEndpoints, routingPreference)
if err := queueEndpoints.set(d); err != nil {
return err
}
}

storageAccountKeys := make([]storageaccounts.StorageAccountKey, 0)
if keys.Model != nil && keys.Model.Keys != nil {
storageAccountKeys = *keys.Model.Keys
}

keysAndConnectionStrings := flattenAccountAccessKeysAndConnectionStrings(id.StorageAccountName, *storageDomainSuffix, storageAccountKeys, endpoints)
if err := keysAndConnectionStrings.set(d); err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ type accountEndpoints struct {
secondaryFileMicrosoftEndpoint string
secondaryFileMicrosoftHostName string

primaryQueueEndpoint string
primaryQueueHostName string
primaryQueueMicrosoftEndpoint string
primaryQueueMicrosoftHostName string
secondaryQueueEndpoint string
secondaryQueueHostName string
secondaryQueueMicrosoftEndpoint string
secondaryQueueMicrosoftHostName string

primaryTableEndpoint string
primaryTableHostName string
primaryTableMicrosoftEndpoint string
Expand All @@ -84,6 +75,17 @@ type accountEndpoints struct {
secondaryWebMicrosoftHostName string
}

type accountQueueEndpoints struct {
primaryQueueEndpoint string
primaryQueueHostName string
primaryQueueMicrosoftEndpoint string
primaryQueueMicrosoftHostName string
secondaryQueueEndpoint string
secondaryQueueHostName string
secondaryQueueMicrosoftEndpoint string
secondaryQueueMicrosoftHostName string
}

func (a accountEndpoints) set(d *pluginsdk.ResourceData) error {
d.Set("primary_blob_endpoint", a.primaryBlobEndpoint)
d.Set("primary_blob_host", a.primaryBlobHostName)
Expand Down Expand Up @@ -124,15 +126,6 @@ func (a accountEndpoints) set(d *pluginsdk.ResourceData) error {
d.Set("secondary_file_microsoft_endpoint", a.secondaryFileMicrosoftEndpoint)
d.Set("secondary_file_microsoft_host", a.secondaryFileMicrosoftHostName)

d.Set("primary_queue_endpoint", a.primaryQueueEndpoint)
d.Set("primary_queue_host", a.primaryQueueHostName)
d.Set("primary_queue_microsoft_endpoint", a.primaryQueueMicrosoftEndpoint)
d.Set("primary_queue_microsoft_host", a.primaryQueueMicrosoftHostName)
d.Set("secondary_queue_endpoint", a.secondaryQueueEndpoint)
d.Set("secondary_queue_host", a.secondaryQueueHostName)
d.Set("secondary_queue_microsoft_endpoint", a.secondaryQueueMicrosoftEndpoint)
d.Set("secondary_queue_microsoft_host", a.secondaryQueueMicrosoftHostName)

d.Set("primary_table_endpoint", a.primaryTableEndpoint)
d.Set("primary_table_host", a.primaryTableHostName)
d.Set("primary_table_microsoft_endpoint", a.primaryTableMicrosoftEndpoint)
Expand All @@ -158,14 +151,26 @@ func (a accountEndpoints) set(d *pluginsdk.ResourceData) error {
return nil
}

func (a accountQueueEndpoints) set(d *pluginsdk.ResourceData) error {
d.Set("primary_queue_endpoint", a.primaryQueueEndpoint)
d.Set("primary_queue_host", a.primaryQueueHostName)
d.Set("primary_queue_microsoft_endpoint", a.primaryQueueMicrosoftEndpoint)
d.Set("primary_queue_microsoft_host", a.primaryQueueMicrosoftHostName)
d.Set("secondary_queue_endpoint", a.secondaryQueueEndpoint)
d.Set("secondary_queue_host", a.secondaryQueueHostName)
d.Set("secondary_queue_microsoft_endpoint", a.secondaryQueueMicrosoftEndpoint)
d.Set("secondary_queue_microsoft_host", a.secondaryQueueMicrosoftHostName)

return nil
}

func flattenAccountEndpoints(primaryEndpoints, secondaryEndpoints *storageaccounts.Endpoints, routingPreference *storageaccounts.RoutingPreference) accountEndpoints {
output := accountEndpoints{}

if primaryEndpoints != nil {
output.primaryBlobEndpoint, output.primaryBlobHostName = flattenAccountEndpointAndHost(primaryEndpoints.Blob)
output.primaryDfsEndpoint, output.primaryDfsHostName = flattenAccountEndpointAndHost(primaryEndpoints.Dfs)
output.primaryFileEndpoint, output.primaryFileHostName = flattenAccountEndpointAndHost(primaryEndpoints.File)
output.primaryQueueEndpoint, output.primaryQueueHostName = flattenAccountEndpointAndHost(primaryEndpoints.Queue)
output.primaryTableEndpoint, output.primaryTableHostName = flattenAccountEndpointAndHost(primaryEndpoints.Table)
output.primaryWebEndpoint, output.primaryWebHostName = flattenAccountEndpointAndHost(primaryEndpoints.Web)

Expand All @@ -181,7 +186,6 @@ func flattenAccountEndpoints(primaryEndpoints, secondaryEndpoints *storageaccoun
output.primaryBlobMicrosoftEndpoint, output.primaryBlobMicrosoftHostName = flattenAccountEndpointAndHost(primaryEndpoints.MicrosoftEndpoints.Blob)
output.primaryDfsMicrosoftEndpoint, output.primaryDfsMicrosoftHostName = flattenAccountEndpointAndHost(primaryEndpoints.MicrosoftEndpoints.Dfs)
output.primaryFileMicrosoftEndpoint, output.primaryFileMicrosoftHostName = flattenAccountEndpointAndHost(primaryEndpoints.MicrosoftEndpoints.File)
output.primaryQueueMicrosoftEndpoint, output.primaryQueueMicrosoftHostName = flattenAccountEndpointAndHost(primaryEndpoints.MicrosoftEndpoints.Queue)
output.primaryTableMicrosoftEndpoint, output.primaryTableMicrosoftHostName = flattenAccountEndpointAndHost(primaryEndpoints.MicrosoftEndpoints.Table)
output.primaryWebMicrosoftEndpoint, output.primaryWebMicrosoftHostName = flattenAccountEndpointAndHost(primaryEndpoints.MicrosoftEndpoints.Web)
}
Expand All @@ -192,7 +196,6 @@ func flattenAccountEndpoints(primaryEndpoints, secondaryEndpoints *storageaccoun
output.secondaryBlobEndpoint, output.secondaryBlobHostName = flattenAccountEndpointAndHost(secondaryEndpoints.Blob)
output.secondaryDfsEndpoint, output.secondaryDfsHostName = flattenAccountEndpointAndHost(secondaryEndpoints.Dfs)
output.secondaryFileEndpoint, output.secondaryFileHostName = flattenAccountEndpointAndHost(secondaryEndpoints.File)
output.secondaryQueueEndpoint, output.secondaryQueueHostName = flattenAccountEndpointAndHost(secondaryEndpoints.Queue)
output.secondaryTableEndpoint, output.secondaryTableHostName = flattenAccountEndpointAndHost(secondaryEndpoints.Table)
output.secondaryWebEndpoint, output.secondaryWebHostName = flattenAccountEndpointAndHost(secondaryEndpoints.Web)

Expand All @@ -208,7 +211,6 @@ func flattenAccountEndpoints(primaryEndpoints, secondaryEndpoints *storageaccoun
output.secondaryBlobMicrosoftEndpoint, output.secondaryBlobMicrosoftHostName = flattenAccountEndpointAndHost(secondaryEndpoints.MicrosoftEndpoints.Blob)
output.secondaryDfsMicrosoftEndpoint, output.secondaryDfsMicrosoftHostName = flattenAccountEndpointAndHost(secondaryEndpoints.MicrosoftEndpoints.Dfs)
output.secondaryFileMicrosoftEndpoint, output.secondaryFileMicrosoftHostName = flattenAccountEndpointAndHost(secondaryEndpoints.MicrosoftEndpoints.File)
output.secondaryQueueMicrosoftEndpoint, output.secondaryQueueMicrosoftHostName = flattenAccountEndpointAndHost(secondaryEndpoints.MicrosoftEndpoints.Queue)
output.secondaryTableMicrosoftEndpoint, output.secondaryTableMicrosoftHostName = flattenAccountEndpointAndHost(secondaryEndpoints.MicrosoftEndpoints.Table)
output.secondaryWebMicrosoftEndpoint, output.secondaryWebMicrosoftHostName = flattenAccountEndpointAndHost(secondaryEndpoints.MicrosoftEndpoints.Web)
}
Expand All @@ -218,6 +220,32 @@ func flattenAccountEndpoints(primaryEndpoints, secondaryEndpoints *storageaccoun
return output
}

func flattenAccountQueueEndpoints(primaryEndpoints, secondaryEndpoints *storageaccounts.Endpoints, routingPreference *storageaccounts.RoutingPreference) accountQueueEndpoints {
output := accountQueueEndpoints{}

if primaryEndpoints != nil {
output.primaryQueueEndpoint, output.primaryQueueHostName = flattenAccountEndpointAndHost(primaryEndpoints.Queue)

if routingPreference != nil {
if primaryEndpoints.MicrosoftEndpoints != nil && pointer.From(routingPreference.PublishMicrosoftEndpoints) {
output.primaryQueueMicrosoftEndpoint, output.primaryQueueMicrosoftHostName = flattenAccountEndpointAndHost(primaryEndpoints.MicrosoftEndpoints.Queue)
}
}
}

if secondaryEndpoints != nil {
output.secondaryQueueEndpoint, output.secondaryQueueHostName = flattenAccountEndpointAndHost(secondaryEndpoints.Queue)

if routingPreference != nil {
if secondaryEndpoints.MicrosoftEndpoints != nil && pointer.From(routingPreference.PublishMicrosoftEndpoints) {
output.secondaryQueueMicrosoftEndpoint, output.secondaryQueueMicrosoftHostName = flattenAccountEndpointAndHost(secondaryEndpoints.MicrosoftEndpoints.Queue)
}
}
}

return output
}

func flattenAccountEndpointAndHost(input *string) (string, string) {
endpoint := ""
host := ""
Expand Down
Loading
Loading