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

changing an aws_ssm_maintenance_window_task that has priority 0 results in a "Member must not be null" priority constraint error from the API #17871

Closed
tzvifriedman opened this issue Mar 2, 2021 · 4 comments · Fixed by #17885
Assignees
Labels
bug Addresses a defect in current functionality. service/ssm Issues and PRs that pertain to the ssm service.
Milestone

Comments

@tzvifriedman
Copy link

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 other comments that do not add relevant new information or questions, 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 CLI and Terraform AWS Provider Version

Terraform v0.13.4
AWS provider 3.23

Affected Resource(s)

  • aws_ssm_maintenance_window_task

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "aws_ssm_maintenance_window_task" "datadog_mute" {
  count            = var.mx_window_multiple == true ? 2 : 1
  priority         = 0
  max_concurrency  = "10"
  max_errors       = "5"
  service_role_arn = [...]
  task_arn         = "AWS-RunPowerShellScript"
  task_type        = "RUN_COMMAND"
  window_id        = aws_ssm_maintenance_window.mx_window_install.*.id[count.index]

  targets {
    key    = "WindowTargetIds"
    values = [aws_ssm_maintenance_window_target.mx_window_install_target.*.id[count.index]]
  }

  task_invocation_parameters {
    run_command_parameters {
      service_role_arn = "[...]"
      timeout_seconds  = "600"

      parameter {
        name   = "commands"
        values = [...]
      }
    }

  }
}

Debug Output

�Terraform v0.13.4
Initializing plugins and modules...
module.default_mx.aws_ssm_maintenance_window_task.datadog_mute[0]: Modifying... [id=7ee87613-fafe-42cf-90b9-21e46b7f569a]

Error: Error updating Maintenance Window (mw-0206570beb23779d2) Task (7ee87613-fafe-42cf-90b9-21e46b7f569a): ValidationException: Value null at 'Priority' failed to satisfy constraint: Member must not be null
status code: 400, request id: 6a6385ca-410f-47e2-a9c9-6663afac6208

