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

Validate the template against aws before stack creation #485

Merged
merged 3 commits into from
May 27, 2016
Merged

Validate the template against aws before stack creation #485

merged 3 commits into from
May 27, 2016

Conversation

chrisgilmerproj
Copy link
Contributor

Working with @markfalk discovered its helpful to have AWS validate the template before stack creation. This change includes these updates while maintaining backwards compatibility:

  • Can now use -u or --update to trigger a cfn update action instead of a create action
  • Fixes pep8 trailing whitespace
  • Fixes pep8 line length to be < 80 chars

@chrisgilmerproj
Copy link
Contributor Author

Friendly ping - Hoping to get a review on this PR.

(literal_eval(e.error_message)['Error']['Message'],))
print("Exiting...")
sys.exit(1)
print("Template Validated")
Copy link
Contributor

@rcuza rcuza May 25, 2016

Choose a reason for hiding this comment

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

What happens if both template and url are None? Wont this return "Template Validated"? This does not seem like a desired result.

What about returning True or False? It would make the function more flexible. The code that calls it could then decide what to do in either case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like these ideas, I'll update this and get it back to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anything that validates returns a boto.cloudformation.template.Template object. If it does not validate it will throw an error:

BotoServerError: BotoServerError: 400 Bad Request
<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
  <Error>
    <Type>Sender</Type>
    <Code>ValidationError</Code>
    <Message>Template format error: unsupported type or structure. (line 2, column 5)</Message>
  </Error>
  <RequestId>aacaaf5b-2442-11e6-96bc-4793db5d2621</RequestId>
</ErrorResponse>

The style of this script is that any error causes a fault. We could cause this method to return True or False, but it steps away from the style of the other methods. Your call, I'm happy to implement either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, I just updated to cause an error if neither url or template are provided.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point about not wanting to loose the error message.

Out of scope for this PR, but there is something wrong with the way the logging feature and print is used in this script over all, but I'm not sure what it is.

@rcuza
Copy link
Contributor

rcuza commented May 27, 2016

These changes LGTM. 👍

Please note, that I did not run the script to test it. Just looked at the changes.

@chrisgilmerproj
Copy link
Contributor Author

Fantastic. I can't merge this so I'll leave it up to your team to do so. Thanks for the review!

@markpeek markpeek merged commit 7bf2c74 into cloudtools:master May 27, 2016
@markpeek
Copy link
Member

Thanks for the PR!

@rcuza thanks for the code review feedback

amosshapira pushed a commit to amosshapira/troposphere that referenced this pull request Oct 24, 2016
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

Successfully merging this pull request may close these issues.

3 participants