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

{Compute} az vm/vmss create: Add warning log to recommend users to specify the --enable-secure-boot True and --enable-vtpm True when the --security-type used by the VM/VMSS creation is TrustedLaunch #23289

Merged
merged 6 commits into from
Jul 22, 2022
Merged
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
12 changes: 12 additions & 0 deletions src/azure-cli/azure/cli/command_modules/vm/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,15 @@ def _enable_msi_for_trusted_launch(namespace):
namespace.assign_identity.append(MSI_LOCAL_ID)


def _validate_trusted_launch(namespace):
if not namespace.security_type or namespace.security_type.lower() != 'trustedlaunch':
return

if not namespace.enable_vtpm or not namespace.enable_secure_boot:
logger.warning('It is recommended to specify "--enable-secure-boot True" and "--enable-secure-boot True"'
' to receive the full suite of security features that comes with Trusted Launch.')


def _validate_vm_vmss_set_applications(cmd, namespace): # pylint: disable=unused-argument
if namespace.application_configuration_overrides and \
len(namespace.application_version_ids) != len(namespace.application_configuration_overrides):
Expand Down Expand Up @@ -1382,6 +1391,7 @@ def process_vm_create_namespace(cmd, namespace):

if namespace.secrets:
_validate_secrets(namespace.secrets, namespace.os_type)
_validate_trusted_launch(namespace)
_validate_vm_vmss_msi(cmd, namespace)
if namespace.boot_diagnostics_storage:
namespace.boot_diagnostics_storage = get_storage_blob_uri(cmd.cli_ctx, namespace.boot_diagnostics_storage)
Expand Down Expand Up @@ -1586,6 +1596,7 @@ def process_vmss_create_namespace(cmd, namespace):
if namespace.vm_sku and not namespace.image:
raise ArgumentUsageError('usage error: please specify the --image when you want to specify the VM SKU')

_validate_trusted_launch(namespace)
if namespace.image:

if namespace.vm_sku is None:
Expand Down Expand Up @@ -1675,6 +1686,7 @@ def process_vmss_create_namespace(cmd, namespace):
_validate_vmss_create_nsg(cmd, namespace)
_validate_vm_vmss_accelerated_networking(cmd.cli_ctx, namespace)
_validate_vm_vmss_create_auth(namespace, cmd)
_validate_trusted_launch(namespace)
zhoxing-ms marked this conversation as resolved.
Show resolved Hide resolved
_validate_vm_vmss_msi(cmd, namespace)
_validate_proximity_placement_group(cmd, namespace)
_validate_vmss_terminate_notification(cmd, namespace)
Expand Down