Skip to content

Deploy off aws cli - #1455

Merged
sriram-mv merged 18 commits into
aws:release-v0.32.0from
sriram-mv:deploy_off_aws_cli
Nov 13, 2019
Merged

sriram-mv merged 18 commits into
aws:release-v0.32.0from
sriram-mv:deploy_off_aws_cli

Conversation

@sriram-mv

@sriram-mv sriram-mv commented Oct 9, 2019 •

Copy link
Copy Markdown
Contributor
  • Clean output of stack events as deploy progress

  • Clean output of changeset before beginning the deploy process

  • Port from AWS CLI

  • Unit tests added

  • Integration tests added

  • Regression tests added

  • Write Design Document (Do I need to write a design document?)

  • Write unit tests

  • Write/update functional tests

  • Write/update integration tests

  • make pr passes

  • Write documentation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This was referenced Oct 18, 2019
@sriram-mv

Copy link
Copy Markdown
Contributor Author

The number of commits appear huge, but thats because this is based off sam package PR: #1437

This is still very much in WIP.

Comment thread samcli/lib/deploy/deployer.py Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

click based decorator to create a table.

- Not breaking parameter overrides formats
- still requires refactoring and error handling
- wire up command.py for `sam deploy`
- move deploy specific exceptions to inherit from UserException
- `sam deploy` now has tables while showcasing the changeset and
  showcasing events happening during deploy.
- fixed unit tests
- linting fixes
- doc strings
- further unit tests and integration tests need to be added.
@sriram-mv sriram-mv changed the title [WIP] : Deploy off aws cli Deploy off aws cli Nov 7, 2019
Comment thread samcli/cli/types.py Resolved
value = [value]

while state.rargs and not next_option:
for prefix in self._nargs_parser.prefixes:

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.

Do we have or intend to support any commands where there is a trailing argument that does not have a prefix?

For example, many CLIs have a valid command that works much like the following:

cli commandname --option-one A --option-set B C D --input inputfile.txt outputfile.txt

(Where outputfile.txt is a positional argument that goes at the end of the full command.)

This code would appear to assume we never allow for that pattern. Is this a correct assumption for us?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, one way to codify that would be to add such positional argument to the front of the command. I'm not sure if there are alternate ways to check for unbounded number of arguments for a given option without a breaking change though.

Comment thread samcli/commands/deploy/command.py Outdated
"change set. Specify this flag if you want to view your stack changes"
"before executing the change set. The command creates an AWS CloudForma-"
"tion change set and then exits without executing the change set. After"
"you view the change set, execute it to implement your changes.",

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.

