Terraform v0.11.11
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}"]
}
}
aws_ssm_maintenance_window_target should deploy successfully even without name and description fields, as they are listed as optional.
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.
terraform apply on config without a name and description for aws_ssm_maintenance_window_target. This should return error.name and description fields to aws_ssm_maintenance_window_target and then run terraform apply. Resources should deploy successfully.We have previously deployed these resources without issue. This has just started within the past few days.
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!
Most helpful comment
PR incoming! It was an easy fix