/
autoscaling.go
80 lines (68 loc) · 2.93 KB
/
autoscaling.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package svc
import (
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
"github.com/mxk/awsscan/scan"
"github.com/mxk/go-terraform/tfx"
)
type autoscalingSvc struct{ *scan.Ctx }
var _ = scan.Register(autoscaling.EndpointsID, autoscaling.New, autoscalingSvc{},
[]autoscaling.DescribeAutoScalingGroupsInput{},
[]autoscaling.DescribeAutoScalingInstancesInput{},
[]autoscaling.DescribeLaunchConfigurationsInput{},
[]autoscaling.DescribePoliciesInput{},
[]autoscaling.DescribeScheduledActionsInput{},
)
func (s autoscalingSvc) DescribeLifecycleHooks(dasg *autoscaling.DescribeAutoScalingGroupsOutput) (q []autoscaling.DescribeLifecycleHooksInput) {
s.Split(&q, "AutoScalingGroupName", dasg.AutoScalingGroups, "AutoScalingGroupName")
return
}
func (s autoscalingSvc) DescribeNotificationConfigurations(dasg *autoscaling.DescribeAutoScalingGroupsOutput) (q []autoscaling.DescribeNotificationConfigurationsInput) {
s.Group(&q, "AutoScalingGroupNames", dasg.AutoScalingGroups, "AutoScalingGroupName", 1600)
if s.Mode(scan.CloudAssert) && len(q) == 0 {
q = make([]autoscaling.DescribeNotificationConfigurationsInput, 1)
}
return
}
//
// Post-processing
//
func (s autoscalingSvc) AutoScalingGroups(out *autoscaling.DescribeAutoScalingGroupsOutput) error {
return s.ImportResources("aws_autoscaling_group", tfx.AttrGen{
"id": s.Strings(out.AutoScalingGroups, "AutoScalingGroupName"),
})
}
func (s autoscalingSvc) LaunchConfigurations(out *autoscaling.DescribeLaunchConfigurationsOutput) error {
return s.ImportResources("aws_launch_configuration", tfx.AttrGen{
"id": s.Strings(out.LaunchConfigurations, "LaunchConfigurationName"),
})
}
func (s autoscalingSvc) LifecycleHooks(out *autoscaling.DescribeLifecycleHooksOutput) error {
name := s.Strings(out.LifecycleHooks, "LifecycleHookName")
return s.MakeResources("aws_autoscaling_lifecycle_hook", tfx.AttrGen{
"id": name,
"autoscaling_group_name": s.Strings(out.LifecycleHooks, "AutoScalingGroupName"),
"name": name,
})
}
func (s autoscalingSvc) Policies(out *autoscaling.DescribePoliciesOutput) error {
name := s.Strings(out.ScalingPolicies, "PolicyName")
return s.MakeResources("aws_autoscaling_policy", tfx.AttrGen{
"id": name,
"autoscaling_group_name": s.Strings(out.ScalingPolicies, "AutoScalingGroupName"),
"name": name,
})
}
func (s autoscalingSvc) ScheduledActions(out *autoscaling.DescribeScheduledActionsOutput) error {
name := s.Strings(out.ScheduledUpdateGroupActions, "ScheduledActionName")
return s.MakeResources("aws_autoscaling_schedule", tfx.AttrGen{
"id": name,
"autoscaling_group_name": s.Strings(out.ScheduledUpdateGroupActions, "AutoScalingGroupName"),
"scheduled_action_name": name,
})
}
func (s autoscalingSvc) mockOutput(out interface{}) {
dasg, ok := out.(*autoscaling.DescribeAutoScalingGroupsOutput)
if ok && s.Mode(scan.CloudAssert) {
dasg.AutoScalingGroups = nil
}
}