-
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_sfn_state_machine: Support Update State machine call #2349
resource/aws_sfn_state_machine: Support Update State machine call #2349
Conversation
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.
Hi @Puneeth-n
As asked, just left a few comments to address before getting this merged in! :)
Thanks for the work! 🙂 🚀
@@ -125,6 +124,32 @@ func resourceAwsSfnStateMachineRead(d *schema.ResourceData, meta interface{}) er | |||
return nil | |||
} | |||
|
|||
func resourceAwsSfnStateMachineUpdate(d *schema.ResourceData, meta interface{}) error { | |||
conn := meta.(*AWSClient).sfnconn | |||
log.Printf("[DEBUG] Updating Step Function State Machine: %s", d.Id()) |
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.
Can you move this one before 137 and log the overall params
structure? as in:
log.Printf("[DEBUG] Updating Step Function State Machine: %#v", params)
if err != nil { | ||
|
||
if awserr, ok := err.(awserr.Error); ok { | ||
if awserr.Code() == "NotFoundException" || awserr.Code() == "StateMachineDoesNotExist" { |
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.
Can you change the 2 above line for something like:
if isAWSErr(err, "StateMachineDoesNotExist", "something") {
...
}
In place of something
, you should write something that is sent back by the AWS API. This parameter is used by the function to check whether err.Message()
contains the string you are passing.
if awserr, ok := err.(awserr.Error); ok { | ||
if awserr.Code() == "NotFoundException" || awserr.Code() == "StateMachineDoesNotExist" { | ||
d.SetId("") | ||
return nil |
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.
In place of these 2 lines, it would be preferable to return an error, as in:
return fmt.Errorf("Error updating Step Function State Machine: %s", err)
Setting an ID to empty removes it from the state, step done by the Read part, always happening before updating/deleting
fb716b7
to
23fe7ea
Compare
@Ninir done :) |
Could you add an acceptance test with 2 steps (one for creation, the other one for update)? thanks :) |
23fe7ea
to
f55d3f8
Compare
@Ninir I am not sure how I can check the
|
f55d3f8
to
5010a1d
Compare
5010a1d
to
6c763c1
Compare
@Puneeth-n We could store the output and use it afterwards, as in https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/resource_aws_flow_log_test.go#L15-L29 We could then check if the ID changed, and hash the structure to ensure that the content changed too. Thoughts? |
@Ninir I used regex to check the output. after the state machine was updated. what do you think about it? |
@Puneeth-n Depending on the regex written, this could be sufficient, nice idea :) |
@Ninir I have already included it in the Acceptance tests. Let me know if you want any changes. |
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.
Hey @Puneeth-n
This looks very good to me :)
make testacc TEST=./aws TESTARGS='-run=TestAccAWSSfnStateMachine_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSSfnStateMachine_ -timeout 120m
=== RUN TestAccAWSSfnStateMachine_createUpdate
--- PASS: TestAccAWSSfnStateMachine_createUpdate (53.01s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 53.054s
Thanks a lot for the work and reactivity! 🚀 😄
@Ninir Thanks a lot :) Wanted to get this feature into mainline so that we can get rid of our fork. :) |
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! |
Resolves #2341
requires #2344 to be merged first