{"record":{"id":"a66426e01ee17fba","repo":"hashicorp/terraform","slug":"target-platform-for-provisioner-has-to-be-either","errorCode":null,"errorMessage":"target_platform for provisioner has to be either %s or %s","messagePattern":"target_platform for provisioner has to be either (.+?) or (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/communicator/ssh/provisioner.go","lineNumber":203,"sourceCode":"\n\t// Check if host is empty.\n\t// Otherwise return error.\n\tif connInfo.Host == \"\" {\n\t\treturn nil, fmt.Errorf(\"host for provisioner cannot be empty\")\n\t}\n\n\t// Format the host if needed.\n\t// Needed for IPv6 support.\n\tconnInfo.Host = shared.IpFormat(connInfo.Host)\n\n\tif connInfo.Port == 0 {\n\t\tconnInfo.Port = DefaultPort\n\t}\n\t// Set default targetPlatform to unix if it's empty\n\tif connInfo.TargetPlatform == \"\" {\n\t\tconnInfo.TargetPlatform = TargetPlatformUnix\n\t} else if connInfo.TargetPlatform != TargetPlatformUnix && connInfo.TargetPlatform != TargetPlatformWindows {\n\t\treturn nil, fmt.Errorf(\"target_platform for provisioner has to be either %s or %s\", TargetPlatformUnix, TargetPlatformWindows)\n\t}\n\t// Choose an appropriate default script path based on the target platform. There is no single\n\t// suitable default script path which works on both UNIX and Windows targets.\n\tif connInfo.ScriptPath == \"\" && connInfo.TargetPlatform == TargetPlatformUnix {\n\t\tconnInfo.ScriptPath = DefaultUnixScriptPath\n\t}\n\tif connInfo.ScriptPath == \"\" && connInfo.TargetPlatform == TargetPlatformWindows {\n\t\tconnInfo.ScriptPath = DefaultWindowsScriptPath\n\t}\n\tif connInfo.Timeout != \"\" {\n\t\tconnInfo.TimeoutVal = safeDuration(connInfo.Timeout, DefaultTimeout)\n\t} else {\n\t\tconnInfo.TimeoutVal = DefaultTimeout\n\t}\n\n\t// Default all bastion config attrs to their non-bastion counterparts\n\tif connInfo.BastionHost != \"\" {\n\t\t// Format the bastion host if needed.","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/communicator/ssh/provisioner.go#L185-L221","documentation":"Raised in parseConnectionInfo when target_platform is set to a value other than 'unix' or 'windows'. The communicator uses target_platform to decide script shebang injection, SCP command quoting, and default script paths, so an invalid value is rejected at config-parse time.","triggerScenarios":"The connection block specifies target_platform with a typo or unsupported value such as \"linux\", \"Win\", \"unix64\", or \"macos\".","commonSituations":"Typo in the target_platform attribute, confusion between OS name and platform identifier (e.g. using 'linux' instead of 'unix'), or copy-paste from documentation using the wrong value.","solutions":["Set target_platform to exactly 'unix' or 'windows'.","If the attribute is not needed, omit it entirely (it defaults to 'unix').","Check for typos or trailing whitespace in the value."],"exampleFix":"// before\nconnection {\n  host            = var.host\n  target_platform = \"linux\"\n}\n\n// after\nconnection {\n  host            = var.host\n  target_platform = \"unix\"\n}","handlingStrategy":"validation","validationCode":"// Validate target_platform before passing to the communicator\nfunc validateTargetPlatform(platform string) error {\n    if platform == \"\" {\n        return nil // defaults to unix\n    }\n    if platform != \"unix\" && platform != \"windows\" {\n        return fmt.Errorf(\"target_platform must be 'unix' or 'windows', got %q\", platform)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use 'unix' or 'windows' for target_platform.","Omit target_platform entirely if the target is unix (it is the default).","Double-check for typos or incorrect casing in the value."],"tags":["configuration","validation","target-platform","connection-block","terraform"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}