# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 resource "aws_ssm_document" "prepare_windows_instance" { name = "${var.project}-${var.environment}-prepare-windows-instance" document_type = "Automation" document_format = "YAML" target_type = "/AWS::EC2::Instance" content = < | list of instances where to apply this ddocument | - dcvExternalAuthEndpoint | String | The Authentication endpoint for Nice DCV login | ${var.dcv_auth_endpoint} dcvWebPort | String | The Web port (TCP) for DCV | ${var.tcp_port} dcvQuicPort | Number | The QUIC port (UDP) for DCV | ${var.udp_port} dcvNoTLSStrict | Number | Disable TLS strict | 1 schemaVersion: '0.3' parameters: InstanceIds: type: 'List' description: (Required) Provide the Instance Id. (e.g. i-07330aca1eb7fecc6 ) allowedPattern: '^[i]{0,1}-[a-z0-9]{8,17}$' dcvExternalAuthEndpoint: type: String description: (Required) [DCV] The Authentication endpoint for Nice DCV login default: '${var.dcv_auth_endpoint}' dcvWebPort: type: String description: (Required) [DCV] The Web port (TCP) for DCV default: '${var.tcp_port}' dcvQuicEnabled: type: String description: (Required) [DCV] If QUIC UDP should be enabled default: 'true' dcvQuicPort: type: String description: (Required) [DCV] The Quic port (UDP) for DCV default: '${var.udp_port}' dcvNoTLSStrict: type: String description: (Required) [DCV] Disable TLS strict default: 'true' mainSteps: - name: DCV_SetDCVExternalAuthEndpoint action: 'aws:runCommand' inputs: DocumentName: AWS-RunPowerShellScript Targets: - Key: InstanceIds Values: '{{InstanceIds}}' Parameters: commands: - 'New-ItemProperty -Path "Microsoft.PowerShell.Core\Registry::HKEY_USERS\S-1-5-18\Software\GSettings\com\nicesoftware\dcv\security" -Name auth-token-verifier -Value {{ dcvExternalAuthEndpoint }} -force' - name: DCV_SetWebPort action: 'aws:runCommand' inputs: DocumentName: AWS-RunPowerShellScript Targets: - Key: InstanceIds Values: '{{InstanceIds}}' Parameters: commands: - 'New-ItemProperty -Path "Microsoft.PowerShell.Core\Registry::HKEY_USERS\S-1-5-18\Software\GSettings\com\nicesoftware\dcv\connectivity" -Name web-port -PropertyType DWORD -Value {{ dcvWebPort }} -force' - name: DCV_SetQuicPort action: 'aws:runCommand' inputs: DocumentName: AWS-RunPowerShellScript Targets: - Key: InstanceIds Values: '{{InstanceIds}}' Parameters: commands: - 'New-ItemProperty -Path "Microsoft.PowerShell.Core\Registry::HKEY_USERS\S-1-5-18\Software\GSettings\com\nicesoftware\dcv\connectivity" -Name quic-port -PropertyType DWORD -Value {{ dcvQuicPort }} -force' - name: DCV_SetNoTLSStrict action: 'aws:runCommand' inputs: DocumentName: AWS-RunPowerShellScript Targets: - Key: InstanceIds Values: '{{InstanceIds}}' Parameters: commands: - 'New-ItemProperty -Path "Microsoft.PowerShell.Core\Registry::HKEY_USERS\S-1-5-18\Software\GSettings\com\nicesoftware\dcv\security" -Name no-tls-strict -PropertyType DWORD -Value {{ dcvNoTLSStrict }} -force' - name: DCV_RestartDCVServer action: 'aws:runCommand' inputs: DocumentName: AWS-RunPowerShellScript Targets: - Key: InstanceIds Values: '{{InstanceIds}}' Parameters: commands: - 'Restart-Service -Name dcvserver' DOC } resource "aws_ssm_document" "assign_windows_instance" { name = "${var.project}-${var.environment}-assign-windows-instance" document_type = "Automation" document_format = "YAML" target_type = "/AWS::EC2::Instance" content = <