forked from hashicorp/terraform-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hashicorp#8777 from stefansundin/appautoscaling_sc…
…heduled_action-capacity-fix
- Loading branch information
Showing
5 changed files
with
515 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:enhancement | ||
resource/aws_appautoscaling_scheduled_action: No longer re-creates when changes can be updated in-place. | ||
``` | ||
|
||
```release-note:enhancement | ||
resource/aws_appautoscaling_scheduled_action: Allows setting leaving `min_capacity` or `max_capacity` unset. | ||
``` |
46 changes: 46 additions & 0 deletions
46
aws/internal/service/applicationautoscaling/finder/finder.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package finder | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/applicationautoscaling" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func ScheduledAction(conn *applicationautoscaling.ApplicationAutoScaling, name, serviceNamespace, resourceId string) (*applicationautoscaling.ScheduledAction, error) { | ||
var result *applicationautoscaling.ScheduledAction | ||
|
||
input := &applicationautoscaling.DescribeScheduledActionsInput{ | ||
ScheduledActionNames: []*string{aws.String(name)}, | ||
ServiceNamespace: aws.String(serviceNamespace), | ||
ResourceId: aws.String(resourceId), | ||
} | ||
err := conn.DescribeScheduledActionsPages(input, func(page *applicationautoscaling.DescribeScheduledActionsOutput, lastPage bool) bool { | ||
if page == nil { | ||
return !lastPage | ||
} | ||
|
||
for _, item := range page.ScheduledActions { | ||
if item == nil { | ||
continue | ||
} | ||
|
||
if name == aws.StringValue(item.ScheduledActionName) { | ||
result = item | ||
return false | ||
} | ||
} | ||
|
||
return !lastPage | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if result == nil { | ||
return nil, &resource.NotFoundError{ | ||
LastRequest: input, | ||
} | ||
} | ||
|
||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.