是否可以使用powershell脚本创建批量aws ALB?

时间:2018-07-13 02:21:26

标签: amazon-web-services powershell amazon-elb

是否可以使用Powershell脚本创建批量AWS ALB?

如果有人可以提供Powershell脚本模板,那就太好了。

2 个答案:

答案 0 :(得分:0)

当然,您可以安装适用于PowerShell的AWS工具。检查下面的链接,那里有示例。

https://aws.amazon.com/powershell/

答案 1 :(得分:-1)

`# Create HTTP Listener
$HTTPListener = New-Object -TypeName ‘Amazon.ElasticLoadBalancing.Model.Listener’
$HTTPListener.Protocol = ‘http’
$HTTPListener.InstancePort = 80
$HTTPListener.LoadBalancerPort = 80

#Create HTTPS Listener
$HTTPSListener = New-Object -TypeName ‘Amazon.ElasticLoadBalancing.Model.Listener’
$HTTPSListener.Protocol = ‘http’
$HTTPSListener.InstancePort = 443
$HTTPSListener.LoadBalancerPort = 80
$HTTPSListener.SSLCertificateId = ‘YourSSL’

# Create Load Balancer
New-ELBLoadBalancer -LoadBalancerName ‘YourLoadBalancerName’ -Listeners 
@($HTTPListener, $HTTPSListener) -SecurityGroups @($sgId) -Subnets @($sn1Id, $sn2Id) 
-Scheme ‘internet-facing’

 # Create Load Balancer
 New-ELBLoadBalancer -LoadBalancerName ‘YourLoadBalancerName’ -Listeners 
 @($HTTPListener, $HTTPSListener) -SecurityGroups @(‘SecurityGroupId’) -Subnets 
 @(‘subnetId1’, ‘subnetId2’) -Scheme ‘internet-facing’

 # Associate Instances with Load Balancer
 Register-ELBInstanceWithLoadBalancer -LoadBalancerName ‘YourLoadBalancerName’ - 
 Instances @(‘instance1ID’, ‘instance2ID’)

 # Create Application Cookie Stickiness Policy
 New-ELBAppCookieStickinessPolicy -LoadBalancerName ‘YourLoadBalancerName’ - 
 PolicyName ‘SessionName’ -CookieName ‘CookieName’

 # Set the Application Cookie Stickiness Policy to Load Balancer
 Set-ELBLoadBalancerPolicyOfListener -LoadBalancerName ‘YourLoadBalancerName’ - 
 LoadBalancerPort 80 -PolicyNames ‘SessionName’`

此脚本仅用于一个弯头...如何转换此脚本以创建批量弯头? 此外,在何处提及AWS账户凭证?