Terraform-provider-aws: aws_ssm_maintenance_window_target name and description fields not optional

Created on 28 May 2019  ·  6Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.11

  • provider.archive: version = "~> 1.2"
  • provider.aws: version = "~> 2.12"
  • provider.local: version = "~> 1.2"
  • provider.null: version = "~> 2.1"
  • provider.random: version = "~> 2.1"
  • provider.template: version = "~> 2.1"

Affected Resource(s)

  • aws_ssm_maintenance_window_target

Terraform Configuration Files

resource "aws_ssm_maintenance_window" "backup" {
  name     = "${var.name_prefix}-nightly-backup"
  schedule = "${var.backup_schedule}"
  duration = 1
  cutoff   = 0
}

resource "aws_ssm_maintenance_window_target" "backup" {
  window_id     = "${aws_ssm_maintenance_window.backup.id}"
  resource_type = "INSTANCE"
  targets {
    key    = "${var.backup_target_tag_key}"
    values = ["${var.backup_target_tag_values}"]
  }
}

resource "aws_iam_role_policy_attachment" "extra" {
  role       = "${var.backup_task_role_name}"
  policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonSSMMaintenanceWindowRole"
}

resource "aws_ssm_maintenance_window_task" "backup" {
  name             = "${var.name_prefix}-backup-task"
  description      = "Backup task for ${var.name_prefix}"
  window_id        = "${aws_ssm_maintenance_window.backup.id}"
  task_type        = "RUN_COMMAND"
  task_arn         = "AWS-RunShellScript"
  priority         = 1
  service_role_arn = "${var.backup_task_role_arn}"
  max_concurrency  = "2"
  max_errors       = "1"

  targets {
    key    = "WindowTargetIds"
    values = ["${aws_ssm_maintenance_window_target.backup.id}"]
  }

  task_parameters {
    name   = "commands"
    values = ["${var.backup_commands}"]
  }
}

resource "aws_ssm_association" "backup" {
  name = "AWS-GatherSoftwareInventory"

  targets {
    key    = "${var.backup_target_tag_key}"
    values = ["${var.backup_target_tag_values}"]
  }
}

Expected Behavior

aws_ssm_maintenance_window_target should deploy successfully even without name and description fields, as they are listed as optional.

Actual Behavior

Receiving following error message without including name and description fields:

* module.datastores.module.data_mgmt.module.scheduled_backups.aws_ssm_maintenance_window_target.backup: 1 error(s) occurred:                                                                  

* aws_ssm_maintenance_window_target.backup: InvalidParameter: 2 validation error(s) found.                                                                                                    
- minimum field size of 1, RegisterTargetWithMaintenanceWindowInput.Description.                                                                                                              
- minimum field size of 3, RegisterTargetWithMaintenanceWindowInput.Name.                                                                                                                     

When adjusting configuration files to include a name and description, the resources deploy successfully.

Steps to Reproduce

  1. terraform apply on config without a name and description for aws_ssm_maintenance_window_target. This should return error.
  2. Add name and description fields to aws_ssm_maintenance_window_target and then run terraform apply. Resources should deploy successfully.

Important Factoids

We have previously deployed these resources without issue. This has just started within the past few days.

References

bug servicssm

Most helpful comment

PR incoming! It was an easy fix

All 6 comments

Breaks starting 2.12.0, similar issue with aws_ssm_maintenance_window_task was resolved a few months ago https://github.com/terraform-providers/terraform-provider-aws/issues/6715

Same is happening here. Running "aws" (2.16.0).

Error: Error applying plan:

1 error(s) occurred:

* module.automaintenance-window-dev-1.aws_ssm_maintenance_window_target.target: 1 error(s) occurred:

* aws_ssm_maintenance_window_target.target: InvalidParameter: 2 validation error(s) found.
- minimum field size of 1, RegisterTargetWithMaintenanceWindowInput.Description.
- minimum field size of 3, RegisterTargetWithMaintenanceWindowInput.Name.

PR incoming! It was an easy fix

The fix for this issue on resource creation has been merged and will release with version 2.17.0 of the Terraform AWS Provider, likely later today. Thanks to @stack72 for the remediation.

This has been released in version 2.17.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings