-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
r/aws_instance: Set new computed value for
public_dns
and `public_i…
…p` attributes when changing `instance_type`, `user_data`, or `user_data_base64`.
- Loading branch information
Showing
5 changed files
with
242 additions
and
106 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,3 @@ | ||
```release-note:bug | ||
resource/aws_instance: Set new computed value for `public_dns` and `public_ip` attributes when changing `instance_type`, `user_data`, or `user_data_base64` | ||
``` |
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,48 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package statecheck | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/knownvalue" | ||
"github.com/hashicorp/terraform-plugin-testing/statecheck" | ||
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath" | ||
) | ||
|
||
type expectNotKnownValueCheck struct { | ||
base Base | ||
attributePath tfjsonpath.Path | ||
notValue knownvalue.Check | ||
} | ||
|
||
func (e expectNotKnownValueCheck) CheckState(ctx context.Context, request statecheck.CheckStateRequest, response *statecheck.CheckStateResponse) { | ||
resource, ok := e.base.ResourceFromState(request, response) | ||
if !ok { | ||
return | ||
} | ||
|
||
value, err := tfjsonpath.Traverse(resource.AttributeValues, e.attributePath) | ||
if err != nil { | ||
response.Error = err | ||
|
||
return | ||
} | ||
|
||
err = e.notValue.CheckValue(value) | ||
if err == nil { | ||
response.Error = fmt.Errorf("value for attribute at path: %s.%s is %v", resource.Address, e.attributePath.String(), value) | ||
|
||
return | ||
} | ||
} | ||
|
||
func ExpectNotKnownValue(resourceAddress string, attributePath tfjsonpath.Path, notValue knownvalue.Check) statecheck.StateCheck { | ||
return expectNotKnownValueCheck{ | ||
base: NewBase(resourceAddress), | ||
attributePath: attributePath, | ||
notValue: notValue, | ||
} | ||
} |
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
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.