@@ -34,17 +34,24 @@ func ResourcePolicy() *schema.Resource {
34
34
},
35
35
36
36
Schema : map [string ]* schema.Schema {
37
+ "alarm_arns" : {
38
+ Type : schema .TypeList ,
39
+ Computed : true ,
40
+ Elem : & schema.Schema {
41
+ Type : schema .TypeString ,
42
+ },
43
+ },
44
+ "arn" : {
45
+ Type : schema .TypeString ,
46
+ Computed : true ,
47
+ },
37
48
"name" : {
38
49
Type : schema .TypeString ,
39
50
Required : true ,
40
51
ForceNew : true ,
41
52
// https://github.com/boto/botocore/blob/9f322b1/botocore/data/autoscaling/2011-01-01/service-2.json#L1862-L1873
42
53
ValidateFunc : validation .StringLenBetween (0 , 255 ),
43
54
},
44
- "arn" : {
45
- Type : schema .TypeString ,
46
- Computed : true ,
47
- },
48
55
"policy_type" : {
49
56
Type : schema .TypeString ,
50
57
Optional : true ,
@@ -148,15 +155,9 @@ func ResourcePolicy() *schema.Resource {
148
155
Required : true ,
149
156
},
150
157
"statistic" : {
151
- Type : schema .TypeString ,
152
- Required : true ,
153
- ValidateFunc : validation .StringInSlice ([]string {
154
- applicationautoscaling .MetricStatisticAverage ,
155
- applicationautoscaling .MetricStatisticMinimum ,
156
- applicationautoscaling .MetricStatisticMaximum ,
157
- applicationautoscaling .MetricStatisticSampleCount ,
158
- applicationautoscaling .MetricStatisticSum ,
159
- }, false ),
158
+ Type : schema .TypeString ,
159
+ Required : true ,
160
+ ValidateFunc : validation .StringInSlice (applicationautoscaling .MetricStatistic_Values (), false ),
160
161
},
161
162
"unit" : {
162
163
Type : schema .TypeString ,
@@ -165,6 +166,11 @@ func ResourcePolicy() *schema.Resource {
165
166
},
166
167
},
167
168
},
169
+ "disable_scale_in" : {
170
+ Type : schema .TypeBool ,
171
+ Default : false ,
172
+ Optional : true ,
173
+ },
168
174
"predefined_metric_specification" : {
169
175
Type : schema .TypeList ,
170
176
MaxItems : 1 ,
@@ -184,11 +190,6 @@ func ResourcePolicy() *schema.Resource {
184
190
},
185
191
},
186
192
},
187
- "disable_scale_in" : {
188
- Type : schema .TypeBool ,
189
- Default : false ,
190
- Optional : true ,
191
- },
192
193
"scale_in_cooldown" : {
193
194
Type : schema .TypeInt ,
194
195
Optional : true ,
@@ -284,6 +285,11 @@ func resourcePolicyRead(d *schema.ResourceData, meta interface{}) error {
284
285
285
286
log .Printf ("[DEBUG] Read ApplicationAutoScaling policy: %s, SP: %s, Obj: %s" , d .Get ("name" ), d .Get ("name" ), p )
286
287
288
+ var alarmARNs = make ([]string , 0 , len (p .Alarms ))
289
+ for _ , alarm := range p .Alarms {
290
+ alarmARNs = append (alarmARNs , aws .StringValue (alarm .AlarmARN ))
291
+ }
292
+ d .Set ("alarm_arns" , alarmARNs )
287
293
d .Set ("arn" , p .PolicyARN )
288
294
d .Set ("name" , p .PolicyName )
289
295
d .Set ("policy_type" , p .PolicyType )
0 commit comments