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

Add support for "StepScaling" autoscaling policies. #4277

Merged
merged 3 commits into from
Mar 31, 2016

Conversation

ctiwald
Copy link
Contributor

@ctiwald ctiwald commented Dec 12, 2015

Amazon added this policy type last spring, but terraform doesn't support it. This PR would implement "StepScaling" policies for autoscaling groups.

This took far more doing than I anticipated. AWS doesn't provide a secondary API endpoint for step policy management. It simply overloads the current policy API, and then switches certain attributes on and off depending on the policy type. I added support for every existing policy attribute, and a fair amount of validation within resource_aws_autoscaling_policy to confirm user input is correct.

The resource is further complicated by a nested Schema which doesn't exist outside the context of these API calls. In all this was surprisingly complicated, but I think I've got something that works. I wouldn't mind a little 3rd party testing -- the edge cases mired me for a while during development.

@ctiwald
Copy link
Contributor Author

ctiwald commented Dec 12, 2015

Whoops. I know what's up here. Will correct later tonight.

@ctiwald ctiwald force-pushed the ct/add-new-asg-policy-type branch 2 times, most recently from 8c31f46 to bae0fd5 Compare December 14, 2015 01:30
@ctiwald
Copy link
Contributor Author

ctiwald commented Dec 14, 2015

@catsby -- not sure what to make of that build error. Best I can tell it's not at all related to my changes, which pass both Acc and unit tests locally.

return nil, fmt.Errorf(
"metric_interval_lower_bound isn't a string. This is a bug. Please file an issue.")
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, I really hate this code. As a schema.Set, we lose the ability to distinguish between an uninitialized float (i.e. 0) and a user-declared value of 0 in the state file for TypeFloat elements. But the StepScaling policies critically depend on absent boundaries -- AWS treats missing boundaries as positive and negative infinity, which apply to a ton of use cases.

Hence I made them strings... which have to be parsed into floats... I hate it too. I'm open to any suggestions to rework this function more sanely, but I can't find any other way to distinguish between a legitimate 0.0 from a user and an empty boundary value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is agreed! currently, 0's are really tough to work with in Terraform :( The only way around this would be to set default values of 0 and then test for those and them treat as excluded

@ctiwald
Copy link
Contributor Author

ctiwald commented Dec 18, 2015

Any word on a merge date for this, @catsby, @radeksimko? We'd like to start using this functionality but we avoid custom versions of TF if we can so as not to poison our state. Totally happy to use the tip of master, though...

@ctiwald
Copy link
Contributor Author

ctiwald commented Jan 1, 2016

Hey @phinze, @radeksimko, @catsby -- any word on whether or not this could be merged? We'd love to start using this functionality but I really don't want to fork TF and potentially munge up our state files if I can help it.

@ctiwald
Copy link
Contributor Author

ctiwald commented Jan 28, 2016

@catsby -- can you offer me any update on this one?

@ericfode
Copy link

ericfode commented Feb 4, 2016

👍 This would be awesome!

@stack72
Copy link
Contributor

stack72 commented Mar 23, 2016

@ctiwald can you rebase this please so I can get it merged after a review?

Unlike SimpleScaling policies, StepScaling policies require one or more
"steps", which are interval ranges in which a tracked metric can lie.
Policies can then execute scaling adjustments wedded to these steps.

This commit also adds a slew of additional policy attributes which are
only applicable to step policies.
@stack72
Copy link
Contributor

stack72 commented Mar 31, 2016

Hi @ctiwald

the PR looks good. Going to run the acceptance tests to make sure all looks good. Pending review, I will merge :)

Btw, loving that you have added the deprecation warnings to match that of AWS! 👍

P.

@stack72
Copy link
Contributor

stack72 commented Mar 31, 2016

Tests look good!!!

make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSAutoscalingPolicy' 2>~/tf.log
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /vendor/)
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSAutoscalingPolicy -timeout 120m
=== RUN   TestAccAWSAutoscalingPolicy_basic
--- PASS: TestAccAWSAutoscalingPolicy_basic (129.76s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    129.777s

@stack72 stack72 merged commit a8e0528 into hashicorp:master Mar 31, 2016
@ghost
Copy link

ghost commented Apr 27, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants