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

Feature discussion: update preview #44

Closed
thorstenhuhn opened this issue May 9, 2020 · 3 comments
Closed

Feature discussion: update preview #44

thorstenhuhn opened this issue May 9, 2020 · 3 comments

Comments

@thorstenhuhn
Copy link
Contributor

What I like about the AWS Web Console is the preview of changes before finally updating the stack. To get something similar using qaz, I have currently defined an alias function (zsh):

qaz-preview() {
  stack=$1
  answer=
  qaz change create update -s $stack && \
    qaz change desc update -s $stack && \
    vared -p "Apply changes? " answer
  case "$answer" in
    [Yy])
      qaz change execute update -s $stack
      ;;
    *)
      echo "Aborting."
      qaz change rm update -s $stack
      ;;
  esac
}

It creates a change set called "update", describes it and finally asks whether to proceed or not without leaving any artifacts.

I could try to implement this in qaz, as this seems a pretty convenient workflow for me, but there might also be advantages keeping the logic "outside" like this. Options might be to grep the description for replacement: "True" or to count the number of resources to be changed to print a summary before asking to proceed to emphasize on the complexity of the change. Of course this could also easily be implemented internally, but the question is what makes more sense.

For the internal implementation I would see at least two different ways:
a) extending the existing change command with a new subcommand, like qaz change workflow -s <stack>
b) adding an option to the update command, like qaz update -i <stack> with -i for "interactive" update (-p for "preview" might overlap with existing profile option)

@daidokoro
Copy link
Owner

daidokoro commented May 9, 2020

Hey @thorstenhuhn

So I believe the feature you're looking for is implemented in the qaz shell mode. It's not documented but, the qaz update command functions differently when called in shell mode. In shell mode a change-set is created, the changes are presented and the user has the option to proceed or cancel.

We should then be able to take the shell mode implementation and replicate it in the update command. Option (b) feels like a good fit, utilising an --interactive/-i flag. I think that one fits the paradigm more closely.

Shell-Mode Updata command example:

Qaz Shell Mode
--
Try "help" for a list of commands

@ qaz:(state-machine-testing) ✗ ls
example
@ qaz:(state-machine-testing) ✗ update example
info: creating change-set: [state-machine-testing-example-change-5577006791947779410] - state-machine-testing-example
info: created change-set: [state-machine-testing-example-change-5577006791947779410] - create_complete - state-machine-testing-example
- resourcechange:
    action: Modify
    details:
    - causingentity: null
      changesource: DirectModification
      evaluation: Static
      target:
        attribute: Properties
        name: Timeout
        requiresrecreation: Never
    logicalresourceid: LambdaFunction
    physicalresourceid: state-machine-testing-example-LambdaFunction-1P3TK0WWM83Q5
    replacement: "False"
    resourcetype: AWS::Lambda::Function
    scope:
    - Properties
  type: Resource
- resourcechange:
    action: Modify
    details:
    - causingentity: LambdaFunction.Arn
      changesource: ResourceAttribute
      evaluation: Dynamic
      target:
        attribute: Properties
        name: DefinitionString
        requiresrecreation: Conditionally
    logicalresourceid: StateMachine
    physicalresourceid: arn:aws:states:eu-west-1:091066890486:stateMachine:StateMachine-iePWxwWG0FZn
    replacement: Conditional
    resourcetype: AWS::StepFunctions::StateMachine
    scope:
    - Properties
  type: Resource
--
The above will be updated, do you want to proceed? [Y/N]:

Let me know what you think.

@thorstenhuhn
Copy link
Contributor Author

That sounds reasonable. Shall I give it a try or would you prefer fixing it in personal?

@daidokoro
Copy link
Owner

If you're up for it, happy to review a pull request, won't have the chance to look at this personally this weekend.

You should be able to copy over the logic from the shell update command and make some minor changes.

Alternatively, I can work on it, some time next week.

daidokoro added a commit that referenced this issue May 10, 2020
Added option -i,--interactive to update command (fixes #44)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants