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

resource/aws_autoscaling_policy: Properly read step_adjustment into Terraform state #7336

Merged

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Jan 25, 2019

This pull request builds on top of #7195 and only requires review of 5fd80c1

Previously, the resource was silently failing to read this attribute and therefore unable to perform drift detection or properly import the resource (currently being added).

--- FAIL: TestAccAWSAutoscalingPolicy_basic (85.72s)
    testing.go:538: Step 2 error: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) {
        }

        (map[string]string) (len=4) {
         (string) (len=17) "step_adjustment.#": (string) (len=1) "1",
         (string) (len=54) "step_adjustment.2042107634.metric_interval_lower_bound": (string) (len=1) "2",
         (string) (len=54) "step_adjustment.2042107634.metric_interval_upper_bound": (string) "",
         (string) (len=45) "step_adjustment.2042107634.scaling_adjustment": (string) (len=1) "1"
        }

Returning the error from d.Set():

--- FAIL: TestAccAWSAutoscalingPolicy_basic (14.03s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_autoscaling_policy.foobar_step: 1 error occurred:
        	* aws_autoscaling_policy.foobar_step: error setting step_adjustment: step_adjustment.0.metric_interval_lower_bound: '' expected type 'string', got unconvertible type 'float64'

Output from acceptance testing after adjustments:

--- PASS: TestAccAWSAutoscalingPolicy_zerovalue (44.61s)
--- PASS: TestAccAWSAutoscalingPolicy_SimpleScalingStepAdjustment (46.60s)
--- PASS: TestAccAWSAutoscalingPolicy_TargetTrack_Predefined (48.75s)
--- PASS: TestAccAWSAutoscalingPolicy_disappears (72.73s)
--- PASS: TestAccAWSAutoscalingPolicy_TargetTrack_Custom (74.47s)
--- PASS: TestAccAWSAutoscalingPolicy_upgrade (76.43s)
--- PASS: TestAccAWSAutoscalingPolicy_basic (82.25s)

@bflad bflad added this to the v1.57.0 milestone Jan 25, 2019
@bflad bflad requested a review from a team January 25, 2019 19:09
@ghost ghost added size/M Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/autoscaling Issues and PRs that pertain to the autoscaling service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jan 25, 2019
@bflad bflad added the bug Addresses a defect in current functionality. label Jan 25, 2019
Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

LGTM after travis passes

@bflad
Copy link
Contributor Author

bflad commented Jan 25, 2019

Ha, we even had errant unit testing in this case:

--- FAIL: TestFlattenStepAdjustments (0.00s)
    structure_test.go:820: expected metric_interval_lower_bound to be 1.0, but got %!d(string=1)

I'll correct the unit testing. 😄

…erraform state

Previously, the resource was silently failing to read this attribute and therefore unable to perform drift detection or properly import the resource (currently being added).

```
--- FAIL: TestAccAWSAutoscalingPolicy_basic (85.72s)
    testing.go:538: Step 2 error: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

        (map[string]string) {
        }

        (map[string]string) (len=4) {
         (string) (len=17) "step_adjustment.#": (string) (len=1) "1",
         (string) (len=54) "step_adjustment.2042107634.metric_interval_lower_bound": (string) (len=1) "2",
         (string) (len=54) "step_adjustment.2042107634.metric_interval_upper_bound": (string) "",
         (string) (len=45) "step_adjustment.2042107634.scaling_adjustment": (string) (len=1) "1"
        }
```

Returning the error from `d.Set()`:

```
--- FAIL: TestAccAWSAutoscalingPolicy_basic (14.03s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_autoscaling_policy.foobar_step: 1 error occurred:
        	* aws_autoscaling_policy.foobar_step: error setting step_adjustment: step_adjustment.0.metric_interval_lower_bound: '' expected type 'string', got unconvertible type 'float64'
```

Output from acceptance testing after adjustments:

```
--- PASS: TestAccAWSAutoscalingPolicy_zerovalue (44.61s)
--- PASS: TestAccAWSAutoscalingPolicy_SimpleScalingStepAdjustment (46.60s)
--- PASS: TestAccAWSAutoscalingPolicy_TargetTrack_Predefined (48.75s)
--- PASS: TestAccAWSAutoscalingPolicy_disappears (72.73s)
--- PASS: TestAccAWSAutoscalingPolicy_TargetTrack_Custom (74.47s)
--- PASS: TestAccAWSAutoscalingPolicy_upgrade (76.43s)
--- PASS: TestAccAWSAutoscalingPolicy_basic (82.25s)
```
@bflad bflad force-pushed the kterada0509-feature/add-support-autoscaling-policy-import branch from 5fd80c1 to 75bb031 Compare January 25, 2019 19:23
@bflad bflad merged commit 141f39d into master Jan 25, 2019
@bflad bflad deleted the kterada0509-feature/add-support-autoscaling-policy-import branch January 25, 2019 19:47
bflad added a commit that referenced this pull request Jan 25, 2019
@bflad
Copy link
Contributor Author

bflad commented Jan 26, 2019

This has been released in version 1.57.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 1, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
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. documentation Introduces or discusses updates to documentation. service/autoscaling Issues and PRs that pertain to the autoscaling service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants