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

provider/aws: aws_autoscaling_policy fails when setting scaling_adjustment to 0 for SimpleScaling #8893

Merged
merged 3 commits into from
Oct 21, 2016
Merged

Conversation

denniswebb
Copy link
Contributor

Terraform 0.7.3 incorrectly handles setting scaling_adjustment=0 when using policy_type = "SimpleScaling" although this is allowed in the AWS CLI and Console for all 3 adjustment_types.

The following terraform configuration:

resource "aws_autoscaling_policy" "ok" {
    name = "terraform-test-ok"
    scaling_adjustment = 0
    adjustment_type = "ExactCapacity"
    cooldown = 300
    autoscaling_group_name = "${aws_autoscaling_group.main.name}"
}

will return the error:

* aws_autoscaling_policy.foobar_simple: Error putting scaling policy: ValidationError: Scaling increment must be specified for a SimpleScaling policy
            status code: 400, request id: 0a983458-7c7a-11e6-b90d-c986fdc05768

This is due to the current provider using the GetOk function which doesn't set the value if equal to 0. This PR changes this behavior by using the Get function when the policy_type="SimpleScaling", and falls back to using GetOk when the policy_type isn't.

Below are the acceptance test results.

make testacc TEST=./builtin/providers/aws TESTARGS='-run=AccAWSAutoscalingPolicy_SimpleScalingStepAdjustment'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/09/16 21:18:59 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=AccAWSAutoscalingPolicy_SimpleScalingStepAdjustment -timeout 120m
=== RUN   TestAccAWSAutoscalingPolicy_SimpleScalingStepAdjustment
--- PASS: TestAccAWSAutoscalingPolicy_SimpleScalingStepAdjustment (43.07s)
PASS
ok      github.com/dennis-bsi/terraform/builtin/providers/aws   43.098s

@denniswebb
Copy link
Contributor Author

Just realized this should fix #6276

@denniswebb
Copy link
Contributor Author

@catsby If you're in the merging mood, I have this one that has gotten overlooked that I need in 0.7.8 hopefully.

@catsby
Copy link
Contributor

catsby commented Oct 21, 2016

Thank you @dennis-bsi – this looks good

TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSAutoscalingPolicy_SimpleScalingStepAdjustment -timeout 120m
=== RUN   TestAccAWSAutoscalingPolicy_SimpleScalingStepAdjustment
--- PASS: TestAccAWSAutoscalingPolicy_SimpleScalingStepAdjustment (38.37s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    38.386s
Test:

@catsby catsby merged commit dcbcde4 into hashicorp:master Oct 21, 2016
@ghost
Copy link

ghost commented Apr 21, 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 21, 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.

3 participants