early-musician-41645
09/26/2019, 5:27 PMawsx
module for creating a Windows ec2 instance. Is there any way to specify that the instance should join a Microsft AD domain?
The domain controller already exists as a managed Microsoft AD directory in AWS. I can get the instance to join "seamlessly" by creating it in the console:
https://docs.aws.amazon.com/directoryservice/latest/admin-guide/launching_instance.html
Or by logging in to the instance and configuring it:
https://docs.aws.amazon.com/directoryservice/latest/admin-guide/join_windows_instance.html
How can I achieve this with Pulumi?acceptable-army-69872
09/26/2019, 5:49 PMearly-musician-41645
09/26/2019, 6:01 PMWrite-Host "Signaling CloudFormation that the instance is up and running"
cfn-signal.exe --success true --region ${config.region} --stack ${stackName} --resource Instances
Write-Host "Updating DNS addresses to match the Directory Service"
Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter).ifIndex -ServerAddresses (${directoryDnsIpAddresses})
Write-Host "Joining the domain directory: ${directoryName}. This will force restart the instance."
$securePassword = ConvertTo-SecureString "${directoryPassword}" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential("Admin", $securePassword)
Add-Computer -Domain ${directoryName} -Credential $credential -Verbose -PassThru -Restart -Force
I've spent a couple days on this and found that UserData was the only way I could make progress. Was just wondering if this is already supported via Pulumi, e.g. through some launchconfiguration args for domain joining that would flow through as needed.clever-sunset-76585
09/26/2019, 6:05 PMearly-musician-41645
09/26/2019, 6:07 PMclever-sunset-76585
09/26/2019, 6:07 PMearly-musician-41645
09/26/2019, 6:09 PMclever-sunset-76585
09/26/2019, 6:09 PMAlso, isn’t the whole point of UserData to run commands after provisioning?I am not too familiar with UserData myself to be honest.
early-musician-41645
09/26/2019, 6:09 PMclever-sunset-76585
09/26/2019, 6:14 PMUserData is just a script you set in AWS launch configurations to run commands after an instance comes upAh I see. Yeah perhaps the difference with the link I provided would be that it wouldn’t run the remote script every time the instance is restarted (in my case I didn’t need that) unless the script is installed to do so vs. having a script that runs every time the instance comes up? I am assuming using UserData does the latter automatically?
early-musician-41645
09/26/2019, 6:18 PMclever-sunset-76585
09/26/2019, 6:19 PM