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

[Bug]: aws_appautoscaling_scheduled_action start_time and end_time not mantained when updating resources #32616

Closed
marcopalumbo opened this issue Jul 20, 2023 · 4 comments · Fixed by #33713
Labels
bug Addresses a defect in current functionality. service/appautoscaling Issues and PRs that pertain to the appautoscaling service.
Milestone

Comments

@marcopalumbo
Copy link

marcopalumbo commented Jul 20, 2023

Terraform Core Version

1.5.3

AWS Provider Version

5.8.0

Affected Resource(s)

aws_appautoscaling_scheduled_action

Expected Behavior

When updating a aws_appautoscaling_scheduled_action resource, all the previously configured settings are maintained

Actual Behavior

When updating a aws_appautoscaling_scheduled_action resource, the previously configured start_time and end_time are lost

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_appautoscaling_target" "ecs_target" {
  max_capacity       = var.MaxCapacity
  min_capacity       = var.MinCapacity
  resource_id        = "service/${var.ecs_cluster.name}/${aws_ecs_service.ecs_service.name}"
  scalable_dimension = "ecs:service:DesiredCount"
  service_namespace  = "ecs"
}

resource "aws_appautoscaling_scheduled_action" "all_days_shift_weekend" {
  name               = "all_days_shift_weekend"
  service_namespace  = aws_appautoscaling_target.ecs_target.service_namespace
  scalable_dimension = aws_appautoscaling_target.ecs_target.scalable_dimension
  resource_id        = aws_appautoscaling_target.ecs_target.resource_id
  schedule           = "cron(00 19 ? * FRI *)"
  timezone           = "Europe/Rome"
  scalable_target_action {
    min_capacity = var.WeekendCapacity
    max_capacity = var.WeekendCapacity
  }
  start_time = "2023-07-19T13:00:00+02:00"
  end_time   = "2023-07-27T13:00:00+02:00"
}

Steps to Reproduce

  1. Create an ECS cluster
  2. Create an ECS service
  3. Plan and apply the Autoscaling Target and Scheduled action as in config files
  4. Check via cli aws application-autoscaling describe-scheduled-actions --service-namespace ecs and see that start_time and end_time are present
{
    "ScheduledActions": [
        {
            "ScheduledActionName": "all_days_shift_weekend",
            "ScheduledActionARN": "arn:aws:autoscaling:eu-west-1:112345123123:scheduledAction:4a1231ff-xxxx-xxxx-xxxx-c989676b6d3e:resource/ecs/service/cluster/service:scheduledActionName/all_days_shift_weekend",
            "ServiceNamespace": "ecs",
            "Schedule": "cron(00 19 ? * FRI *)",
            "Timezone": "Europe/Rome",
            "ResourceId": "service/cluster/service",
            "StartTime": "2023-07-19T13:00:00+02:00",
            "EndTime": "2023-07-27T13:00:00+02:00",
            "ScalableDimension": "ecs:service:DesiredCount",
            "ScalableTargetAction": {
                "MinCapacity": 2,
                "MaxCapacity": 2
            },
            "CreationTime": "2023-07-20T10:58:23.570000+02:00"
        }
    ]
}
  1. Change the var.WeekendCapacity from 2 to 3 (or anything different from 2)
  2. Plan and apply, you will see
Plan: 0 to add, 1 to change, 0 to destroy.
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
  1. Check via cli aws application-autoscaling describe-scheduled-actions --service-namespace ecs and see that start_time and end_time are not present anymore
{
    "ScheduledActions": [
        {
            "ScheduledActionName": "all_days_shift_weekend",
            "ScheduledActionARN": "arn:aws:autoscaling:eu-west-1:112345123123:scheduledAction:4a1231ff-xxxx-xxxx-xxxx-c989676b6d3e:resource/ecs/service/cluster/service:scheduledActionName/all_days_shift_weekend",
            "ServiceNamespace": "ecs",
            "Schedule": "cron(00 19 ? * FRI *)",
            "Timezone": "Europe/Rome",
            "ResourceId": "service/cluster/service",
            "ScalableDimension": "ecs:service:DesiredCount",
            "ScalableTargetAction": {
                "MinCapacity": 3,
                "MaxCapacity": 3
            },
            "CreationTime": "2023-07-20T10:58:23.570000+02:00"
        }
    ]
}

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@marcopalumbo marcopalumbo added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Jul 20, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/appautoscaling Issues and PRs that pertain to the appautoscaling service. label Jul 20, 2023
@marcopalumbo
Copy link
Author

marcopalumbo commented Jul 20, 2023

To further check the issue I tried to create the same scheduled action via CLI, so:

  1. issued this command
aws application-autoscaling put-scheduled-action 
\ --scheduled-action-name all_days_shift_weekend
\ --service-namespace ecs 
\ --schedule "cron(00 19 ? * FRI *)"
\ --timezone Europe/Rome
\ --resource-id service/cluster/service 
\ --scalable-dimension ecs:service:DesiredCount 
\ --scalable-target-action MinCapacity=2,MaxCapacity=2
\ --start-time 2023-07-19T13:00:00+02:00
\ --end-time 2023-07-27T13:00:00+02:00
  1. checked via CLI with describe-scheduled-actions => all values present
  2. reissued the same put-scheduled-action with different values of MinCapacity=3,MaxCapacity=3
  3. checked again via CLI with describe-scheduled-actions => all values present
  4. reissued the same put-scheduled-action with different values of MinCapacity=4,MaxCapacity=4 but without --start-time --end-time
  5. checked again via CLI with describe-scheduled-actions => --start-time --end-time missing

So it seems like that on modification of resources, terraform passes to AWS only the changed values, but in this case the resource want it all, even if the object on AWS is updated and not deleted and recreated (you can see that "CreationTime" remains the same)

@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Jul 24, 2023
@github-actions github-actions bot added this to the v5.42.0 milestone Mar 18, 2024
Copy link

This functionality has been released in v5.42.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. Thank you!

Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2024
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/appautoscaling Issues and PRs that pertain to the appautoscaling service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants