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_search_service - support attribute customer_managed_key_encryption_compliance_status #27478

Merged
merged 4 commits into from
Nov 25, 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
9 changes: 9 additions & 0 deletions internal/services/search/search_service_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func dataSourceSearchService() *pluginsdk.Resource {

"resource_group_name": commonschema.ResourceGroupNameForDataSource(),

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

"replica_count": {
Type: pluginsdk.TypeInt,
Computed: true,
Expand Down Expand Up @@ -116,6 +121,10 @@ func dataSourceSearchServiceRead(d *pluginsdk.ResourceData, meta interface{}) er
replicaCount := 1
publicNetworkAccess := true

if props.EncryptionWithCmk != nil {
d.Set("customer_managed_key_encryption_compliance_status", string(pointer.From(props.EncryptionWithCmk.EncryptionComplianceStatus)))
}

if count := props.PartitionCount; count != nil {
partitionCount = int(*count)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestAccDataSourceSearchService_basic(t *testing.T) {
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("customer_managed_key_encryption_compliance_status").Exists(),
check.That(data.ResourceName).Key("replica_count").Exists(),
check.That(data.ResourceName).Key("partition_count").Exists(),
check.That(data.ResourceName).Key("primary_key").Exists(),
Expand Down
6 changes: 6 additions & 0 deletions internal/services/search/search_service_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ func resourceSearchService() *pluginsdk.Resource {
Default: false,
},

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

"primary_key": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -557,6 +562,7 @@ func resourceSearchServiceRead(d *pluginsdk.ResourceData, meta interface{}) erro

if props.EncryptionWithCmk != nil {
cmkEnforcement = strings.EqualFold(string(pointer.From(props.EncryptionWithCmk.Enforcement)), string(services.SearchEncryptionWithCmkEnabled))
d.Set("customer_managed_key_encryption_compliance_status", string(pointer.From(props.EncryptionWithCmk.EncryptionComplianceStatus)))
}

// I am using 'DisableLocalAuth' here because when you are in
Expand Down
1 change: 1 addition & 0 deletions internal/services/search/search_service_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ func TestAccSearchService_customerManagedKeyEnforcement(t *testing.T) {
Config: r.customerManagedKeyEnforcement(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("customer_managed_key_encryption_compliance_status").HasValue("Compliant"),
),
},
data.ImportStep(),
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/search_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `id` - The ID of the Search Service.

* `customer_managed_key_encryption_compliance_status` - Describes whether the search service is compliant or not with respect to having non-customer encrypted resources. If a service has more than one non-customer encrypted resource and `Enforcement` is `enabled` then the service will be marked as `NonCompliant`. If all the resources are customer encrypted, then the service will be marked as `Compliant`.

* `primary_key` - The Primary Key used for Search Service Administration.

* `secondary_key` - The Secondary Key used for Search Service Administration.
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/search_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `id` - The ID of the Search Service.

* `customer_managed_key_encryption_compliance_status` - Describes whether the search service is compliant or not with respect to having non-customer encrypted resources. If a service has more than one non-customer encrypted resource and `Enforcement` is `enabled` then the service will be marked as `NonCompliant`. If all the resources are customer encrypted, then the service will be marked as `Compliant`.

* `primary_key` - The Primary Key used for Search Service Administration.

* `query_keys` - A `query_keys` block as defined below.
Expand Down
Loading