Execute it how? We should make that clear somewhere, probably here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will clarify this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread samcli/lib/deploy/deployer.py Outdated
"""
try:
resp = self._client.describe_stacks(StackName=stack_name)
if len(resp["Stacks"]) != 1:

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.

I'd actually check that this is equal to zero.

I believe (could be wrong) that certain situations and inputs can lead this number to be greater than one. At the very least, the API documentation lists this as a possibility.

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.

I'm looking at this as a defensive programming POV - I don't think the logic below needs to change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed.

@sriram-mv

Copy link
Copy Markdown
Contributor Author

@awood45 addressed your comments.

@jfuss jfuss added area/deploy sam deploy command type/feature Feature request labels Nov 12, 2019

@awood45 awood45 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.

One comment to verify before merging.

try:
resp = self._client.describe_stacks(StackName=stack_name)
if len(resp["Stacks"]) != 1:
if not resp["Stacks"]:

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.

Does this handle an empty array?

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.

Actually, better question, can we ensure that we test the case of no such stack? Just to be sure for regressions.

self.assertEqual(self.deployer._client, self.cloudformation_client)
self.assertEqual(self.deployer.changeset_prefix, "samcli-cloudformation-package-deploy-")

def test_deployer_has_no_stack(self):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of such a test, @awood45

@sanathkr sanathkr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most comments are minor, something to think about. Just make sure the table formatting doesn't lead to zeros or infinities or crashes. We don't want deploy to crash because of the table print.

Comment thread samcli/lib/deploy/deployer.py Resolved
Comment thread samcli/lib/deploy/deployer.py Resolved
Comment thread samcli/lib/deploy/deployer.py Outdated
try:
outputs = stacks_description["Stacks"][0]["Outputs"]
if echo:
click.secho("\nStack {stack_name} outputs:\n".format(stack_name=stack_name))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you not use click in this layer? It adds a dependency on click for this module to function. It makes the code less portable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread samcli/lib/deploy/deployer.py Resolved
Comment thread samcli/lib/deploy/deployer.py Resolved
usable_width_no_margin = int(width) - 1
usable_width = int((usable_width_no_margin - (margin if margin else min_margin)))

width_per_column = int(usable_width / total_args)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Can this be zero?
  • Can this be infinity?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added ValueError if so.

Comment thread samcli/commands/_utils/table_print.py Resolved
Comment thread samcli/commands/_utils/table_print.py Resolved
Comment thread samcli/lib/deploy/deployer.py Resolved
Comment thread samcli/lib/deploy/deployer.py Resolved
- add retries
- more regression testing
- remove types for capabilities

@sanathkr sanathkr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making the changes. This looks good to me.

def wait_for_execute(self, stack_name, changeset_type):

click.secho("\nWaiting for stack create/update to complete\n")
sys.stdout.write("\nWaiting for stack create/update to complete\n")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure these are written to stdout in AWS CLI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 add flushes

- show cases Add, Modify, Delete with +, * and -
@sriram-mv
sriram-mv changed the base branch from develop to release-v0.32.0 November 13, 2019 18:56
@sriram-mv
sriram-mv merged commit d51d6f7 into aws:release-v0.32.0 Nov 13, 2019
sriram-mv added a commit that referenced this pull request Nov 20, 2019
* feat: sam deploy without aws cli pre-installed

- Not breaking parameter overrides formats
- still requires refactoring and error handling

* feat: new click types for deploy parameters

* feat: show changeset and stack events

- needs refactoring

* refactor: move deploy classes to lib

- wire up command.py for `sam deploy`
- move deploy specific exceptions to inherit from UserException

* rebase: latest from `sam package` port

* feat: decorator for printing tables

- `sam deploy` now has tables while showcasing the changeset and
  showcasing events happening during deploy.

* fix: wrap text on resource status column on `sam deploy`

- fixed unit tests
- linting fixes
- doc strings
- further unit tests and integration tests need to be added.

* fix: cleaner text formatting for tables

* tests: add unit tests for full suite of `sam deploy`

* tests: add integration tests for `sam deploy`

* tests: regression test suite for `sam deploy`

- exercise all command line parameters for `aws` and `sam`

* fix: deploy command now showcases stack outputs

* fix: address comments

* fix: return stack outputs from `get_stack_outputs`

* fix: width margins on table prints

* fix: address comments

- add retries
- more regression testing
- remove types for capabilities

* tests: tests for pprint of tables

* usability: add table headers

- show cases Add, Modify, Delete with +, * and -
sriram-mv added a commit that referenced this pull request Nov 23, 2019
* feat: sam deploy without aws cli pre-installed

- Not breaking parameter overrides formats
- still requires refactoring and error handling

* feat: new click types for deploy parameters

* feat: show changeset and stack events

- needs refactoring

* refactor: move deploy classes to lib

- wire up command.py for `sam deploy`
- move deploy specific exceptions to inherit from UserException

* rebase: latest from `sam package` port

* feat: decorator for printing tables

- `sam deploy` now has tables while showcasing the changeset and
  showcasing events happening during deploy.

* fix: wrap text on resource status column on `sam deploy`

- fixed unit tests
- linting fixes
- doc strings
- further unit tests and integration tests need to be added.

* fix: cleaner text formatting for tables

* tests: add unit tests for full suite of `sam deploy`

* tests: add integration tests for `sam deploy`

* tests: regression test suite for `sam deploy`

- exercise all command line parameters for `aws` and `sam`

* fix: deploy command now showcases stack outputs

* fix: address comments

* fix: return stack outputs from `get_stack_outputs`

* fix: width margins on table prints

* fix: address comments

- add retries
- more regression testing
- remove types for capabilities

* tests: tests for pprint of tables

* usability: add table headers

- show cases Add, Modify, Delete with +, * and -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/deploy sam deploy command type/feature Feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants