-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
add name and description to SSM Maintenance Window Tasks #5762
Changes from 4 commits
2728e9d
4004ffb
465112b
d63ff82
f418a43
2d41b1a
dbb2e31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,20 @@ func resourceAwsSsmMaintenanceWindowTask() *schema.Resource { | |
}, | ||
}, | ||
|
||
"name": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
ValidateFunc: validateAwsSSMMaintenanceWindowTaskName, | ||
}, | ||
Guimove marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
"description": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
ValidateFunc: validateAwsSSMMaintenanceWindowTaskDescription, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use an upstream validation function here instead of our own custom one: https://godoc.org/github.com/hashicorp/terraform/helper/validation#StringLenBetween ValidateFunc: validation.StringLenBetween(0, 128), There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok for the description but for the name I can keep my validator that check the regex and the length ? |
||
}, | ||
Guimove marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
"priority": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
|
@@ -191,6 +205,8 @@ func resourceAwsSsmMaintenanceWindowTaskCreate(d *schema.ResourceData, meta inte | |
TaskType: aws.String(d.Get("task_type").(string)), | ||
ServiceRoleArn: aws.String(d.Get("service_role_arn").(string)), | ||
TaskArn: aws.String(d.Get("task_arn").(string)), | ||
Name: aws.String(d.Get("name").(string)), | ||
Description: aws.String(d.Get("description").(string)), | ||
Targets: expandAwsSsmTargets(d.Get("targets").([]interface{})), | ||
} | ||
|
||
|
@@ -241,6 +257,14 @@ func resourceAwsSsmMaintenanceWindowTaskRead(d *schema.ResourceData, meta interf | |
d.Set("task_arn", t.TaskArn) | ||
d.Set("priority", t.Priority) | ||
|
||
if t.Name != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I'll remove that if |
||
d.Set("name", t.Name) | ||
} | ||
|
||
if t.Description != nil { | ||
d.Set("description", t.Description) | ||
} | ||
|
||
if t.LoggingInfo != nil { | ||
if err := d.Set("logging_info", flattenAwsSsmMaintenanceWindowLoggingInfo(t.LoggingInfo)); err != nil { | ||
return fmt.Errorf("[DEBUG] Error setting logging_info error: %#v", err) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ func TestAccAWSSSMMaintenanceWindowTask_basic(t *testing.T) { | |
Config: testAccAWSSSMMaintenanceWindowTaskBasicConfig(name), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSSSMMaintenanceWindowTaskExists("aws_ssm_maintenance_window_task.target", &task), | ||
resource.TestCheckResourceAttr("aws_ssm_maintenance_window_task.target", "name", "TestMaintenanceWindowTask"), | ||
resource.TestCheckResourceAttr("aws_ssm_maintenance_window_task.target", "description", "This ressource is for test purpose only"), | ||
), | ||
}, | ||
}, | ||
|
@@ -141,6 +143,8 @@ resource "aws_ssm_maintenance_window_task" "target" { | |
task_type = "RUN_COMMAND" | ||
task_arn = "AWS-RunShellScript" | ||
priority = 1 | ||
name = "TestMaintenanceWindowTask" | ||
Guimove marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description = "This ressource is for test purpose only" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: Typo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the french touch hehe |
||
service_role_arn = "${aws_iam_role.ssm_role.arn}" | ||
max_concurrency = "2" | ||
max_errors = "1" | ||
|
@@ -213,6 +217,8 @@ resource "aws_ssm_maintenance_window_task" "target" { | |
task_type = "RUN_COMMAND" | ||
task_arn = "AWS-RunShellScript" | ||
priority = 1 | ||
name = "TestMaintenanceWindowTask" | ||
description = "This ressource is for test purpose only" | ||
service_role_arn = "${aws_iam_role.ssm_role.arn}" | ||
max_concurrency = "2" | ||
max_errors = "1" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really forcing a new resource? The API seems to tell the opposite (i.e. it's updatable): https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_UpdateMaintenanceWindowTask.html