-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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_msk_configuration: Implement Update and Delete support #14826
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,38 @@ | ||
package waiter | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/kafka" | ||
"github.com/hashicorp/aws-sdk-go-base/tfawserr" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
const ( | ||
ConfigurationStateDeleted = "Deleted" | ||
ConfigurationStateUnknown = "Unknown" | ||
) | ||
|
||
// ConfigurationState fetches the Operation and its Status | ||
func ConfigurationState(conn *kafka.Kafka, arn string) resource.StateRefreshFunc { | ||
return func() (interface{}, string, error) { | ||
input := &kafka.DescribeConfigurationInput{ | ||
Arn: aws.String(arn), | ||
} | ||
|
||
output, err := conn.DescribeConfiguration(input) | ||
|
||
if tfawserr.ErrMessageContains(err, kafka.ErrCodeBadRequestException, "Configuration ARN does not exist") { | ||
return output, ConfigurationStateDeleted, nil | ||
} | ||
|
||
if err != nil { | ||
return output, ConfigurationStateUnknown, err | ||
} | ||
|
||
if output == nil { | ||
return output, ConfigurationStateUnknown, nil | ||
} | ||
|
||
return output, aws.StringValue(output.State), 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package waiter | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/service/kafka" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
const ( | ||
// Maximum amount of time to wait for an Configuration to return Deleted | ||
ConfigurationDeletedTimeout = 5 * time.Minute | ||
) | ||
|
||
// ConfigurationDeleted waits for an Configuration to return Deleted | ||
func ConfigurationDeleted(conn *kafka.Kafka, arn string) (*kafka.DescribeConfigurationOutput, error) { | ||
stateConf := &resource.StateChangeConf{ | ||
Pending: []string{kafka.ConfigurationStateDeleting}, | ||
Target: []string{ConfigurationStateDeleted}, | ||
Refresh: ConfigurationState(conn, arn), | ||
Timeout: ConfigurationDeletedTimeout, | ||
} | ||
|
||
outputRaw, err := stateConf.WaitForState() | ||
|
||
if output, ok := outputRaw.(*kafka.DescribeConfigurationOutput); ok { | ||
return output, err | ||
} | ||
|
||
return nil, err | ||
} |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure the likelihood of catching a configuration in a
deleting
state at this point, but just curious if we should check the state here as well since the docs forDeleteConfiguration
note the configuration must be in either theactive
ordelete_failed
state?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is certainly in the realm of possibility (albeit very unlikely as these seem to delete very fast currently)! Rather than handling it just in our testing code, it would be something that should be handled in the resource
Delete
function. We won't be able to really test it, but let me see if I can grab the specific error via the AWS CLI.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's what I got with quickly doing
aws kafka delete-configuration
:I was hoping it would either have a more specific error code for this situation or include
DELETING
in the error message so we could safely skip it, but given the way this error is setup they could add other state values for configurations which we should always return the error instead of skipping it. 🙁 I think we'll want to leave this edge case in there for now unless it does become a real problem for practitioners or our sweepers.