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

add name and description to SSM Maintenance Window Tasks #5762

Merged
merged 7 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 22 additions & 0 deletions aws/resource_aws_ssm_maintenance_window_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ func resourceAwsSsmMaintenanceWindowTask() *schema.Resource {
},
},

"name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
Guimove marked this conversation as resolved.
Show resolved Hide resolved

"description": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
Guimove marked this conversation as resolved.
Show resolved Hide resolved

"priority": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -191,6 +203,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{})),
}

Expand Down Expand Up @@ -241,6 +255,14 @@ func resourceAwsSsmMaintenanceWindowTaskRead(d *schema.ResourceData, meta interf
d.Set("task_arn", t.TaskArn)
d.Set("priority", t.Priority)

if t.Name != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d.Set() automatically handles conversions of types like *string and we prefer to always call d.Set() for drift detection. (Same with description below)

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)
Expand Down
4 changes: 4 additions & 0 deletions aws/resource_aws_ssm_maintenance_window_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Typo ressource should be resource

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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"
Expand Down Expand Up @@ -213,6 +215,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"
Expand Down