You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1769 lines
58 KiB

  1. //
  2. // autoscaling: This package provides types and functions to interact with the AWS Auto Scale API
  3. //
  4. // Depends on https://wiki.ubuntu.com/goamz
  5. //
  6. package autoscaling
  7. import (
  8. "encoding/base64"
  9. "encoding/xml"
  10. "fmt"
  11. "log"
  12. "net/http"
  13. "net/http/httputil"
  14. "net/url"
  15. "sort"
  16. "strconv"
  17. "strings"
  18. "time"
  19. "github.com/goamz/goamz/aws"
  20. )
  21. const debug = false
  22. var timeNow = time.Now
  23. // AutoScaling contains the details of the AWS region to perform operations against.
  24. type AutoScaling struct {
  25. aws.Auth
  26. aws.Region
  27. }
  28. // New creates a new AutoScaling Client.
  29. func New(auth aws.Auth, region aws.Region) *AutoScaling {
  30. return &AutoScaling{auth, region}
  31. }
  32. // ----------------------------------------------------------------------------
  33. // Request dispatching logic.
  34. // Error encapsulates an error returned by the AWS Auto Scaling API.
  35. //
  36. // See http://goo.gl/VZGuC for more details.
  37. type Error struct {
  38. // HTTP status code (200, 403, ...)
  39. StatusCode int
  40. // AutoScaling error code ("UnsupportedOperation", ...)
  41. Code string
  42. // The error type
  43. Type string
  44. // The human-oriented error message
  45. Message string
  46. RequestId string `xml:"RequestID"`
  47. }
  48. func (err *Error) Error() string {
  49. if err.Code == "" {
  50. return err.Message
  51. }
  52. return fmt.Sprintf("%s (%s)", err.Message, err.Code)
  53. }
  54. type xmlErrors struct {
  55. RequestId string `xml:"RequestId"`
  56. Errors []Error `xml:"Error"`
  57. }
  58. func (as *AutoScaling) query(params map[string]string, resp interface{}) error {
  59. params["Version"] = "2011-01-01"
  60. data := strings.NewReader(multimap(params).Encode())
  61. hreq, err := http.NewRequest("POST", as.Region.AutoScalingEndpoint+"/", data)
  62. if err != nil {
  63. return err
  64. }
  65. hreq.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value")
  66. token := as.Auth.Token()
  67. if token != "" {
  68. hreq.Header.Set("X-Amz-Security-Token", token)
  69. }
  70. signer := aws.NewV4Signer(as.Auth, "autoscaling", as.Region)
  71. signer.Sign(hreq)
  72. if debug {
  73. log.Printf("%v -> {\n", hreq)
  74. }
  75. r, err := http.DefaultClient.Do(hreq)
  76. if err != nil {
  77. log.Printf("Error calling Amazon %v", err)
  78. return err
  79. }
  80. defer r.Body.Close()
  81. if debug {
  82. dump, _ := httputil.DumpResponse(r, true)
  83. log.Printf("response:\n")
  84. log.Printf("%v\n}\n", string(dump))
  85. }
  86. if r.StatusCode != 200 {
  87. return buildError(r)
  88. }
  89. err = xml.NewDecoder(r.Body).Decode(resp)
  90. return err
  91. }
  92. func buildError(r *http.Response) error {
  93. var (
  94. err Error
  95. errors xmlErrors
  96. )
  97. xml.NewDecoder(r.Body).Decode(&errors)
  98. if len(errors.Errors) > 0 {
  99. err = errors.Errors[0]
  100. }
  101. err.RequestId = errors.RequestId
  102. err.StatusCode = r.StatusCode
  103. if err.Message == "" {
  104. err.Message = r.Status
  105. }
  106. return &err
  107. }
  108. func multimap(p map[string]string) url.Values {
  109. q := make(url.Values, len(p))
  110. for k, v := range p {
  111. q[k] = []string{v}
  112. }
  113. return q
  114. }
  115. func makeParams(action string) map[string]string {
  116. params := make(map[string]string)
  117. params["Action"] = action
  118. return params
  119. }
  120. func addParamsList(params map[string]string, label string, ids []string) {
  121. for i, id := range ids {
  122. params[label+"."+strconv.Itoa(i+1)] = id
  123. }
  124. }
  125. // ----------------------------------------------------------------------------
  126. // Filtering helper.
  127. // Filter builds filtering parameters to be used in an autoscaling query which supports
  128. // filtering. For example:
  129. //
  130. // filter := NewFilter()
  131. // filter.Add("architecture", "i386")
  132. // filter.Add("launch-index", "0")
  133. // resp, err := as.DescribeTags(filter,nil,nil)
  134. //
  135. type Filter struct {
  136. m map[string][]string
  137. }
  138. // NewFilter creates a new Filter.
  139. func NewFilter() *Filter {
  140. return &Filter{make(map[string][]string)}
  141. }
  142. // Add appends a filtering parameter with the given name and value(s).
  143. func (f *Filter) Add(name string, value ...string) {
  144. f.m[name] = append(f.m[name], value...)
  145. }
  146. func (f *Filter) addParams(params map[string]string) {
  147. if f != nil {
  148. a := make([]string, len(f.m))
  149. i := 0
  150. for k := range f.m {
  151. a[i] = k
  152. i++
  153. }
  154. sort.StringSlice(a).Sort()
  155. for i, k := range a {
  156. prefix := "Filters.member." + strconv.Itoa(i+1)
  157. params[prefix+".Name"] = k
  158. for j, v := range f.m[k] {
  159. params[prefix+".Values.member."+strconv.Itoa(j+1)] = v
  160. }
  161. }
  162. }
  163. }
  164. // ----------------------------------------------------------------------------
  165. // Auto Scaling base types and related functions.
  166. // SimpleResp is the basic response from most actions.
  167. type SimpleResp struct {
  168. XMLName xml.Name
  169. RequestId string `xml:"ResponseMetadata>RequestId"`
  170. }
  171. // EnabledMetric encapsulates a metric associated with an Auto Scaling Group
  172. //
  173. // See http://goo.gl/hXiH17 for more details
  174. type EnabledMetric struct {
  175. Granularity string `xml:"Granularity"` // The granularity of the enabled metric.
  176. Metric string `xml:"Metric"` // The name of the enabled metric.
  177. }
  178. // Instance encapsulates an instance type as returned by the Auto Scaling API
  179. //
  180. // See http://goo.gl/NwBxGh and http://goo.gl/OuoqhS for more details.
  181. type Instance struct {
  182. // General instance information
  183. AutoScalingGroupName string `xml:"AutoScalingGroupName"`
  184. AvailabilityZone string `xml:"AvailabilityZone"`
  185. HealthStatus string `xml:"HealthStatus"`
  186. InstanceId string `xml:"InstanceId"`
  187. LaunchConfigurationName string `xml:"LaunchConfigurationName"`
  188. LifecycleState string `xml:"LifecycleState"`
  189. }
  190. // SuspenedProcess encapsulates an Auto Scaling process that has been suspended
  191. //
  192. // See http://goo.gl/iObPgF for more details
  193. type SuspendedProcess struct {
  194. ProcessName string `xml:"ProcessName"`
  195. SuspensionReason string `xml:"SuspensionReason"`
  196. }
  197. // Tag encapsulates tag applied to an Auto Scaling group.
  198. //
  199. // See http://goo.gl/MG1hqs for more details
  200. type Tag struct {
  201. Key string `xml:"Key"`
  202. PropagateAtLaunch bool `xml:"PropagateAtLaunch"` // Specifies whether the new tag will be applied to instances launched after the tag is created
  203. ResourceId string `xml:"ResourceId"` // the name of the Auto Scaling group - not required if creating ASG
  204. ResourceType string `xml:"ResourceType"` // currently only auto-scaling-group is supported - not required if creating ASG
  205. Value string `xml:"Value"`
  206. }
  207. // AutoScalingGroup encapsulates an Auto Scaling Group object
  208. //
  209. // See http://goo.gl/fJdYhg for more details.
  210. type AutoScalingGroup struct {
  211. AutoScalingGroupARN string `xml:"AutoScalingGroupARN"`
  212. AutoScalingGroupName string `xml:"AutoScalingGroupName"`
  213. AvailabilityZones []string `xml:"AvailabilityZones>member"`
  214. CreatedTime time.Time `xml:"CreatedTime"`
  215. DefaultCooldown int `xml:"DefaultCooldown"`
  216. DesiredCapacity int `xml:"DesiredCapacity"`
  217. EnabledMetrics []EnabledMetric `xml:"EnabledMetric>member"`
  218. HealthCheckGracePeriod int `xml:"HealthCheckGracePeriod"`
  219. HealthCheckType string `xml:"HealthCheckType"`
  220. Instances []Instance `xml:"Instances>member"`
  221. LaunchConfigurationName string `xml:"LaunchConfigurationName"`
  222. LoadBalancerNames []string `xml:"LoadBalancerNames>member"`
  223. MaxSize int `xml:"MaxSize"`
  224. MinSize int `xml:"MinSize"`
  225. PlacementGroup string `xml:"PlacementGroup"`
  226. Status string `xml:"Status"`
  227. SuspendedProcesses []SuspendedProcess `xml:"SuspendedProcesses>member"`
  228. Tags []Tag `xml:"Tags>member"`
  229. TerminationPolicies []string `xml:"TerminationPolicies>member"`
  230. VPCZoneIdentifier string `xml:"VPCZoneIdentifier"`
  231. }
  232. // CreateAutoScalingGroupParams type encapsulates options for the respective request.
  233. //
  234. // See http://goo.gl/3S13Bv for more details.
  235. type CreateAutoScalingGroupParams struct {
  236. AutoScalingGroupName string
  237. AvailabilityZones []string
  238. DefaultCooldown int
  239. DesiredCapacity int
  240. HealthCheckGracePeriod int
  241. HealthCheckType string
  242. InstanceId string
  243. LaunchConfigurationName string
  244. LoadBalancerNames []string
  245. MaxSize int
  246. MinSize int
  247. PlacementGroup string
  248. Tags []Tag
  249. TerminationPolicies []string
  250. VPCZoneIdentifier string
  251. }
  252. // AttachInstances Attach running instances to an autoscaling group
  253. //
  254. // See http://goo.gl/zDZbuQ for more details.
  255. func (as *AutoScaling) AttachInstances(name string, instanceIds []string) (resp *SimpleResp, err error) {
  256. params := makeParams("AttachInstances")
  257. params["AutoScalingGroupName"] = name
  258. for i, id := range instanceIds {
  259. key := fmt.Sprintf("InstanceIds.member.%d", i+1)
  260. params[key] = id
  261. }
  262. resp = new(SimpleResp)
  263. if err := as.query(params, resp); err != nil {
  264. return nil, err
  265. }
  266. return resp, nil
  267. }
  268. // CreateAutoScalingGroup creates an Auto Scaling Group on AWS
  269. //
  270. // Required params: AutoScalingGroupName, MinSize, MaxSize
  271. //
  272. // See http://goo.gl/3S13Bv for more details.
  273. func (as *AutoScaling) CreateAutoScalingGroup(options *CreateAutoScalingGroupParams) (
  274. resp *SimpleResp, err error) {
  275. params := makeParams("CreateAutoScalingGroup")
  276. params["AutoScalingGroupName"] = options.AutoScalingGroupName
  277. params["MaxSize"] = strconv.Itoa(options.MaxSize)
  278. params["MinSize"] = strconv.Itoa(options.MinSize)
  279. params["DesiredCapacity"] = strconv.Itoa(options.DesiredCapacity)
  280. if options.DefaultCooldown > 0 {
  281. params["DefaultCooldown"] = strconv.Itoa(options.DefaultCooldown)
  282. }
  283. if options.HealthCheckGracePeriod > 0 {
  284. params["HealthCheckGracePeriod"] = strconv.Itoa(options.HealthCheckGracePeriod)
  285. }
  286. if options.HealthCheckType != "" {
  287. params["HealthCheckType"] = options.HealthCheckType
  288. }
  289. if options.InstanceId != "" {
  290. params["InstanceId"] = options.InstanceId
  291. }
  292. if options.LaunchConfigurationName != "" {
  293. params["LaunchConfigurationName"] = options.LaunchConfigurationName
  294. }
  295. if options.PlacementGroup != "" {
  296. params["PlacementGroup"] = options.PlacementGroup
  297. }
  298. if options.VPCZoneIdentifier != "" {
  299. params["VPCZoneIdentifier"] = options.VPCZoneIdentifier
  300. }
  301. if len(options.LoadBalancerNames) > 0 {
  302. addParamsList(params, "LoadBalancerNames.member", options.LoadBalancerNames)
  303. }
  304. if len(options.AvailabilityZones) > 0 {
  305. addParamsList(params, "AvailabilityZones.member", options.AvailabilityZones)
  306. }
  307. if len(options.TerminationPolicies) > 0 {
  308. addParamsList(params, "TerminationPolicies.member", options.TerminationPolicies)
  309. }
  310. for i, t := range options.Tags {
  311. key := "Tags.member.%d.%s"
  312. index := i + 1
  313. params[fmt.Sprintf(key, index, "Key")] = t.Key
  314. params[fmt.Sprintf(key, index, "Value")] = t.Value
  315. params[fmt.Sprintf(key, index, "PropagateAtLaunch")] = strconv.FormatBool(t.PropagateAtLaunch)
  316. }
  317. resp = new(SimpleResp)
  318. if err := as.query(params, resp); err != nil {
  319. return nil, err
  320. }
  321. return resp, nil
  322. }
  323. // EBS represents the AWS EBS volume data type
  324. //
  325. // See http://goo.gl/nDUL2h for more details
  326. type EBS struct {
  327. DeleteOnTermination bool `xml:"DeleteOnTermination"`
  328. Iops int `xml:"Iops"`
  329. SnapshotId string `xml:"SnapshotId"`
  330. VolumeSize int `xml:"VolumeSize"`
  331. VolumeType string `xml:"VolumeType"`
  332. }
  333. // BlockDeviceMapping represents the association of a block device with ebs volume.
  334. //
  335. // See http://goo.gl/wEGwkU for more details.
  336. type BlockDeviceMapping struct {
  337. DeviceName string `xml:"DeviceName"`
  338. Ebs EBS `xml:"Ebs"`
  339. NoDevice bool `xml:"NoDevice"`
  340. VirtualName string `xml:"VirtualName"`
  341. }
  342. // InstanceMonitoring data type
  343. //
  344. // See http://goo.gl/TfaPwz for more details
  345. type InstanceMonitoring struct {
  346. Enabled bool `xml:"Enabled"`
  347. }
  348. // LaunchConfiguration encapsulates the LaunchConfiguration Data Type
  349. //
  350. // See http://goo.gl/TOJunp
  351. type LaunchConfiguration struct {
  352. AssociatePublicIpAddress bool `xml:"AssociatePublicIpAddress"`
  353. BlockDeviceMappings []BlockDeviceMapping `xml:"BlockDeviceMappings>member"`
  354. CreatedTime time.Time `xml:"CreatedTime"`
  355. EbsOptimized bool `xml:"EbsOptimized"`
  356. IamInstanceProfile string `xml:"IamInstanceProfile"`
  357. ImageId string `xml:"ImageId"`
  358. InstanceId string `xml:"InstanceId"`
  359. InstanceMonitoring InstanceMonitoring `xml:"InstanceMonitoring"`
  360. InstanceType string `xml:"InstanceType"`
  361. KernelId string `xml:"KernelId"`
  362. KeyName string `xml:"KeyName"`
  363. LaunchConfigurationARN string `xml:"LaunchConfigurationARN"`
  364. LaunchConfigurationName string `xml:"LaunchConfigurationName"`
  365. RamdiskId string `xml:"RamdiskId"`
  366. SecurityGroups []string `xml:"SecurityGroups>member"`
  367. SpotPrice string `xml:"SpotPrice"`
  368. UserData string `xml:"UserData"`
  369. }
  370. // CreateLaunchConfiguration creates a launch configuration
  371. //
  372. // Required params: AutoScalingGroupName, MinSize, MaxSize
  373. //
  374. // See http://goo.gl/8e0BSF for more details.
  375. func (as *AutoScaling) CreateLaunchConfiguration(lc *LaunchConfiguration) (
  376. resp *SimpleResp, err error) {
  377. var b64 = base64.StdEncoding
  378. params := makeParams("CreateLaunchConfiguration")
  379. params["LaunchConfigurationName"] = lc.LaunchConfigurationName
  380. if lc.AssociatePublicIpAddress {
  381. params["AssociatePublicIpAddress"] = strconv.FormatBool(lc.AssociatePublicIpAddress)
  382. }
  383. if lc.EbsOptimized {
  384. params["EbsOptimized"] = strconv.FormatBool(lc.EbsOptimized)
  385. }
  386. if lc.IamInstanceProfile != "" {
  387. params["IamInstanceProfile"] = lc.IamInstanceProfile
  388. }
  389. if lc.ImageId != "" {
  390. params["ImageId"] = lc.ImageId
  391. }
  392. if lc.InstanceId != "" {
  393. params["InstanceId"] = lc.InstanceId
  394. }
  395. if lc.InstanceMonitoring != (InstanceMonitoring{}) {
  396. params["InstanceMonitoring.Enabled"] = strconv.FormatBool(lc.InstanceMonitoring.Enabled)
  397. }
  398. if lc.InstanceType != "" {
  399. params["InstanceType"] = lc.InstanceType
  400. }
  401. if lc.KernelId != "" {
  402. params["KernelId"] = lc.KernelId
  403. }
  404. if lc.KeyName != "" {
  405. params["KeyName"] = lc.KeyName
  406. }
  407. if lc.RamdiskId != "" {
  408. params["RamdiskId"] = lc.RamdiskId
  409. }
  410. if lc.SpotPrice != "" {
  411. params["SpotPrice"] = lc.SpotPrice
  412. }
  413. if lc.UserData != "" {
  414. params["UserData"] = b64.EncodeToString([]byte(lc.UserData))
  415. }
  416. // Add our block device mappings
  417. for i, bdm := range lc.BlockDeviceMappings {
  418. key := "BlockDeviceMappings.member.%d.%s"
  419. index := i + 1
  420. params[fmt.Sprintf(key, index, "DeviceName")] = bdm.DeviceName
  421. params[fmt.Sprintf(key, index, "VirtualName")] = bdm.VirtualName
  422. if bdm.NoDevice {
  423. params[fmt.Sprintf(key, index, "NoDevice")] = "true"
  424. }
  425. if bdm.Ebs != (EBS{}) {
  426. key := "BlockDeviceMappings.member.%d.Ebs.%s"
  427. // Defaults to true
  428. params[fmt.Sprintf(key, index, "DeleteOnTermination")] = strconv.FormatBool(bdm.Ebs.DeleteOnTermination)
  429. if bdm.Ebs.Iops > 0 {
  430. params[fmt.Sprintf(key, index, "Iops")] = strconv.Itoa(bdm.Ebs.Iops)
  431. }
  432. if bdm.Ebs.SnapshotId != "" {
  433. params[fmt.Sprintf(key, index, "SnapshotId")] = bdm.Ebs.SnapshotId
  434. }
  435. if bdm.Ebs.VolumeSize > 0 {
  436. params[fmt.Sprintf(key, index, "VolumeSize")] = strconv.Itoa(bdm.Ebs.VolumeSize)
  437. }
  438. if bdm.Ebs.VolumeType != "" {
  439. params[fmt.Sprintf(key, index, "VolumeType")] = bdm.Ebs.VolumeType
  440. }
  441. }
  442. }
  443. if len(lc.SecurityGroups) > 0 {
  444. addParamsList(params, "SecurityGroups.member", lc.SecurityGroups)
  445. }
  446. resp = new(SimpleResp)
  447. if err := as.query(params, resp); err != nil {
  448. return nil, err
  449. }
  450. return resp, nil
  451. }
  452. // CreateOrUpdateTags creates or updates Auto Scaling Group Tags
  453. //
  454. // See http://goo.gl/e1UIXb for more details.
  455. func (as *AutoScaling) CreateOrUpdateTags(tags []Tag) (resp *SimpleResp, err error) {
  456. params := makeParams("CreateOrUpdateTags")
  457. for i, t := range tags {
  458. key := "Tags.member.%d.%s"
  459. index := i + 1
  460. params[fmt.Sprintf(key, index, "Key")] = t.Key
  461. params[fmt.Sprintf(key, index, "Value")] = t.Value
  462. params[fmt.Sprintf(key, index, "PropagateAtLaunch")] = strconv.FormatBool(t.PropagateAtLaunch)
  463. params[fmt.Sprintf(key, index, "ResourceId")] = t.ResourceId
  464. if t.ResourceType != "" {
  465. params[fmt.Sprintf(key, index, "ResourceType")] = t.ResourceType
  466. } else {
  467. params[fmt.Sprintf(key, index, "ResourceType")] = "auto-scaling-group"
  468. }
  469. }
  470. resp = new(SimpleResp)
  471. if err := as.query(params, resp); err != nil {
  472. return nil, err
  473. }
  474. return resp, nil
  475. }
  476. type CompleteLifecycleActionParams struct {
  477. AutoScalingGroupName string
  478. LifecycleActionResult string
  479. LifecycleActionToken string
  480. LifecycleHookName string
  481. }
  482. // CompleteLifecycleAction completes the lifecycle action for the associated token initiated under the given lifecycle hook with the specified result.
  483. //
  484. // Part of the basic sequence for adding a lifecycle hook to an Auto Scaling group:
  485. // 1) Create a notification target (SQS queue || SNS Topic)
  486. // 2) Create an IAM role to allow the ASG topublish lifecycle notifications to the designated SQS queue or SNS topic
  487. // 3) Create the lifecycle hook. You can create a hook that acts when instances launch or when instances terminate
  488. // 4) If necessary, record the lifecycle action heartbeat to keep the instance in a pending state
  489. // 5) ***Complete the lifecycle action***
  490. //
  491. // See http://goo.gl/k4fl0p for more details
  492. func (as *AutoScaling) CompleteLifecycleAction(options *CompleteLifecycleActionParams) (
  493. resp *SimpleResp, err error) {
  494. params := makeParams("CompleteLifecycleAction")
  495. params["AutoScalingGroupName"] = options.AutoScalingGroupName
  496. params["LifecycleActionResult"] = options.LifecycleActionResult
  497. params["LifecycleActionToken"] = options.LifecycleActionToken
  498. params["LifecycleHookName"] = options.LifecycleHookName
  499. resp = new(SimpleResp)
  500. if err := as.query(params, resp); err != nil {
  501. return nil, err
  502. }
  503. return resp, nil
  504. }
  505. // DeleteAutoScalingGroup deletes an Auto Scaling Group
  506. //
  507. // See http://goo.gl/us7VSffor for more details.
  508. func (as *AutoScaling) DeleteAutoScalingGroup(asgName string, forceDelete bool) (
  509. resp *SimpleResp, err error) {
  510. params := makeParams("DeleteAutoScalingGroup")
  511. params["AutoScalingGroupName"] = asgName
  512. if forceDelete {
  513. params["ForceDelete"] = "true"
  514. }
  515. resp = new(SimpleResp)
  516. if err := as.query(params, resp); err != nil {
  517. return nil, err
  518. }
  519. return resp, nil
  520. }
  521. // DeleteLaunchConfiguration deletes a Launch Configuration
  522. //
  523. // See http://goo.gl/xksfyR for more details.
  524. func (as *AutoScaling) DeleteLaunchConfiguration(name string) (resp *SimpleResp, err error) {
  525. params := makeParams("DeleteLaunchConfiguration")
  526. params["LaunchConfigurationName"] = name
  527. resp = new(SimpleResp)
  528. if err := as.query(params, resp); err != nil {
  529. return nil, err
  530. }
  531. return resp, nil
  532. }
  533. // DeleteLifecycleHook eletes the specified lifecycle hook.
  534. // If there are any outstanding lifecycle actions, they are completed first
  535. //
  536. // See http://goo.gl/MwX1vG for more details.
  537. func (as *AutoScaling) DeleteLifecycleHook(asgName, lifecycleHookName string) (resp *SimpleResp, err error) {
  538. params := makeParams("DeleteLifecycleHook")
  539. params["AutoScalingGroupName"] = asgName
  540. params["LifecycleHookName"] = lifecycleHookName
  541. resp = new(SimpleResp)
  542. if err := as.query(params, resp); err != nil {
  543. return nil, err
  544. }
  545. return resp, nil
  546. }
  547. // DeleteNotificationConfiguration deletes notifications created by PutNotificationConfiguration.
  548. //
  549. // See http://goo.gl/jTqoYz for more details
  550. func (as *AutoScaling) DeleteNotificationConfiguration(asgName string, topicARN string) (
  551. resp *SimpleResp, err error) {
  552. params := makeParams("DeleteNotificationConfiguration")
  553. params["AutoScalingGroupName"] = asgName
  554. params["TopicARN"] = topicARN
  555. resp = new(SimpleResp)
  556. if err := as.query(params, resp); err != nil {
  557. return nil, err
  558. }
  559. return resp, nil
  560. }
  561. // DeletePolicy deletes a policy created by PutScalingPolicy.
  562. //
  563. // policyName might be the policy name or ARN
  564. //
  565. // See http://goo.gl/aOQPH2 for more details
  566. func (as *AutoScaling) DeletePolicy(asgName string, policyName string) (resp *SimpleResp, err error) {
  567. params := makeParams("DeletePolicy")
  568. params["AutoScalingGroupName"] = asgName
  569. params["PolicyName"] = policyName
  570. resp = new(SimpleResp)
  571. if err := as.query(params, resp); err != nil {
  572. return nil, err
  573. }
  574. return resp, nil
  575. }
  576. // DeleteScheduledAction deletes a scheduled action previously created using the PutScheduledUpdateGroupAction.
  577. //
  578. // See http://goo.gl/Zss9CH for more details
  579. func (as *AutoScaling) DeleteScheduledAction(asgName string, scheduledActionName string) (resp *SimpleResp, err error) {
  580. params := makeParams("DeleteScheduledAction")
  581. params["AutoScalingGroupName"] = asgName
  582. params["ScheduledActionName"] = scheduledActionName
  583. resp = new(SimpleResp)
  584. if err := as.query(params, resp); err != nil {
  585. return nil, err
  586. }
  587. return resp, nil
  588. }
  589. // DeleteTags deletes autoscaling group tags
  590. //
  591. // See http://goo.gl/o8HzAk for more details.
  592. func (as *AutoScaling) DeleteTags(tags []Tag) (resp *SimpleResp, err error) {
  593. params := makeParams("DeleteTags")
  594. for i, t := range tags {
  595. key := "Tags.member.%d.%s"
  596. index := i + 1
  597. params[fmt.Sprintf(key, index, "Key")] = t.Key
  598. params[fmt.Sprintf(key, index, "Value")] = t.Value
  599. params[fmt.Sprintf(key, index, "PropagateAtLaunch")] = strconv.FormatBool(t.PropagateAtLaunch)
  600. params[fmt.Sprintf(key, index, "ResourceId")] = t.ResourceId
  601. params[fmt.Sprintf(key, index, "ResourceType")] = "auto-scaling-group"
  602. }
  603. resp = new(SimpleResp)
  604. if err := as.query(params, resp); err != nil {
  605. return nil, err
  606. }
  607. return resp, nil
  608. }
  609. //DescribeAccountLimits response wrapper
  610. //
  611. // See http://goo.gl/tKsMN0 for more details.
  612. type DescribeAccountLimitsResp struct {
  613. MaxNumberOfAutoScalingGroups int `xml:"DescribeAccountLimitsResult>MaxNumberOfAutoScalingGroups"`
  614. MaxNumberOfLaunchConfigurations int `xml:"DescribeAccountLimitsResult>MaxNumberOfLaunchConfigurations"`
  615. RequestId string `xml:"ResponseMetadata>RequestId"`
  616. }
  617. // DescribeAccountLimits - Returns the limits for the Auto Scaling resources currently allowed for your AWS account.
  618. //
  619. // See http://goo.gl/tKsMN0 for more details.
  620. func (as *AutoScaling) DescribeAccountLimits() (resp *DescribeAccountLimitsResp, err error) {
  621. params := makeParams("DescribeAccountLimits")
  622. resp = new(DescribeAccountLimitsResp)
  623. if err := as.query(params, resp); err != nil {
  624. return nil, err
  625. }
  626. return resp, nil
  627. }
  628. // AdjustmentType specifies whether the PutScalingPolicy ScalingAdjustment parameter is an absolute number or a percentage of the current capacity.
  629. //
  630. // See http://goo.gl/tCFqeL for more details
  631. type AdjustmentType struct {
  632. AdjustmentType string //Valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.
  633. }
  634. //DescribeAdjustmentTypes response wrapper
  635. //
  636. // See http://goo.gl/hGx3Pc for more details.
  637. type DescribeAdjustmentTypesResp struct {
  638. AdjustmentTypes []AdjustmentType `xml:"DescribeAdjustmentTypesResult>AdjustmentTypes>member"`
  639. RequestId string `xml:"ResponseMetadata>RequestId"`
  640. }
  641. // DescribeAdjustmentTypes returns policy adjustment types for use in the PutScalingPolicy action.
  642. //
  643. // See http://goo.gl/hGx3Pc for more details.
  644. func (as *AutoScaling) DescribeAdjustmentTypes() (resp *DescribeAdjustmentTypesResp, err error) {
  645. params := makeParams("DescribeAdjustmentTypes")
  646. resp = new(DescribeAdjustmentTypesResp)
  647. if err := as.query(params, resp); err != nil {
  648. return nil, err
  649. }
  650. return resp, nil
  651. }
  652. // DescribeAutoScalingGroups response wrapper
  653. //
  654. // See http://goo.gl/nW74Ut for more details.
  655. type DescribeAutoScalingGroupsResp struct {
  656. AutoScalingGroups []AutoScalingGroup `xml:"DescribeAutoScalingGroupsResult>AutoScalingGroups>member"`
  657. NextToken string `xml:"DescribeAutoScalingGroupsResult>NextToken"`
  658. RequestId string `xml:"ResponseMetadata>RequestId"`
  659. }
  660. // DescribeAutoScalingGroups returns a full description of each Auto Scaling group in the given list
  661. // If no autoscaling groups are provided, returns the details of all autoscaling groups
  662. // Supports pagination by using the returned "NextToken" parameter for subsequent calls
  663. //
  664. // See http://goo.gl/nW74Ut for more details.
  665. func (as *AutoScaling) DescribeAutoScalingGroups(names []string, maxRecords int, nextToken string) (
  666. resp *DescribeAutoScalingGroupsResp, err error) {
  667. params := makeParams("DescribeAutoScalingGroups")
  668. if maxRecords != 0 {
  669. params["MaxRecords"] = strconv.Itoa(maxRecords)
  670. }
  671. if nextToken != "" {
  672. params["NextToken"] = nextToken
  673. }
  674. if len(names) > 0 {
  675. addParamsList(params, "AutoScalingGroupNames.member", names)
  676. }
  677. resp = new(DescribeAutoScalingGroupsResp)
  678. if err := as.query(params, resp); err != nil {
  679. return nil, err
  680. }
  681. return resp, nil
  682. }
  683. // DescribeAutoScalingInstances response wrapper
  684. //
  685. // See http://goo.gl/ckzORt for more details.
  686. type DescribeAutoScalingInstancesResp struct {
  687. AutoScalingInstances []Instance `xml:"DescribeAutoScalingInstancesResult>AutoScalingInstances>member"`
  688. NextToken string `xml:"DescribeAutoScalingInstancesResult>NextToken"`
  689. RequestId string `xml:"ResponseMetadata>RequestId"`
  690. }
  691. // DescribeAutoScalingInstances returns a description of each Auto Scaling instance in the InstanceIds list.
  692. // If a list is not provided, the service returns the full details of all instances up to a maximum of 50
  693. // By default, the service returns a list of 20 items.
  694. // Supports pagination by using the returned "NextToken" parameter for subsequent calls
  695. //
  696. // See http://goo.gl/ckzORt for more details.
  697. func (as *AutoScaling) DescribeAutoScalingInstances(ids []string, maxRecords int, nextToken string) (
  698. resp *DescribeAutoScalingInstancesResp, err error) {
  699. params := makeParams("DescribeAutoScalingInstances")
  700. if maxRecords != 0 {
  701. params["MaxRecords"] = strconv.Itoa(maxRecords)
  702. }
  703. if nextToken != "" {
  704. params["NextToken"] = nextToken
  705. }
  706. if len(ids) > 0 {
  707. addParamsList(params, "InstanceIds.member", ids)
  708. }
  709. resp = new(DescribeAutoScalingInstancesResp)
  710. if err := as.query(params, resp); err != nil {
  711. return nil, err
  712. }
  713. return resp, nil
  714. }
  715. // DescribeAutoScalingNotificationTypes response wrapper
  716. //
  717. // See http://goo.gl/pmLIoE for more details.
  718. type DescribeAutoScalingNotificationTypesResp struct {
  719. AutoScalingNotificationTypes []string `xml:"DescribeAutoScalingNotificationTypesResult>AutoScalingNotificationTypes>member"`
  720. RequestId string `xml:"ResponseMetadata>RequestId"`
  721. }
  722. // DescribeAutoScalingNotificationTypes returns a list of all notification types that are supported by Auto Scaling
  723. //
  724. // See http://goo.gl/pmLIoE for more details.
  725. func (as *AutoScaling) DescribeAutoScalingNotificationTypes() (resp *DescribeAutoScalingNotificationTypesResp, err error) {
  726. params := makeParams("DescribeAutoScalingNotificationTypes")
  727. resp = new(DescribeAutoScalingNotificationTypesResp)
  728. if err := as.query(params, resp); err != nil {
  729. return nil, err
  730. }
  731. return resp, nil
  732. }
  733. // DescribeLaunchConfigurationResp defines the basic response structure for launch configuration
  734. // requests
  735. //
  736. // See http://goo.gl/y31YYE for more details.
  737. type DescribeLaunchConfigurationsResp struct {
  738. LaunchConfigurations []LaunchConfiguration `xml:"DescribeLaunchConfigurationsResult>LaunchConfigurations>member"`
  739. NextToken string `xml:"DescribeLaunchConfigurationsResult>NextToken"`
  740. RequestId string `xml:"ResponseMetadata>RequestId"`
  741. }
  742. // DescribeLaunchConfigurations returns details about the launch configurations supplied in
  743. // the list. If the list is nil, information is returned about all launch configurations in the
  744. // region.
  745. //
  746. // See http://goo.gl/y31YYE for more details.
  747. func (as *AutoScaling) DescribeLaunchConfigurations(names []string, maxRecords int, nextToken string) (
  748. resp *DescribeLaunchConfigurationsResp, err error) {
  749. params := makeParams("DescribeLaunchConfigurations")
  750. if maxRecords != 0 {
  751. params["MaxRecords"] = strconv.Itoa(maxRecords)
  752. }
  753. if nextToken != "" {
  754. params["NextToken"] = nextToken
  755. }
  756. if len(names) > 0 {
  757. addParamsList(params, "LaunchConfigurationNames.member", names)
  758. }
  759. resp = new(DescribeLaunchConfigurationsResp)
  760. if err := as.query(params, resp); err != nil {
  761. return nil, err
  762. }
  763. return resp, nil
  764. }
  765. // DescribeLifecycleHookTypesResult wraps a DescribeLifecycleHookTypes response
  766. //
  767. // See http://goo.gl/qiAH31 for more details.
  768. type DescribeLifecycleHookTypesResult struct {
  769. LifecycleHookTypes []string `xml:"DescribeLifecycleHookTypesResult>LifecycleHookTypes>member"`
  770. RequestId string `xml:"ResponseMetadata>RequestId"`
  771. }
  772. // DescribeLifecycleHookTypes describes the available types of lifecycle hooks
  773. //
  774. // See http://goo.gl/E9IBtY for more information
  775. func (as *AutoScaling) DescribeLifecycleHookTypes() (
  776. resp *DescribeLifecycleHookTypesResult, err error) {
  777. params := makeParams("DescribeLifecycleHookTypes")
  778. resp = new(DescribeLifecycleHookTypesResult)
  779. if err := as.query(params, resp); err != nil {
  780. return nil, err
  781. }
  782. return resp, nil
  783. }
  784. // LifecycleHook represents a lifecyclehook object
  785. //
  786. // See http://goo.gl/j62Iqu for more information
  787. type LifecycleHook struct {
  788. AutoScalingGroupName string `xml:"AutoScalingGroupName"`
  789. DefaultResult string `xml:"DefaultResult"`
  790. GlobalTimeout int `xml:"GlobalTimeout"`
  791. HeartbeatTimeout int `xml:"HeartbeatTimeout"`
  792. LifecycleHookName string `xml:"LifecycleHookName"`
  793. LifecycleTransition string `xml:"LifecycleTransition"`
  794. NotificationMetadata string `xml:"NotificationMetadata"`
  795. NotificationTargetARN string `xml:"NotificationTargetARN"`
  796. RoleARN string `xml:"RoleARN"`
  797. }
  798. // DescribeLifecycleHooks wraps a DescribeLifecycleHooks response
  799. //
  800. // See http://goo.gl/wQkWiz for more details.
  801. type DescribeLifecycleHooksResult struct {
  802. LifecycleHooks []string `xml:"DescribeLifecycleHooksResult>LifecycleHooks>member"`
  803. RequestId string `xml:"ResponseMetadata>RequestId"`
  804. }
  805. // DescribeLifecycleHooks describes the lifecycle hooks that currently belong to the specified Auto Scaling group
  806. //
  807. // See http://goo.gl/wQkWiz for more information
  808. func (as *AutoScaling) DescribeLifecycleHooks(asgName string, hookNames []string) (
  809. resp *DescribeLifecycleHooksResult, err error) {
  810. params := makeParams("DescribeLifecycleHooks")
  811. params["AutoScalingGroupName"] = asgName
  812. if len(hookNames) > 0 {
  813. addParamsList(params, "LifecycleHookNames.member", hookNames)
  814. }
  815. resp = new(DescribeLifecycleHooksResult)
  816. if err := as.query(params, resp); err != nil {
  817. return nil, err
  818. }
  819. return resp, nil
  820. }
  821. // MetricGranularity encapsulates the MetricGranularityType
  822. //
  823. // See http://goo.gl/WJ82AA for more details
  824. type MetricGranularity struct {
  825. Granularity string `xml:"Granularity"`
  826. }
  827. //MetricCollection encapsulates the MetricCollectionType
  828. //
  829. // See http://goo.gl/YrEG6h for more details
  830. type MetricCollection struct {
  831. Metric string `xml:"Metric"`
  832. }
  833. // DescribeMetricCollectionTypesResp response wrapper
  834. //
  835. // See http://goo.gl/UyYc3i for more details.
  836. type DescribeMetricCollectionTypesResp struct {
  837. Granularities []MetricGranularity `xml:"DescribeMetricCollectionTypesResult>Granularities>member"`
  838. Metrics []MetricCollection `xml:"DescribeMetricCollectionTypesResult>Metrics>member"`
  839. RequestId string `xml:"ResponseMetadata>RequestId"`
  840. }
  841. // DescribeMetricCollectionTypes returns a list of metrics and a corresponding list of granularities for each metric
  842. //
  843. // See http://goo.gl/UyYc3i for more details.
  844. func (as *AutoScaling) DescribeMetricCollectionTypes() (resp *DescribeMetricCollectionTypesResp, err error) {
  845. params := makeParams("DescribeMetricCollectionTypes")
  846. resp = new(DescribeMetricCollectionTypesResp)
  847. if err := as.query(params, resp); err != nil {
  848. return nil, err
  849. }
  850. return resp, nil
  851. }
  852. // NotificationConfiguration encapsulates the NotificationConfigurationType
  853. //
  854. // See http://goo.gl/M8xYOQ for more details
  855. type NotificationConfiguration struct {
  856. AutoScalingGroupName string `xml:"AutoScalingGroupName"`
  857. NotificationType string `xml:"NotificationType"`
  858. TopicARN string `xml:"TopicARN"`
  859. }
  860. // DescribeNotificationConfigurations response wrapper
  861. //
  862. // See http://goo.gl/qiAH31 for more details.
  863. type DescribeNotificationConfigurationsResp struct {
  864. NotificationConfigurations []NotificationConfiguration `xml:"DescribeNotificationConfigurationsResult>NotificationConfigurations>member"`
  865. NextToken string `xml:"DescribeNotificationConfigurationsResult>NextToken"`
  866. RequestId string `xml:"ResponseMetadata>RequestId"`
  867. }
  868. // DescribeNotificationConfigurations returns a list of notification actions associated with Auto Scaling groups for specified events.
  869. // Supports pagination by using the returned "NextToken" parameter for subsequent calls
  870. //
  871. // http://goo.gl/qiAH31 for more details.
  872. func (as *AutoScaling) DescribeNotificationConfigurations(asgNames []string, maxRecords int, nextToken string) (
  873. resp *DescribeNotificationConfigurationsResp, err error) {
  874. params := makeParams("DescribeNotificationConfigurations")
  875. if maxRecords != 0 {
  876. params["MaxRecords"] = strconv.Itoa(maxRecords)
  877. }
  878. if nextToken != "" {
  879. params["NextToken"] = nextToken
  880. }
  881. if len(asgNames) > 0 {
  882. addParamsList(params, "AutoScalingGroupNames.member", asgNames)
  883. }
  884. resp = new(DescribeNotificationConfigurationsResp)
  885. if err := as.query(params, resp); err != nil {
  886. return nil, err
  887. }
  888. return resp, nil
  889. }
  890. // Alarm encapsulates the Alarm data type.
  891. //
  892. // See http://goo.gl/Q0uPAB for more details
  893. type Alarm struct {
  894. AlarmARN string `xml:"AlarmARN"`
  895. AlarmName string `xml:"AlarmName"`
  896. }
  897. // ScalingPolicy encapsulates the ScalingPolicyType
  898. //
  899. // See http://goo.gl/BYAT18 for more details
  900. type ScalingPolicy struct {
  901. AdjustmentType string `xml:"AdjustmentType"` // ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity
  902. Alarms []Alarm `xml:"Alarms>member"` // A list of CloudWatch Alarms related to the policy
  903. AutoScalingGroupName string `xml:"AutoScalingGroupName"`
  904. Cooldown int `xml:"Cooldown"`
  905. MinAdjustmentStep int `xml:"MinAdjustmentStep"` // Changes the DesiredCapacity of ASG by at least the specified number of instances.
  906. PolicyARN string `xml:"PolicyARN"`
  907. PolicyName string `xml:"PolicyName"`
  908. ScalingAdjustment int `xml:"ScalingAdjustment"`
  909. }
  910. // DescribePolicies response wrapper
  911. //
  912. // http://goo.gl/bN7A9T for more details.
  913. type DescribePoliciesResp struct {
  914. ScalingPolicies []ScalingPolicy `xml:"DescribePoliciesResult>ScalingPolicies>member"`
  915. NextToken string `xml:"DescribePoliciesResult>NextToken"`
  916. RequestId string `xml:"ResponseMetadata>RequestId"`
  917. }
  918. // DescribePolicies returns descriptions of what each policy does.
  919. // Supports pagination by using the returned "NextToken" parameter for subsequent calls
  920. //
  921. // http://goo.gl/bN7A9Tfor more details.
  922. func (as *AutoScaling) DescribePolicies(asgName string, policyNames []string, maxRecords int, nextToken string) (
  923. resp *DescribePoliciesResp, err error) {
  924. params := makeParams("DescribePolicies")
  925. if asgName != "" {
  926. params["AutoScalingGroupName"] = asgName
  927. }
  928. if maxRecords != 0 {
  929. params["MaxRecords"] = strconv.Itoa(maxRecords)
  930. }
  931. if nextToken != "" {
  932. params["NextToken"] = nextToken
  933. }
  934. if len(policyNames) > 0 {
  935. addParamsList(params, "PolicyNames.member", policyNames)
  936. }
  937. resp = new(DescribePoliciesResp)
  938. if err := as.query(params, resp); err != nil {
  939. return nil, err
  940. }
  941. return resp, nil
  942. }
  943. // Activity encapsulates the Activity data type
  944. //
  945. // See http://goo.gl/fRaVi1 for more details
  946. type Activity struct {
  947. ActivityId string `xml:"ActivityId"`
  948. AutoScalingGroupName string `xml:"AutoScalingGroupName"`
  949. Cause string `xml:"Cause"`
  950. Description string `xml:"Description"`
  951. Details string `xml:"Details"`
  952. EndTime time.Time `xml:"EndTime"`
  953. Progress int `xml:"Progress"`
  954. StartTime time.Time `xml:"StartTime"`
  955. StatusCode string `xml:"StatusCode"`
  956. StatusMessage string `xml:"StatusMessage"`
  957. }
  958. // DescribeScalingActivities response wrapper
  959. //
  960. // http://goo.gl/noOXIC for more details.
  961. type DescribeScalingActivitiesResp struct {
  962. Activities []Activity `xml:"DescribeScalingActivitiesResult>Activities>member"`
  963. NextToken string `xml:"DescribeScalingActivitiesResult>NextToken"`
  964. RequestId string `xml:"ResponseMetadata>RequestId"`
  965. }
  966. // DescribeScalingActivities returns the scaling activities for the specified Auto Scaling group.
  967. // Supports pagination by using the returned "NextToken" parameter for subsequent calls
  968. //
  969. // http://goo.gl/noOXIC more details.
  970. func (as *AutoScaling) DescribeScalingActivities(asgName string, activityIds []string, maxRecords int, nextToken string) (
  971. resp *DescribeScalingActivitiesResp, err error) {
  972. params := makeParams("DescribeScalingActivities")
  973. if asgName != "" {
  974. params["AutoScalingGroupName"] = asgName
  975. }
  976. if maxRecords != 0 {
  977. params["MaxRecords"] = strconv.Itoa(maxRecords)
  978. }
  979. if nextToken != "" {
  980. params["NextToken"] = nextToken
  981. }
  982. if len(activityIds) > 0 {
  983. addParamsList(params, "ActivityIds.member", activityIds)
  984. }
  985. resp = new(DescribeScalingActivitiesResp)
  986. if err := as.query(params, resp); err != nil {
  987. return nil, err
  988. }
  989. return resp, nil
  990. }
  991. // ProcessType encapsulates the Auto Scaling process data type
  992. //
  993. // See http://goo.gl/9BvNik for more details.
  994. type ProcessType struct {
  995. ProcessName string `xml:"ProcessName"`
  996. }
  997. // DescribeScalingProcessTypes response wrapper
  998. //
  999. // See http://goo.gl/rkp2tw for more details.
  1000. type DescribeScalingProcessTypesResp struct {
  1001. Processes []ProcessType `xml:"DescribeScalingProcessTypesResult>Processes>member"`
  1002. RequestId string `xml:"ResponseMetadata>RequestId"`
  1003. }
  1004. // DescribeScalingProcessTypes returns scaling process types for use in the ResumeProcesses and SuspendProcesses actions.
  1005. //
  1006. // See http://goo.gl/rkp2tw for more details.
  1007. func (as *AutoScaling) DescribeScalingProcessTypes() (resp *DescribeScalingProcessTypesResp, err error) {
  1008. params := makeParams("DescribeScalingProcessTypes")
  1009. resp = new(DescribeScalingProcessTypesResp)
  1010. if err := as.query(params, resp); err != nil {
  1011. return nil, err
  1012. }
  1013. return resp, nil
  1014. }
  1015. // ScheduledUpdateGroupAction contains the information to be used in a scheduled update to an
  1016. // AutoScalingGroup
  1017. //
  1018. // See http://goo.gl/z2Kfxe for more details
  1019. type ScheduledUpdateGroupAction struct {
  1020. AutoScalingGroupName string `xml:"AutoScalingGroupName"`
  1021. DesiredCapacity int `xml:"DesiredCapacity"`
  1022. EndTime time.Time `xml:"EndTime"`
  1023. MaxSize int `xml:"MaxSize"`
  1024. MinSize int `xml:"MinSize"`
  1025. Recurrence string `xml:"Recurrence"`
  1026. ScheduledActionARN string `xml:"ScheduledActionARN"`
  1027. ScheduledActionName string `xml:"ScheduledActionName"`
  1028. StartTime time.Time `xml:"StartTime"`
  1029. Time time.Time `xml:"Time"`
  1030. }
  1031. // DescribeScheduledActionsResult contains the response from a DescribeScheduledActions.
  1032. //
  1033. // See http://goo.gl/zqrJLx for more details.
  1034. type DescribeScheduledActionsResult struct {
  1035. ScheduledUpdateGroupActions []ScheduledUpdateGroupAction `xml:"DescribeScheduledActionsResult>ScheduledUpdateGroupActions>member"`
  1036. NextToken string `xml:"DescribeScheduledActionsResult>NextToken"`
  1037. RequestId string `xml:"ResponseMetadata>RequestId"`
  1038. }
  1039. // ScheduledActionsRequestParams contains the items that can be specified when making
  1040. // a ScheduledActions request
  1041. type DescribeScheduledActionsParams struct {
  1042. AutoScalingGroupName string
  1043. EndTime time.Time
  1044. MaxRecords int
  1045. ScheduledActionNames []string
  1046. StartTime time.Time
  1047. NextToken string
  1048. }
  1049. // DescribeScheduledActions returns a list of the current scheduled actions. If the
  1050. // AutoScalingGroup name is provided it will list all the scheduled actions for that group.
  1051. //
  1052. // See http://goo.gl/zqrJLx for more details.
  1053. func (as *AutoScaling) DescribeScheduledActions(options *DescribeScheduledActionsParams) (
  1054. resp *DescribeScheduledActionsResult, err error) {
  1055. params := makeParams("DescribeScheduledActions")
  1056. if options.AutoScalingGroupName != "" {
  1057. params["AutoScalingGroupName"] = options.AutoScalingGroupName
  1058. }
  1059. if !options.StartTime.IsZero() {
  1060. params["StartTime"] = options.StartTime.Format(time.RFC3339)
  1061. }
  1062. if !options.EndTime.IsZero() {
  1063. params["EndTime"] = options.EndTime.Format(time.RFC3339)
  1064. }
  1065. if options.MaxRecords > 0 {
  1066. params["MaxRecords"] = strconv.Itoa(options.MaxRecords)
  1067. }
  1068. if options.NextToken != "" {
  1069. params["NextToken"] = options.NextToken
  1070. }
  1071. if len(options.ScheduledActionNames) > 0 {
  1072. addParamsList(params, "ScheduledActionNames.member", options.ScheduledActionNames)
  1073. }
  1074. resp = new(DescribeScheduledActionsResult)
  1075. if err := as.query(params, resp); err != nil {
  1076. return nil, err
  1077. }
  1078. return resp, nil
  1079. }
  1080. // DescribeTags response wrapper
  1081. //
  1082. // See http://goo.gl/ZTEU3G for more details.
  1083. type DescribeTagsResp struct {
  1084. Tags []Tag `xml:"DescribeTagsResult>Tags>member"`
  1085. NextToken string `xml:"DescribeTagsResult>NextToken"`
  1086. RequestId string `xml:"ResponseMetadata>RequestId"`
  1087. }
  1088. // DescribeTags lists the Auto Scaling group tags.
  1089. // Supports pagination by using the returned "NextToken" parameter for subsequent calls
  1090. //
  1091. // See http://goo.gl/ZTEU3G for more details.
  1092. func (as *AutoScaling) DescribeTags(filter *Filter, maxRecords int, nextToken string) (
  1093. resp *DescribeTagsResp, err error) {
  1094. params := makeParams("DescribeTags")
  1095. if maxRecords != 0 {
  1096. params["MaxRecords"] = strconv.Itoa(maxRecords)
  1097. }
  1098. if nextToken != "" {
  1099. params["NextToken"] = nextToken
  1100. }
  1101. filter.addParams(params)
  1102. resp = new(DescribeTagsResp)
  1103. if err := as.query(params, resp); err != nil {
  1104. return nil, err
  1105. }
  1106. return resp, nil
  1107. }
  1108. // DescribeTerminationPolicyTypes response wrapper
  1109. //
  1110. // See http://goo.gl/ZTEU3G for more details.
  1111. type DescribeTerminationPolicyTypesResp struct {
  1112. TerminationPolicyTypes []string `xml:"DescribeTerminationPolicyTypesResult>TerminationPolicyTypes>member"`
  1113. RequestId string `xml:"ResponseMetadata>RequestId"`
  1114. }
  1115. // DescribeTerminationPolicyTypes returns a list of all termination policies supported by Auto Scaling
  1116. //
  1117. // See http://goo.gl/ZTEU3G for more details.
  1118. func (as *AutoScaling) DescribeTerminationPolicyTypes() (resp *DescribeTerminationPolicyTypesResp, err error) {
  1119. params := makeParams("DescribeTerminationPolicyTypes")
  1120. resp = new(DescribeTerminationPolicyTypesResp)
  1121. if err := as.query(params, resp); err != nil {
  1122. return nil, err
  1123. }
  1124. return resp, nil
  1125. }
  1126. // DetachInstancesResult wraps a DetachInstances response
  1127. type DetachInstancesResult struct {
  1128. Activities []Activity `xml:"DetachInstancesResult>Activities>member"`
  1129. RequestId string `xml:"ResponseMetadata>RequestId"`
  1130. }
  1131. // DetachInstances removes an instance from an Auto Scaling group
  1132. //
  1133. // See http://goo.gl/cNwrqF for more details
  1134. func (as *AutoScaling) DetachInstances(asgName string, instanceIds []string, decrementCapacity bool) (
  1135. resp *DetachInstancesResult, err error) {
  1136. params := makeParams("DetachInstances")
  1137. params["AutoScalingGroupName"] = asgName
  1138. params["ShouldDecrementDesiredCapacity"] = strconv.FormatBool(decrementCapacity)
  1139. if len(instanceIds) > 0 {
  1140. addParamsList(params, "InstanceIds.member", instanceIds)
  1141. }
  1142. resp = new(DetachInstancesResult)
  1143. if err := as.query(params, resp); err != nil {
  1144. return nil, err
  1145. }
  1146. return resp, nil
  1147. }
  1148. // DisableMetricsCollection disables monitoring of group metrics for the Auto Scaling group specified in asgName.
  1149. // You can specify the list of affected metrics with the metrics parameter. If no metrics are specified, all metrics are disabled
  1150. //
  1151. // See http://goo.gl/kAvzQw for more details.
  1152. func (as *AutoScaling) DisableMetricsCollection(asgName string, metrics []string) (
  1153. resp *SimpleResp, err error) {
  1154. params := makeParams("DisableMetricsCollection")
  1155. params["AutoScalingGroupName"] = asgName
  1156. if len(metrics) > 0 {
  1157. addParamsList(params, "Metrics.member", metrics)
  1158. }
  1159. resp = new(SimpleResp)
  1160. if err := as.query(params, resp); err != nil {
  1161. return nil, err
  1162. }
  1163. return resp, nil
  1164. }
  1165. // EnableMetricsCollection enables monitoring of group metrics for the Auto Scaling group specified in asNmae.
  1166. // You can specify the list of affected metrics with the metrics parameter.
  1167. // Auto Scaling metrics collection can be turned on only if the InstanceMonitoring flag is set to true.
  1168. // Currently, the only legal granularity is "1Minute".
  1169. //
  1170. // See http://goo.gl/UcVDWn for more details.
  1171. func (as *AutoScaling) EnableMetricsCollection(asgName string, metrics []string, granularity string) (
  1172. resp *SimpleResp, err error) {
  1173. params := makeParams("EnableMetricsCollection")
  1174. params["AutoScalingGroupName"] = asgName
  1175. params["Granularity"] = granularity
  1176. if len(metrics) > 0 {
  1177. addParamsList(params, "Metrics.member", metrics)
  1178. }
  1179. resp = new(SimpleResp)
  1180. if err := as.query(params, resp); err != nil {
  1181. return nil, err
  1182. }
  1183. return resp, nil
  1184. }
  1185. // EnterStandbyResult wraps an EnterStandby response
  1186. type EnterStandbyResult struct {
  1187. Activities []Activity `xml:"EnterStandbyResult>Activities>member"`
  1188. RequestId string `xml:"ResponseMetadata>RequestId"`
  1189. }
  1190. // EnterStandby moves instances in an Auto Scaling group into a Standby mode.
  1191. //
  1192. // See http://goo.gl/BJ3lXs for more information
  1193. func (as *AutoScaling) EnterStandby(asgName string, instanceIds []string, decrementCapacity bool) (
  1194. resp *EnterStandbyResult, err error) {
  1195. params := makeParams("EnterStandby")
  1196. params["AutoScalingGroupName"] = asgName
  1197. params["ShouldDecrementDesiredCapacity"] = strconv.FormatBool(decrementCapacity)
  1198. if len(instanceIds) > 0 {
  1199. addParamsList(params, "InstanceIds.member", instanceIds)
  1200. }
  1201. resp = new(EnterStandbyResult)
  1202. if err := as.query(params, resp); err != nil {
  1203. return nil, err
  1204. }
  1205. return resp, nil
  1206. }
  1207. // ExecutePolicy executes the specified policy.
  1208. //
  1209. // See http://goo.gl/BxHpFc for more details.
  1210. func (as *AutoScaling) ExecutePolicy(policyName string, asgName string, honorCooldown bool) (
  1211. resp *SimpleResp, err error) {
  1212. params := makeParams("ExecutePolicy")
  1213. params["PolicyName"] = policyName
  1214. if asgName != "" {
  1215. params["AutoScalingGroupName"] = asgName
  1216. }
  1217. if honorCooldown {
  1218. params["HonorCooldown"] = strconv.FormatBool(honorCooldown)
  1219. }
  1220. resp = new(SimpleResp)
  1221. if err := as.query(params, resp); err != nil {
  1222. return nil, err
  1223. }
  1224. return resp, nil
  1225. }
  1226. // ExitStandbyResult wraps an ExitStandby response
  1227. type ExitStandbyResult struct {
  1228. Activities []Activity `xml:"ExitStandbyResult>Activities>member"`
  1229. RequestId string `xml:"ResponseMetadata>RequestId"`
  1230. }
  1231. // ExitStandby moves an instance out of Standby mode.
  1232. //
  1233. // See http://goo.gl/9zQV4G for more information
  1234. func (as *AutoScaling) ExitStandby(asgName string, instanceIds []string) (
  1235. resp *ExitStandbyResult, err error) {
  1236. params := makeParams("ExitStandby")
  1237. params["AutoScalingGroupName"] = asgName
  1238. if len(instanceIds) > 0 {
  1239. addParamsList(params, "InstanceIds.member", instanceIds)
  1240. }
  1241. resp = new(ExitStandbyResult)
  1242. if err := as.query(params, resp); err != nil {
  1243. return nil, err
  1244. }
  1245. return resp, nil
  1246. }
  1247. // PutLifecycleHookParams wraps a PutLifecycleHook request
  1248. //
  1249. // See http://goo.gl/zsNqp5 for more details
  1250. type PutLifecycleHookParams struct {
  1251. AutoScalingGroupName string
  1252. DefaultResult string
  1253. HeartbeatTimeout int
  1254. LifecycleHookName string
  1255. LifecycleTransition string
  1256. NotificationMetadata string
  1257. NotificationTargetARN string
  1258. RoleARN string
  1259. }
  1260. // PutLifecycleHook Creates or updates a lifecycle hook for an Auto Scaling Group.
  1261. //
  1262. // Part of the basic sequence for adding a lifecycle hook to an Auto Scaling group:
  1263. // 1) Create a notification target (SQS queue || SNS Topic)
  1264. // 2) Create an IAM role to allow the ASG topublish lifecycle notifications to the designated SQS queue or SNS topic
  1265. // 3) *** Create the lifecycle hook. You can create a hook that acts when instances launch or when instances terminate***
  1266. // 4) If necessary, record the lifecycle action heartbeat to keep the instance in a pending state
  1267. // 5) Complete the lifecycle action
  1268. //
  1269. // See http://goo.gl/9XrROq for more details.
  1270. func (as *AutoScaling) PutLifecycleHook(options *PutLifecycleHookParams) (
  1271. resp *SimpleResp, err error) {
  1272. params := makeParams("PutLifecycleHook")
  1273. params["AutoScalingGroupName"] = options.AutoScalingGroupName
  1274. params["LifecycleHookName"] = options.LifecycleHookName
  1275. if options.DefaultResult != "" {
  1276. params["DefaultResult"] = options.DefaultResult
  1277. }
  1278. if options.HeartbeatTimeout != 0 {
  1279. params["HeartbeatTimeout"] = strconv.Itoa(options.HeartbeatTimeout)
  1280. }
  1281. if options.LifecycleTransition != "" {
  1282. params["LifecycleTransition"] = options.LifecycleTransition
  1283. }
  1284. if options.NotificationMetadata != "" {
  1285. params["NotificationMetadata"] = options.NotificationMetadata
  1286. }
  1287. if options.NotificationTargetARN != "" {
  1288. params["NotificationTargetARN"] = options.NotificationTargetARN
  1289. }
  1290. if options.RoleARN != "" {
  1291. params["RoleARN"] = options.RoleARN
  1292. }
  1293. resp = new(SimpleResp)
  1294. if err := as.query(params, resp); err != nil {
  1295. return nil, err
  1296. }
  1297. return resp, nil
  1298. }
  1299. // PutNotificationConfiguration configures an Auto Scaling group to send notifications when specified events take place.
  1300. //
  1301. // See http://goo.gl/9XrROq for more details.
  1302. func (as *AutoScaling) PutNotificationConfiguration(asgName string, notificationTypes []string, topicARN string) (
  1303. resp *SimpleResp, err error) {
  1304. params := makeParams("PutNotificationConfiguration")
  1305. params["AutoScalingGroupName"] = asgName
  1306. params["TopicARN"] = topicARN
  1307. if len(notificationTypes) > 0 {
  1308. addParamsList(params, "NotificationTypes.member", notificationTypes)
  1309. }
  1310. resp = new(SimpleResp)
  1311. if err := as.query(params, resp); err != nil {
  1312. return nil, err
  1313. }
  1314. return resp, nil
  1315. }
  1316. // PutScalingPolicyParams wraps a PutScalingPolicyParams request
  1317. //
  1318. // See http://goo.gl/o0E8hl for more details.
  1319. type PutScalingPolicyParams struct {
  1320. AutoScalingGroupName string
  1321. PolicyName string
  1322. ScalingAdjustment int
  1323. AdjustmentType string
  1324. Cooldown int
  1325. MinAdjustmentStep int
  1326. }
  1327. // PutScalingPolicy response wrapper
  1328. //
  1329. // See http://goo.gl/o0E8hl for more details.
  1330. type PutScalingPolicyResp struct {
  1331. PolicyARN string `xml:"PutScalingPolicyResult>PolicyARN"`
  1332. RequestId string `xml:"ResponseMetadata>RequestId"`
  1333. }
  1334. // PutScalingPolicy creates or updates a policy for an Auto Scaling group
  1335. //
  1336. // See http://goo.gl/o0E8hl for more details.
  1337. func (as *AutoScaling) PutScalingPolicy(options *PutScalingPolicyParams) (
  1338. resp *PutScalingPolicyResp, err error) {
  1339. params := makeParams("PutScalingPolicy")
  1340. params["AutoScalingGroupName"] = options.AutoScalingGroupName
  1341. params["PolicyName"] = options.PolicyName
  1342. params["ScalingAdjustment"] = strconv.Itoa(options.ScalingAdjustment)
  1343. params["AdjustmentType"] = options.AdjustmentType
  1344. if options.Cooldown != 0 {
  1345. params["Cooldown"] = strconv.Itoa(options.Cooldown)
  1346. }
  1347. if options.MinAdjustmentStep != 0 {
  1348. params["MinAdjustmentStep"] = strconv.Itoa(options.MinAdjustmentStep)
  1349. }
  1350. resp = new(PutScalingPolicyResp)
  1351. if err := as.query(params, resp); err != nil {
  1352. return nil, err
  1353. }
  1354. return resp, nil
  1355. }
  1356. // PutScheduledUpdateGroupActionParams contains the details of the ScheduledAction to be added.
  1357. //
  1358. // See http://goo.gl/sLPi0d for more details
  1359. type PutScheduledUpdateGroupActionParams struct {
  1360. AutoScalingGroupName string
  1361. DesiredCapacity int
  1362. EndTime time.Time
  1363. MaxSize int
  1364. MinSize int
  1365. Recurrence string
  1366. ScheduledActionName string
  1367. StartTime time.Time
  1368. }
  1369. // PutScheduledUpdateGroupAction creates or updates a scheduled scaling action for an
  1370. // AutoScaling group. Scheduled actions can be made up to thirty days in advance. When updating
  1371. // a scheduled scaling action, if you leave a parameter unspecified, the corresponding value
  1372. // remains unchanged in the affected AutoScaling group.
  1373. //
  1374. // Auto Scaling supports the date and time expressed in "YYYY-MM-DDThh:mm:ssZ" format in UTC/GMT
  1375. // only.
  1376. //
  1377. // See http://goo.gl/sLPi0d for more details.
  1378. func (as *AutoScaling) PutScheduledUpdateGroupAction(options *PutScheduledUpdateGroupActionParams) (
  1379. resp *SimpleResp, err error) {
  1380. params := makeParams("PutScheduledUpdateGroupAction")
  1381. params["AutoScalingGroupName"] = options.AutoScalingGroupName
  1382. params["ScheduledActionName"] = options.ScheduledActionName
  1383. params["MinSize"] = strconv.Itoa(options.MinSize)
  1384. params["MaxSize"] = strconv.Itoa(options.MaxSize)
  1385. params["DesiredCapacity"] = strconv.Itoa(options.DesiredCapacity)
  1386. if !options.StartTime.IsZero() {
  1387. params["StartTime"] = options.StartTime.Format(time.RFC3339)
  1388. }
  1389. if !options.EndTime.IsZero() {
  1390. params["EndTime"] = options.EndTime.Format(time.RFC3339)
  1391. }
  1392. if options.Recurrence != "" {
  1393. params["Recurrence"] = options.Recurrence
  1394. }
  1395. resp = new(SimpleResp)
  1396. if err := as.query(params, resp); err != nil {
  1397. return nil, err
  1398. }
  1399. return resp, nil
  1400. }
  1401. // RecordLifecycleActionHeartbeat ecords a heartbeat for the lifecycle action associated with a specific token.
  1402. // This extends the timeout by the length of time defined by the HeartbeatTimeout parameter of the
  1403. // PutLifecycleHook operation.
  1404. //
  1405. // Part of the basic sequence for adding a lifecycle hook to an Auto Scaling group:
  1406. // 1) Create a notification target (SQS queue || SNS Topic)
  1407. // 2) Create an IAM role to allow the ASG topublish lifecycle notifications to the designated SQS queue or SNS topic
  1408. // 3) Create the lifecycle hook. You can create a hook that acts when instances launch or when instances terminate
  1409. // 4) ***If necessary, record the lifecycle action heartbeat to keep the instance in a pending state***
  1410. // 5) Complete the lifecycle action
  1411. //
  1412. // See http://goo.gl/jc70xp for more details.
  1413. func (as *AutoScaling) RecordLifecycleActionHeartbeat(asgName, lifecycleActionToken, hookName string) (
  1414. resp *SimpleResp, err error) {
  1415. params := makeParams("RecordLifecycleActionHeartbeat")
  1416. params["AutoScalingGroupName"] = asgName
  1417. params["LifecycleActionToken"] = lifecycleActionToken
  1418. params["LifecycleHookName"] = hookName
  1419. resp = new(SimpleResp)
  1420. if err := as.query(params, resp); err != nil {
  1421. return nil, err
  1422. }
  1423. return resp, nil
  1424. }
  1425. // ResumeProcesses resumes the scaling processes for the scaling group. If no processes are
  1426. // provided, all processes are resumed.
  1427. //
  1428. // See http://goo.gl/XWIIg1 for more details.
  1429. func (as *AutoScaling) ResumeProcesses(asgName string, processes []string) (
  1430. resp *SimpleResp, err error) {
  1431. params := makeParams("ResumeProcesses")
  1432. params["AutoScalingGroupName"] = asgName
  1433. if len(processes) > 0 {
  1434. addParamsList(params, "ScalingProcesses.member", processes)
  1435. }
  1436. resp = new(SimpleResp)
  1437. if err := as.query(params, resp); err != nil {
  1438. return nil, err
  1439. }
  1440. return resp, nil
  1441. }
  1442. // SetDesiredCapacity changes the DesiredCapacity of an AutoScaling group.
  1443. //
  1444. // See http://goo.gl/3WGZbI for more details.
  1445. func (as *AutoScaling) SetDesiredCapacity(asgName string, desiredCapacity int, honorCooldown bool) (
  1446. resp *SimpleResp, err error) {
  1447. params := makeParams("SetDesiredCapacity")
  1448. params["AutoScalingGroupName"] = asgName
  1449. params["DesiredCapacity"] = strconv.Itoa(desiredCapacity)
  1450. params["HonorCooldown"] = strconv.FormatBool(honorCooldown)
  1451. resp = new(SimpleResp)
  1452. if err := as.query(params, resp); err != nil {
  1453. return nil, err
  1454. }
  1455. return resp, nil
  1456. }
  1457. // SetInstanceHealth sets the health status of a specified instance that belongs to any of your Auto Scaling groups.
  1458. //
  1459. // See http://goo.gl/j4ZRxh for more details.
  1460. func (as *AutoScaling) SetInstanceHealth(id string, healthStatus string, respectGracePeriod bool) (
  1461. resp *SimpleResp, err error) {
  1462. params := makeParams("SetInstanceHealth")
  1463. params["HealthStatus"] = healthStatus
  1464. params["InstanceId"] = id
  1465. // Default is true
  1466. params["ShouldRespectGracePeriod"] = strconv.FormatBool(respectGracePeriod)
  1467. resp = new(SimpleResp)
  1468. if err := as.query(params, resp); err != nil {
  1469. return nil, err
  1470. }
  1471. return resp, nil
  1472. }
  1473. // SuspendProcesses suspends the processes for the autoscaling group. If no processes are
  1474. // provided, all processes are suspended.
  1475. //
  1476. // If you suspend either of the two primary processes (Launch or Terminate), this can prevent other
  1477. // process types from functioning properly.
  1478. //
  1479. // See http://goo.gl/DUJpQy for more details.
  1480. func (as *AutoScaling) SuspendProcesses(asgName string, processes []string) (
  1481. resp *SimpleResp, err error) {
  1482. params := makeParams("SuspendProcesses")
  1483. params["AutoScalingGroupName"] = asgName
  1484. if len(processes) > 0 {
  1485. addParamsList(params, "ScalingProcesses.member", processes)
  1486. }
  1487. resp = new(SimpleResp)
  1488. if err := as.query(params, resp); err != nil {
  1489. return nil, err
  1490. }
  1491. return resp, nil
  1492. }
  1493. // TerminateInstanceInAutoScalingGroupResp response wrapper
  1494. //
  1495. // See http://goo.gl/ki5hMh for more details.
  1496. type TerminateInstanceInAutoScalingGroupResp struct {
  1497. Activity Activity `xml:"TerminateInstanceInAutoScalingGroupResult>Activity"`
  1498. RequestId string `xml:"ResponseMetadata>RequestId"`
  1499. }
  1500. // TerminateInstanceInAutoScalingGroup terminates the specified instance.
  1501. // Optionally, the desired group size can be adjusted by setting decrCap to true
  1502. //
  1503. // See http://goo.gl/ki5hMh for more details.
  1504. func (as *AutoScaling) TerminateInstanceInAutoScalingGroup(id string, decrCap bool) (
  1505. resp *TerminateInstanceInAutoScalingGroupResp, err error) {
  1506. params := makeParams("TerminateInstanceInAutoScalingGroup")
  1507. params["InstanceId"] = id
  1508. params["ShouldDecrementDesiredCapacity"] = strconv.FormatBool(decrCap)
  1509. resp = new(TerminateInstanceInAutoScalingGroupResp)
  1510. if err := as.query(params, resp); err != nil {
  1511. return nil, err
  1512. }
  1513. return resp, nil
  1514. }
  1515. // UpdateAutoScalingGroup updates the scaling group.
  1516. //
  1517. // To update an auto scaling group with a launch configuration that has the InstanceMonitoring
  1518. // flag set to False, you must first ensure that collection of group metrics is disabled.
  1519. // Otherwise calls to UpdateAutoScalingGroup will fail.
  1520. //
  1521. // See http://goo.gl/rqrmxy for more details.
  1522. func (as *AutoScaling) UpdateAutoScalingGroup(asg *AutoScalingGroup) (resp *SimpleResp, err error) {
  1523. params := makeParams("UpdateAutoScalingGroup")
  1524. params["AutoScalingGroupName"] = asg.AutoScalingGroupName
  1525. params["MaxSize"] = strconv.Itoa(asg.MaxSize)
  1526. params["MinSize"] = strconv.Itoa(asg.MinSize)
  1527. params["DesiredCapacity"] = strconv.Itoa(asg.DesiredCapacity)
  1528. if asg.DefaultCooldown > 0 {
  1529. params["DefaultCooldown"] = strconv.Itoa(asg.DefaultCooldown)
  1530. }
  1531. if asg.HealthCheckGracePeriod > 0 {
  1532. params["HealthCheckGracePeriod"] = strconv.Itoa(asg.HealthCheckGracePeriod)
  1533. }
  1534. if asg.HealthCheckType != "" {
  1535. params["HealthCheckType"] = asg.HealthCheckType
  1536. }
  1537. if asg.LaunchConfigurationName != "" {
  1538. params["LaunchConfigurationName"] = asg.LaunchConfigurationName
  1539. }
  1540. if asg.PlacementGroup != "" {
  1541. params["PlacementGroup"] = asg.PlacementGroup
  1542. }
  1543. if asg.VPCZoneIdentifier != "" {
  1544. params["VPCZoneIdentifier"] = asg.VPCZoneIdentifier
  1545. }
  1546. if len(asg.AvailabilityZones) > 0 {
  1547. addParamsList(params, "AvailabilityZones.member", asg.AvailabilityZones)
  1548. }
  1549. if len(asg.TerminationPolicies) > 0 {
  1550. addParamsList(params, "TerminationPolicies.member", asg.TerminationPolicies)
  1551. }
  1552. resp = new(SimpleResp)
  1553. if err := as.query(params, resp); err != nil {
  1554. return nil, err
  1555. }
  1556. return resp, nil
  1557. }