Skip to content

azurerm_batch_pool - support for new block security_profile#28069

Merged
catriona-m merged 5 commits intohashicorp:mainfrom
liuwuliuyun:fix-27952
Dec 17, 2024
Merged

azurerm_batch_pool - support for new block security_profile#28069
catriona-m merged 5 commits intohashicorp:mainfrom
liuwuliuyun:fix-27952

Conversation

@liuwuliuyun
Copy link
Collaborator

@liuwuliuyun liuwuliuyun commented Nov 19, 2024

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

For resource azurerm_batch_pool

  • support new block security_profile
  • add documentation for security_profile

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevent documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

image

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Fixes #27952

@liuwuliuyun liuwuliuyun requested review from a team and katbyte as code owners November 19, 2024 09:19
@liuwuliuyun liuwuliuyun changed the title azurerm_batch_pool - support new block security_profile azurerm_batch_pool - support for new block security_profile Nov 19, 2024
Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @liuwuliuyun - I've had a look through and left some suggestions inline but once those are addressed I can take another look. Thanks!

})
}

func TestAccBatchPool_securityProfileWithUEFISettings(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add additional steps to this test to test updating the properties in the block and to test adding/removing the block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I have just recalled that the security_profile can only be specified during creation and does not support updates. I will ensure this information is added to the documentation.

Copy link
Collaborator Author

@liuwuliuyun liuwuliuyun Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus I will mark this block as forceNew

Comment on lines +1283 to +1296
if config.SecurityProfile != nil {
securityProfile := make([]interface{}, 0)
securityConfig := make(map[string]interface{})
securityConfig["host_encryption_enabled"] = pointer.ToBool(config.SecurityProfile.EncryptionAtHost)
if config.SecurityProfile.SecurityType != nil {
securityConfig["security_type"] = string(*config.SecurityProfile.SecurityType)
}
if config.SecurityProfile.UefiSettings != nil {
securityConfig["secure_boot_enabled"] = pointer.ToBool(config.SecurityProfile.UefiSettings.SecureBootEnabled)
securityConfig["vtpm_enabled"] = pointer.ToBool(config.SecurityProfile.UefiSettings.VTpmEnabled)
}
securityProfile = append(securityProfile, securityConfig)
d.Set("security_profile", securityProfile)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we move this into a flatten func?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, will do

@liuwuliuyun
Copy link
Collaborator Author

liuwuliuyun commented Dec 10, 2024

New testing evidence:
image

Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating this @liuwuliuyun - I left a couple more suggestions inline but can take another look after those are addressed. Thanks!

Comment on lines +418 to +420
if configProfile.EncryptionAtHost != nil {
securityConfig["host_encryption_enabled"] = *configProfile.EncryptionAtHost
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if configProfile.EncryptionAtHost != nil {
securityConfig["host_encryption_enabled"] = *configProfile.EncryptionAtHost
}
securityConfig["host_encryption_enabled"] = pointer.From(configProfile.EncryptionAtHost)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +422 to +424
if configProfile.SecurityType != nil {
securityConfig["security_type"] = string(*configProfile.SecurityType)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if configProfile.SecurityType != nil {
securityConfig["security_type"] = string(*configProfile.SecurityType)
}
securityConfig["security_type"] = pointer.From(*configProfile.SecurityType)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +427 to +429
if configProfile.UefiSettings.SecureBootEnabled != nil {
securityConfig["secure_boot_enabled"] = pointer.ToBool(configProfile.UefiSettings.SecureBootEnabled)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if configProfile.UefiSettings.SecureBootEnabled != nil {
securityConfig["secure_boot_enabled"] = pointer.ToBool(configProfile.UefiSettings.SecureBootEnabled)
}
securityConfig["secure_boot_enabled"] = pointer.From(configProfile.UefiSettings.SecureBootEnabled)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +430 to +432
if configProfile.UefiSettings.VTpmEnabled != nil {
securityConfig["vtpm_enabled"] = pointer.ToBool(configProfile.UefiSettings.VTpmEnabled)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if configProfile.UefiSettings.VTpmEnabled != nil {
securityConfig["vtpm_enabled"] = pointer.ToBool(configProfile.UefiSettings.VTpmEnabled)
}
securityConfig["vtpm_enabled"] = pointer.From(configProfile.UefiSettings.VTpmEnabled)

Copy link
Collaborator Author

@liuwuliuyun liuwuliuyun Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

if v, ok := item["host_encryption_enabled"]; ok {
securityProfile.EncryptionAtHost = pointer.FromBool(v.(bool))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
securityProfile.EncryptionAtHost = pointer.FromBool(v.(bool))
securityProfile.EncryptionAtHost = pointer.To(v.(bool))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

if v, ok := item["secure_boot_enabled"]; ok {
securityProfile.UefiSettings.SecureBootEnabled = pointer.FromBool(v.(bool))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
securityProfile.UefiSettings.SecureBootEnabled = pointer.FromBool(v.(bool))
securityProfile.UefiSettings.SecureBootEnabled = pointer.To(v.(bool))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

if v, ok := item["vtpm_enabled"]; ok {
securityProfile.UefiSettings.VTpmEnabled = pointer.FromBool(v.(bool))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
securityProfile.UefiSettings.VTpmEnabled = pointer.FromBool(v.(bool))
securityProfile.UefiSettings.VTpmEnabled = pointer.To(v.(bool))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


* `os_disk_placement` - (Optional) Specifies the ephemeral disk placement for operating system disk for all VMs in the pool. This property can be used by user in the request to choose which location the operating system should be in. e.g., cache disk space for Ephemeral OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer to Ephemeral OS disk size requirements for Windows VMs at <https://docs.microsoft.com/en-us/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements> and Linux VMs at <https://docs.microsoft.com/en-us/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements>. The only possible value is `CacheDisk`.

* `security_profile` - (Optional) A `security_profile` block that describes the security settings for the Batch pool as defined below.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add here that Changing this forces a new resource to be created.?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Comment on lines +510 to +516
* `host_encryption_enabled` - (Optional) Whether to enable host encryption for the Virtual Machine or Virtual Machine Scale Set. This will enable the encryption for all the disks including Resource/Temp disk at host itself. Possible values are `true` and `false`. Changing this forces a new resource to be created.

* `security_type` - (Optional) The security type of the Virtual Machine. Possible values are `confidentialVM` and `trustedLaunch`. Changing this forces a new resource to be created.

* `secure_boot_enabled` - (Optional) Whether to enable secure boot for the Virtual Machine or Virtual Machine Scale Set. Possible values are `true` and `false`. Changing this forces a new resource to be created.

* `vtpm_enabled` - (Optional) Whether to enable virtual trusted platform module (vTPM) for the Virtual Machine or Virtual Machine Scale Set. Possible values are `true` and `false`. Changing this forces a new resource to be created.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the properties within the block cannot be updated once it's been created as well, we should add ForceNew to these properties in the schema too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @liuwuliuyun LGTM!

@catriona-m catriona-m merged commit ed20285 into hashicorp:main Dec 17, 2024
@github-actions github-actions bot added this to the v4.15.0 milestone Dec 17, 2024
catriona-m added a commit that referenced this pull request Dec 17, 2024
jackofallops pushed a commit that referenced this pull request Jan 10, 2025
jackofallops added a commit that referenced this pull request Jan 10, 2025
* Update CHANGELOG.md for #28233

* Update for #28215

* Update CHANGELOG.md for #28279

* Update CHANGELOG.md #28269

* Update CHANGELOG.md #27876

* Update CHANGELOG.md #28069

* Update CHANGELOG.md for #28312

* Update CHANGELOG.md for #28278

* Update CHANGELOG.md #28311

* Update CHANGELOG.md undo 28311

* Update CHANGELOG.md #27874

* Update CHANGELOG.md

* Update CHANGELOG for #28352

* Update CHANGELOG.md for #28390

* Update CHANGELOG.md for #28398

* Update CHANGELOG.md for #28425

* Update CHANGELOG.md #28427

* Update CHANGELOG.md #28280

* Update CHANGELOG.md for #28319

* Update CHANGELOG.md #24801

* Update for #28360 #28216 #27830 #28404 #27401 #27122 #27931 #28442

* Update for #28379

* Update CHANGELOG.md for #28281

* Update for #28380

* Update for #27375

* Update for #25695

* Update CHANGELOG.md #27985

* Update CHANGELOG.md - update release date manually until can be scripted

* Update CHANGELOG.md revert date change as script available

* pre-release script updates

---------

Co-authored-by: stephybun <[email protected]>
Co-authored-by: catriona-m <[email protected]>
Co-authored-by: Wyatt Fry <[email protected]>
Co-authored-by: sreallymatt <[email protected]>
Co-authored-by: Matthew Frahry <[email protected]>
Co-authored-by: kt <[email protected]>
@github-actions
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 17, 2025
@liuwuliuyun liuwuliuyun deleted the fix-27952 branch March 20, 2025 01:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for TrustedLaunch in "azurerm_batch_pool"

2 participants