chore(e2e): Update firewall rules for instances in the windows domain (#6059)
* chore(e2e): Update firewall rules * fix(e2e): Add ipv6_address
This commit is contained in:
1 parent
ac9774b574
commit
57d69637f8
3 files changed
+49
-11
No files matched your search
@@ -280,9 +280,21 @@ resource "aws_instance" "domain_controller" {
|
||||
# Force an immediate time synchronization
|
||||
w32tm /resync /force
|
||||
|
||||
$password = ConvertTo-SecureString ${random_string.DSRMPassword.result} -AsPlainText -Force
|
||||
Add-WindowsFeature -name ad-domain-services -IncludeManagementTools
|
||||
# Open firewall ports for RDP functionality
|
||||
New-NetFirewallRule -Name kerberostcp -DisplayName 'Kerberos TCP' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 88
|
||||
New-NetFirewallRule -Name kerberosudp -DisplayName 'Kerberos UDP' -Enabled True -Direction Inbound -Protocol UDP -Action Allow -LocalPort 88
|
||||
New-NetFirewallRule -Name rpctcp -DisplayName 'RPC TCP' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 135
|
||||
New-NetFirewallRule -Name rpcudp -DisplayName 'RPC UDP' -Enabled True -Direction Inbound -Protocol UDP -Action Allow -LocalPort 135
|
||||
New-NetFirewallRule -Name ldaptcp -DisplayName 'LDAP TCP' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 389
|
||||
New-NetFirewallRule -Name ldapudp -DisplayName 'LDAP UDP' -Enabled True -Direction Inbound -Protocol UDP -Action Allow -LocalPort 389
|
||||
New-NetFirewallRule -Name smbtcp -DisplayName 'SMB TCP' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 445
|
||||
New-NetFirewallRule -Name rdptcp -DisplayName 'RDP TCP' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 3389
|
||||
New-NetFirewallRule -Name rdpudp -DisplayName 'RDP UDP' -Enabled True -Direction Inbound -Protocol UDP -Action Allow -LocalPort 3389
|
||||
|
||||
# Add computer to the domain and promote to a domain
|
||||
# controller
|
||||
Add-WindowsFeature -name ad-domain-services -IncludeManagementTools
|
||||
$password = ConvertTo-SecureString ${random_string.DSRMPassword.result} -AsPlainText -Force
|
||||
# causes the instance to reboot
|
||||
Install-ADDSForest -CreateDnsDelegation:$false -DomainMode 7 -DomainName ${var.active_directory_domain} -DomainNetbiosName ${local.domain_sld} -ForestMode 7 -InstallDns:$true -NoRebootOnCompletion:$false -SafeModeAdministratorPassword $password -Force:$true
|
||||
</powershell>
|
||||
|
||||
@@ -70,13 +70,14 @@ resource "aws_instance" "member_server" {
|
||||
# Force an immediate time synchronization
|
||||
w32tm /resync /force
|
||||
|
||||
# Set up SSH so we can remotely manage the instance
|
||||
# Note: Windows Server 2016 does not support OpenSSH
|
||||
%{if var.server_version != "2016"~}
|
||||
# set variables for retry loops
|
||||
$timeout = 300
|
||||
$interval = 30
|
||||
|
||||
# Set up SSH so we can remotely manage the instance
|
||||
## Install OpenSSH Server and Client
|
||||
# Install OpenSSH Server and Client
|
||||
# Loop to make sure that SSH installs correctly
|
||||
$elapsed = 0
|
||||
do {
|
||||
@@ -122,25 +123,36 @@ resource "aws_instance" "member_server" {
|
||||
}
|
||||
} while ($true)
|
||||
|
||||
## Set PowerShell as the default SSH shell
|
||||
# Set PowerShell as the default SSH shell
|
||||
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value (Get-Command powershell.exe).Path -PropertyType String -Force
|
||||
|
||||
## Configure SSH server to use private key authentication so that scripts don't have to use passwords
|
||||
## Save the private key from instance metadata
|
||||
# Configure SSH server to use private key authentication so that scripts don't have to use passwords
|
||||
# Save the private key from instance metadata
|
||||
$ImdsToken = (Invoke-WebRequest -Uri 'http://169.254.169.254/latest/api/token' -Method 'PUT' -Headers @{'X-aws-ec2-metadata-token-ttl-seconds' = 2160} -UseBasicParsing).Content
|
||||
$ImdsHeaders = @{'X-aws-ec2-metadata-token' = $ImdsToken}
|
||||
$AuthorizedKey = (Invoke-WebRequest -Uri 'http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key' -Headers $ImdsHeaders -UseBasicParsing).Content
|
||||
$AuthorizedKeysPath = 'C:\ProgramData\ssh\administrators_authorized_keys'
|
||||
New-Item -Path $AuthorizedKeysPath -ItemType File -Value $AuthorizedKey -Force
|
||||
|
||||
## Ensure the SSH agent pulls in the new key.
|
||||
# Ensure the SSH agent pulls in the new key.
|
||||
Set-Service -Name ssh-agent -StartupType "Automatic"
|
||||
Restart-Service -Name ssh-agent
|
||||
|
||||
## Open the firewall for SSH connections
|
||||
# Open the firewall for SSH connections
|
||||
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
|
||||
%{endif~}
|
||||
|
||||
# Open firewall ports for RDP functionality
|
||||
New-NetFirewallRule -Name kerberostcp -DisplayName 'Kerberos TCP' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 88
|
||||
New-NetFirewallRule -Name kerberosudp -DisplayName 'Kerberos UDP' -Enabled True -Direction Inbound -Protocol UDP -Action Allow -LocalPort 88
|
||||
New-NetFirewallRule -Name rpctcp -DisplayName 'RPC TCP ' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 135
|
||||
New-NetFirewallRule -Name rpcudp -DisplayName 'RPC UDP' -Enabled True -Direction Inbound -Protocol UDP -Action Allow -LocalPort 135
|
||||
New-NetFirewallRule -Name ldaptcp -DisplayName 'LDAP TCP ' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 389
|
||||
New-NetFirewallRule -Name ldapudp -DisplayName 'LDAP UDP' -Enabled True -Direction Inbound -Protocol UDP -Action Allow -LocalPort 389
|
||||
New-NetFirewallRule -Name smbtcp -DisplayName 'SMB TCP ' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 445
|
||||
New-NetFirewallRule -Name rdptcp -DisplayName 'RDP TCP ' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 3389
|
||||
New-NetFirewallRule -Name rdpudp -DisplayName 'RDP UDP' -Enabled True -Direction Inbound -Protocol UDP -Action Allow -LocalPort 3389
|
||||
|
||||
# Adds member server to the domain
|
||||
[int]$intix = Get-NetAdapter | % { Process { If ( $_.Status -eq "up" ) { $_.ifIndex } }}
|
||||
Set-DNSClientServerAddress -interfaceIndex $intix -ServerAddresses ("${var.domain_controller_ip}","127.0.0.1")
|
||||
|
||||
@@ -75,6 +75,7 @@ resource "aws_instance" "worker" {
|
||||
key_name = var.domain_controller_aws_keypair_name
|
||||
subnet_id = data.aws_subnets.infra.ids[0]
|
||||
iam_instance_profile = var.iam_name
|
||||
ipv6_address_count = 1
|
||||
|
||||
root_block_device {
|
||||
volume_type = "gp2"
|
||||
@@ -101,7 +102,7 @@ resource "aws_instance" "worker" {
|
||||
$interval = 30
|
||||
|
||||
# Set up SSH so we can remotely manage the instance
|
||||
## Install OpenSSH Server and Client
|
||||
# Install OpenSSH Server and Client
|
||||
# Loop to make sure that SSH installs correctly
|
||||
$elapsed = 0
|
||||
do {
|
||||
@@ -162,11 +163,24 @@ resource "aws_instance" "worker" {
|
||||
Set-Service -Name ssh-agent -StartupType "Automatic"
|
||||
Restart-Service -Name ssh-agent
|
||||
|
||||
## Open the firewall for SSH and boundary connections
|
||||
# Open the firewall for SSH
|
||||
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
|
||||
|
||||
# Open firewall for boundary connections
|
||||
New-NetFirewallRule -Name boundary_in -DisplayName 'Boundary inbound' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 9202
|
||||
New-NetFirewallRule -Name boundary_out -DisplayName 'Boundary outbound' -Enabled True -Direction Outbound -Protocol TCP -Action Allow -LocalPort 9202
|
||||
|
||||
# Open firewall ports for RDP functionality
|
||||
New-NetFirewallRule -Name kerberostcp -DisplayName 'Kerberos TCP' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 88
|
||||
New-NetFirewallRule -Name kerberosudp -DisplayName 'Kerberos UDP' -Enabled True -Direction Inbound -Protocol UDP -Action Allow -LocalPort 88
|
||||
New-NetFirewallRule -Name rpctcp -DisplayName 'RPC TCP' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 135
|
||||
New-NetFirewallRule -Name rpcudp -DisplayName 'RPC UDP' -Enabled True -Direction Inbound -Protocol UDP -Action Allow -LocalPort 135
|
||||
New-NetFirewallRule -Name ldaptcp -DisplayName 'LDAP TCP' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 389
|
||||
New-NetFirewallRule -Name ldapudp -DisplayName 'LDAP UDP' -Enabled True -Direction Inbound -Protocol UDP -Action Allow -LocalPort 389
|
||||
New-NetFirewallRule -Name smbtcp -DisplayName 'SMB TCP' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 445
|
||||
New-NetFirewallRule -Name rdptcp -DisplayName 'RDP TCP' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 3389
|
||||
New-NetFirewallRule -Name rdpudp -DisplayName 'RDP UDP' -Enabled True -Direction Inbound -Protocol UDP -Action Allow -LocalPort 3389
|
||||
|
||||
# Add computer to the domain
|
||||
[int]$intix = Get-NetAdapter | % { Process { If ( $_.Status -eq "up" ) { $_.ifIndex } }}
|
||||
Set-DNSClientServerAddress -interfaceIndex $intix -ServerAddresses ("${var.domain_controller_ip}","127.0.0.1")
|
||||
|
||||
Reference in new issue
Block a user