Update 1 Host Script
Updating the script to not require the association of an AWS Account, plus some other general corrections.
This commit is contained in:
@@ -7,9 +7,10 @@
|
|||||||
|
|
||||||
# Set details for SDDC
|
# Set details for SDDC
|
||||||
$oauthToken = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
|
$oauthToken = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
|
||||||
$sddcName = "PowerCLI-1Node-SDDC"
|
$sddcName = "PowerCLI-1Host-SDDC"
|
||||||
$hostCount = "1"
|
$hostCount = "1"
|
||||||
$awsRegion = "US_WEST_2"
|
$awsRegion = "US_WEST_2"
|
||||||
|
$useAwsAccount = $false
|
||||||
|
|
||||||
# --- Deployment code ---
|
# --- Deployment code ---
|
||||||
# Connect to VMware Cloud Service
|
# Connect to VMware Cloud Service
|
||||||
@@ -18,19 +19,25 @@ Connect-Vmc -RefreshToken $oauthToken | Out-Null
|
|||||||
# Get ORG ID
|
# Get ORG ID
|
||||||
$orgSvc = Get-VmcService -Name com.vmware.vmc.orgs
|
$orgSvc = Get-VmcService -Name com.vmware.vmc.orgs
|
||||||
$org = $orgSvc.List()
|
$org = $orgSvc.List()
|
||||||
Write-Host "Org:"$org.display_name" ID:"$org.id
|
Write-Output -InputObject "Org: $($org.display_name) ID: $($org.id)"
|
||||||
|
|
||||||
# Get Linked Account ID
|
# Check to use the already existing AWS account connection
|
||||||
$connAcctSvc = Get-VmcService -Name com.vmware.vmc.orgs.account_link.connected_accounts
|
if ($useAwsAccount -eq $true) {
|
||||||
$connAcctId = $connAcctSvc.get($org.id) | Select-Object -ExpandProperty id
|
# Get Linked Account ID
|
||||||
Write-Host "Account ID: $connAcctId"
|
$connAcctSvc = Get-VmcService -Name com.vmware.vmc.orgs.account_link.connected_accounts
|
||||||
|
$connAcctId = $connAcctSvc.get($org.id) | Select-Object -ExpandProperty id
|
||||||
|
Write-Output -InputObject "Account ID: $connAcctId"
|
||||||
|
|
||||||
# Get Subnet ID
|
# Get Subnet ID
|
||||||
$compSubnetSvc = Get-VmcService -Name com.vmware.vmc.orgs.account_link.compatible_subnets
|
$compSubnetSvc = Get-VmcService -Name com.vmware.vmc.orgs.account_link.compatible_subnets
|
||||||
$vpcMap = $compSubnetSvc.Get($org.id, $connAcctId, $region) | Select-Object -ExpandProperty vpc_map
|
$vpcMap = $compSubnetSvc.Get($org.id, $connAcctId, $region) | Select-Object -ExpandProperty vpc_map
|
||||||
$compSubnets = $vpcMap | Select-Object -ExpandProperty Values | Select-Object -ExpandProperty subnets
|
$compSubnets = $vpcMap | Select-Object -ExpandProperty Values | Select-Object -ExpandProperty subnets
|
||||||
$compSubnet = $compSubnets | where {$_.name -ne $null} | Select-Object -first 1
|
$compSubnet = $compSubnets | where {$_.name -ne $null} | Select-Object -first 1
|
||||||
Write-Host "Subnet CIDR"$compSubnet.subnet_cidr_block"ID:"$compSubnet.subnet_id
|
Write-Output -InputObject "Subnet CIDR $($compSubnet.subnet_cidr_block) ID: $($compSubnet.subnet_id)"
|
||||||
|
}
|
||||||
|
elseif ($useAwsAccount -eq $false) {
|
||||||
|
Write-Output -InputObject "AWS Account Not Configured - you must connect to an AWS account within 14 days of creating this SDDC"
|
||||||
|
}
|
||||||
|
|
||||||
# Deploy the SDDC
|
# Deploy the SDDC
|
||||||
$sddcSvc = Get-VmcService com.vmware.vmc.orgs.sddcs
|
$sddcSvc = Get-VmcService com.vmware.vmc.orgs.sddcs
|
||||||
@@ -40,12 +47,20 @@ $sddcCreateSpec.Name = $sddcName
|
|||||||
$sddcCreateSpec.num_hosts = $hostCount
|
$sddcCreateSpec.num_hosts = $hostCount
|
||||||
if ($org.properties.values.sddcTypes) {$sddcCreateSpec.sddc_type = "1NODE"}
|
if ($org.properties.values.sddcTypes) {$sddcCreateSpec.sddc_type = "1NODE"}
|
||||||
$sddcCreateSpec.Provider = "AWS"
|
$sddcCreateSpec.Provider = "AWS"
|
||||||
$accountLinkSpec = $sddcSvc.Help.create.sddc_config.account_link_sddc_config.Element.Create()
|
|
||||||
$accountLinkSpec.connected_account_id = $connAcctId
|
if ($useAwsAccount -eq $true) {
|
||||||
$custSubId0 = $sddcSvc.Help.create.sddc_config.account_link_sddc_config.Element.customer_subnet_ids.Element.Create()
|
$accountLinkSpec = $sddcSvc.Help.create.sddc_config.account_link_sddc_config.Element.Create()
|
||||||
$custSubId0 = $compSubnet.subnet_id
|
$accountLinkSpec.connected_account_id = $connAcctId
|
||||||
$accountLinkSpec.customer_subnet_ids.Add($custSubId0) | Out-Null
|
$custSubId0 = $sddcSvc.Help.create.sddc_config.account_link_sddc_config.Element.customer_subnet_ids.Element.Create()
|
||||||
$sddcCreateSpec.account_link_sddc_config.Add($accountLinkSpec) | Out-Null
|
$custSubId0 = $compSubnet.subnet_id
|
||||||
$sddcCreateSpec
|
$accountLinkSpec.customer_subnet_ids.Add($custSubId0) | Out-Null
|
||||||
|
$sddcCreateSpec.account_link_sddc_config.Add($accountLinkSpec) | Out-Null
|
||||||
|
}
|
||||||
|
elseif ($useAwsAccount -eq $false) {
|
||||||
|
$accountLinkDelaySpec = $sddcSvc.Help.create.sddc_config.account_link_config.delay_account_link.Create()
|
||||||
|
$accountLinkDelaySpec = $true
|
||||||
|
$sddcCreateSpec.account_link_config.delay_account_link = $accountLinkDelaySpec
|
||||||
|
}
|
||||||
|
|
||||||
$newSddc = $sddcSvc.create($org.Id, $sddcCreateSpec)
|
$newSddc = $sddcSvc.create($org.Id, $sddcCreateSpec)
|
||||||
$newSddc
|
$newSddc | Select-Object resource_id,status,task_type,start_time,task_id
|
||||||
Reference in New Issue
Block a user