Skip to content

resource/aws_sfn_state_machine: Support Update State machine call#2349

Merged
Ninir merged 1 commit into
hashicorp:masterfrom
Puneeth-n:chore/aws-sfn-update-state-machine
Nov 22, 2017
Merged

resource/aws_sfn_state_machine: Support Update State machine call#2349
Ninir merged 1 commit into
hashicorp:masterfrom
Puneeth-n:chore/aws-sfn-update-state-machine

Conversation

@Puneeth-n

Copy link
Copy Markdown
Contributor

Resolves #2341

requires #2344 to be merged first

@Ninir Ninir added the enhancement Requests to existing resources that expand the functionality or scope. label Nov 20, 2017
@Ninir Ninir changed the title support Update State machine call resource/aws_sfn_state_machine: Support Update State machine call Nov 20, 2017

@Ninir Ninir left a comment

Copy link
Copy Markdown
Contributor

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! 🙂 🚀

Comment thread aws/resource_aws_sfn_state_machine.go Outdated

Copy link
Copy Markdown
Contributor

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)

Comment thread aws/resource_aws_sfn_state_machine.go Outdated

Copy link
Copy Markdown
Contributor

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.

Comment thread aws/resource_aws_sfn_state_machine.go Outdated

Copy link
Copy Markdown
Contributor

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

@Puneeth-n Puneeth-n force-pushed the chore/aws-sfn-update-state-machine branch from fb716b7 to 23fe7ea Compare November 21, 2017 10:37
@Puneeth-n

Copy link
Copy Markdown
Contributor Author

@Ninir done :)

@Ninir

Ninir commented Nov 21, 2017

Copy link
Copy Markdown
Contributor

Could you add an acceptance test with 2 steps (one for creation, the other one for update)? thanks :)

@Puneeth-n Puneeth-n force-pushed the chore/aws-sfn-update-state-machine branch from 23fe7ea to f55d3f8 Compare November 21, 2017 17:48
@Puneeth-n

Copy link
Copy Markdown
Contributor Author

@Ninir I am not sure how I can check the sfn definition changes in the acceptance tests.

root@5f4b89633452:/go/src/github.com/terraform-providers/terraform-provider-aws# make testacc TESTARGS='-run=TestAccAWSSfnStateMachine_createUpdate'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccAWSSfnStateMachine_createUpdate -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAWSSfnStateMachine_createUpdate
--- PASS: TestAccAWSSfnStateMachine_createUpdate (84.16s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	84.182s

@Puneeth-n Puneeth-n force-pushed the chore/aws-sfn-update-state-machine branch from f55d3f8 to 5010a1d Compare November 21, 2017 17:50
@Puneeth-n Puneeth-n force-pushed the chore/aws-sfn-update-state-machine branch from 5010a1d to 6c763c1 Compare November 21, 2017 19:13
@Ninir

Ninir commented Nov 21, 2017

Copy link
Copy Markdown
Contributor

@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?

@Puneeth-n

Puneeth-n commented Nov 21, 2017

Copy link
Copy Markdown
Contributor Author

@Ninir I used regex to check the output. after the state machine was updated. what do you think about it?

@Ninir

Ninir commented Nov 21, 2017

Copy link
Copy Markdown
Contributor

@Puneeth-n Depending on the regex written, this could be sufficient, nice idea :)

@Puneeth-n

Copy link
Copy Markdown
Contributor Author

@Ninir I have already included it in the Acceptance tests. Let me know if you want any changes.

@Ninir Ninir left a comment

Copy link
Copy Markdown
Contributor

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 Ninir merged commit f416a86 into hashicorp:master Nov 22, 2017
@Puneeth-n

Copy link
Copy Markdown
Contributor Author

@Ninir Thanks a lot :) Wanted to get this feature into mainline so that we can get rid of our fork. :)

@Puneeth-n Puneeth-n deleted the chore/aws-sfn-update-state-machine branch November 30, 2017 20:33
@ghost

ghost commented Apr 10, 2020

Copy link
Copy Markdown

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 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement Requests to existing resources that expand the functionality or scope.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Step function update state machine

2 participants