Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_cloudwatch_metric_alarm: Accept EC2 automate reboot ARN #6405

Merged
merged 1 commit into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion aws/resource_aws_cloudwatch_metric_alarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate(t *testing.T) {
CheckDestroy: testAccCheckAWSCloudWatchMetricAlarmDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSCloudWatchMetricAlarmConfigAlarmActionsEC2Automate(rName, "recover"),
Config: testAccAWSCloudWatchMetricAlarmConfigAlarmActionsEC2Automate(rName, "reboot"),
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudWatchMetricAlarmExists(resourceName, &alarm),
resource.TestCheckResourceAttr(resourceName, "alarm_actions.#", "1"),
Expand All @@ -65,6 +65,27 @@ func TestAccAWSCloudWatchMetricAlarm_AlarmActions_EC2Automate(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAWSCloudWatchMetricAlarmConfigAlarmActionsEC2Automate(rName, "recover"),
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudWatchMetricAlarmExists(resourceName, &alarm),
resource.TestCheckResourceAttr(resourceName, "alarm_actions.#", "1"),
),
},
{
Config: testAccAWSCloudWatchMetricAlarmConfigAlarmActionsEC2Automate(rName, "stop"),
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudWatchMetricAlarmExists(resourceName, &alarm),
resource.TestCheckResourceAttr(resourceName, "alarm_actions.#", "1"),
),
},
{
Config: testAccAWSCloudWatchMetricAlarmConfigAlarmActionsEC2Automate(rName, "terminate"),
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudWatchMetricAlarmExists(resourceName, &alarm),
resource.TestCheckResourceAttr(resourceName, "alarm_actions.#", "1"),
),
},
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion aws/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func validateEC2AutomateARN(v interface{}, k string) (ws []string, errors []erro
value := v.(string)

// https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html
pattern := `^arn:[\w-]+:automate:[\w-]+:ec2:(recover|stop|terminate)$`
pattern := `^arn:[\w-]+:automate:[\w-]+:ec2:(reboot|recover|stop|terminate)$`
if !regexp.MustCompile(pattern).MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q does not match EC2 automation ARN (%q): %q",
Expand Down
1 change: 1 addition & 0 deletions aws/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ func TestValidateArn(t *testing.T) {

func TestValidateEC2AutomateARN(t *testing.T) {
validNames := []string{
"arn:aws:automate:us-east-1:ec2:reboot",
"arn:aws:automate:us-east-1:ec2:recover",
"arn:aws:automate:us-east-1:ec2:stop",
"arn:aws:automate:us-east-1:ec2:terminate",
Expand Down