Skip to content

Commit

Permalink
add validations
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 committed Feb 11, 2021
1 parent fc4bda7 commit 469c142
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions aws/resource_aws_cloudwatch_metric_alarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,9 @@ func resourceAwsCloudWatchMetricAlarm() *schema.Resource {
Computed: true,
},
"comparison_operator": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
cloudwatch.ComparisonOperatorGreaterThanOrEqualToThreshold,
cloudwatch.ComparisonOperatorGreaterThanThreshold,
cloudwatch.ComparisonOperatorGreaterThanUpperThreshold,
cloudwatch.ComparisonOperatorLessThanLowerOrGreaterThanUpperThreshold,
cloudwatch.ComparisonOperatorLessThanLowerThreshold,
cloudwatch.ComparisonOperatorLessThanOrEqualToThreshold,
cloudwatch.ComparisonOperatorLessThanThreshold,
}, false),
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice(cloudwatch.ComparisonOperator_Values(), false),
},
"evaluation_periods": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -100,8 +92,9 @@ func resourceAwsCloudWatchMetricAlarm() *schema.Resource {
Required: true,
},
"unit": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(cloudwatch.StandardUnit_Values(), false),
},
},
},
Expand Down Expand Up @@ -132,13 +125,7 @@ func resourceAwsCloudWatchMetricAlarm() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"extended_statistic", "metric_query"},
ValidateFunc: validation.StringInSlice([]string{
cloudwatch.StatisticAverage,
cloudwatch.StatisticMaximum,
cloudwatch.StatisticMinimum,
cloudwatch.StatisticSampleCount,
cloudwatch.StatisticSum,
}, false),
ValidateFunc: validation.StringInSlice(cloudwatch.Statistic_Values(), false),
},
"threshold": {
Type: schema.TypeFloat,
Expand Down Expand Up @@ -196,8 +183,9 @@ func resourceAwsCloudWatchMetricAlarm() *schema.Resource {
Set: schema.HashString,
},
"unit": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(cloudwatch.StandardUnit_Values(), false),
},
"extended_statistic": {
Type: schema.TypeString,
Expand Down

0 comments on commit 469c142

Please sign in to comment.