on ../../../base/mx_window/main.tf line 119, in resource "aws_ssm_maintenance_window_task" "datadog_mute":
119: resource "aws_ssm_maintenance_window_task" "datadog_mute" {

I don't actually have access to the full debug logs at this point, since I'm on TFE and I'm not sure how to get access to the full debug log...

Panic Output

Expected Behavior

I'm just changing the contents of the script commands, and the plan is successful. It is supposed to change the commands and it lists the priority as 0.

Actual Behavior

The apply should change the commands and leave the priority as 0. Instead, on apply, the API seems to think that value is actually null.

I have three tasks in this MX Window, and I can actually bypass this issue by setting the priorities to 1, 2, and 3; obviously this is not ideal. There's something about the 0 that is making AWS think it's trying to pass null.

Steps to Reproduce

  1. Create a maintenance window task with priority 0.
  2. Make a change to something in the task that doesn't trigger a recreate.
  3. terraform apply

Important Factoids

References

  • #0000
@ghost ghost added the service/ssm Issues and PRs that pertain to the ssm service. label Mar 2, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 2, 2021
@bflad bflad added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 2, 2021
@bflad bflad self-assigned this Mar 2, 2021
bflad added a commit that referenced this issue Mar 2, 2021
… error on update when priority is not set or 0

Reference: #17871

Priority is optional, but it is currently configured in every test configuration which is why this was not found before. To minimize the changes to verify this bug and timebox effort as part of triage, submitting one preferred style test that covers the behavior.

Previously:

```
=== CONT  TestAccAWSSSMMaintenanceWindowTask_Description
    resource_aws_ssm_maintenance_window_task_test.go:114: Step 3/3 error: Error running apply: exit status 1

        Error: Error updating Maintenance Window (mw-02f66f1bc3df08b83) Task (4c1a1e3e-c449-4e2d-882c-5f8a23a2104d): ValidationException: Value null at 'Priority' failed to satisfy constraint: Member must not be null
        	status code: 400, request id: fc15f736-7e53-49bb-8d5d-11f35ba98a30

          on terraform_plugin_test.tf line 58, in resource "aws_ssm_maintenance_window_task" "test":
          58: resource "aws_ssm_maintenance_window_task" "test" {

--- FAIL: TestAccAWSSSMMaintenanceWindowTask_Description (22.29s)
```

Output from acceptance testing in AWS Commercial:

```
--- PASS: TestAccAWSSSMMaintenanceWindowTask_basic (36.64s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_Description (36.65s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_disappears (20.12s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_emptyNotificationConfig (21.04s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_noRole (21.13s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationAutomationParameters (49.73s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationLambdaParameters (39.99s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationRunCommandParameters (50.76s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationRunCommandParametersCloudWatch (53.64s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationStepFunctionParameters (23.05s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_updateForcesNewResource (36.64s)
```

Output from acceptance testing in AWS GovCloud (US):

```
--- PASS: TestAccAWSSSMMaintenanceWindowTask_basic (48.68s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_Description (45.57s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_disappears (28.64s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_emptyNotificationConfig (28.72s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_noRole (28.97s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationAutomationParameters (52.58s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationLambdaParameters (49.44s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationRunCommandParameters (54.30s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationRunCommandParametersCloudWatch (60.93s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationStepFunctionParameters (31.03s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_updateForcesNewResource (46.25s)
```
@bflad
Copy link
Contributor

bflad commented Mar 2, 2021

Hi @tzvifriedman 👋 Thank you for submitting this and sorry you ran into trouble here. This is a small bug in the resource, which can be fixed up with this change: #17885

@tzvifriedman
Copy link
Author

I had a hunch that validation was the issue, but I do not have the Go knowledge to confirm. Thanks for the quick turnaround!

bflad added a commit that referenced this issue Mar 4, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
… error on update when priority is not set or 0 (#17885)

Reference: #17871

Priority is optional, but it is currently configured in every test configuration which is why this was not found before. To minimize the changes to verify this bug and timebox effort as part of triage, submitting one preferred style test that covers the behavior.

Previously:

```
=== CONT  TestAccAWSSSMMaintenanceWindowTask_Description
    resource_aws_ssm_maintenance_window_task_test.go:114: Step 3/3 error: Error running apply: exit status 1

        Error: Error updating Maintenance Window (mw-02f66f1bc3df08b83) Task (4c1a1e3e-c449-4e2d-882c-5f8a23a2104d): ValidationException: Value null at 'Priority' failed to satisfy constraint: Member must not be null
        	status code: 400, request id: fc15f736-7e53-49bb-8d5d-11f35ba98a30

          on terraform_plugin_test.tf line 58, in resource "aws_ssm_maintenance_window_task" "test":
          58: resource "aws_ssm_maintenance_window_task" "test" {

--- FAIL: TestAccAWSSSMMaintenanceWindowTask_Description (22.29s)
```

Output from acceptance testing in AWS Commercial:

```
--- PASS: TestAccAWSSSMMaintenanceWindowTask_basic (36.64s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_Description (36.65s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_disappears (20.12s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_emptyNotificationConfig (21.04s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_noRole (21.13s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationAutomationParameters (49.73s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationLambdaParameters (39.99s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationRunCommandParameters (50.76s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationRunCommandParametersCloudWatch (53.64s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationStepFunctionParameters (23.05s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_updateForcesNewResource (36.64s)
```

Output from acceptance testing in AWS GovCloud (US):

```
--- PASS: TestAccAWSSSMMaintenanceWindowTask_basic (48.68s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_Description (45.57s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_disappears (28.64s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_emptyNotificationConfig (28.72s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_noRole (28.97s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationAutomationParameters (52.58s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationLambdaParameters (49.44s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationRunCommandParameters (54.30s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationRunCommandParametersCloudWatch (60.93s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_TaskInvocationStepFunctionParameters (31.03s)
--- PASS: TestAccAWSSSMMaintenanceWindowTask_updateForcesNewResource (46.25s)
```
@github-actions github-actions bot added this to the v3.31.0 milestone Mar 4, 2021
@ghost
Copy link

ghost commented Mar 5, 2021

This has been released in version 3.31.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!

@ghost
Copy link

ghost commented Apr 4, 2021

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!

@ghost ghost locked as resolved and limited conversation to collaborators Apr 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ssm Issues and PRs that pertain to the ssm service.
Projects
None yet
2 participants