pythian / opsviz

25 stars 24 forks source link

Creation of cert in 'create_stack' fails if stack of same name was previously created #33

Closed dtest closed 9 years ago

dtest commented 9 years ago

If you use create_stack, and it fails at any point after uploading the cert, then a re-run of the script will result in the following error:

writing RSA key
Traceback (most recent call last):
  File "create_stack", line 166, in <module>
    main()
  File "create_stack", line 163, in main
    stack_creator.create_stack()
  File "create_stack", line 128, in create_stack
    self.prepare_cert()
  File "create_stack", line 72, in prepare_cert
    self.cert_arn = self.upload_cert()
  File "create_stack", line 63, in upload_cert
    private_key=self.ssl_key)
  File "/home/vagrant/.virtualenvs/opvis/lib/python2.7/site-packages/boto/iam/connection.py", line 799, in upload_server_cert
    verb='POST')
  File "/home/vagrant/.virtualenvs/opvis/lib/python2.7/site-packages/boto/iam/connection.py", line 102, in get_response
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.BotoServerError: BotoServerError: 409 Conflict
<ErrorResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
  <Error>
    <Type>Sender</Type>
    <Code>EntityAlreadyExists</Code>
    <Message>The Server Certificate with name opsvistest1_cert already exists.</Message>
  </Error>
  <RequestId>e9c7caab-b2bf-11e4-9420-5bb7c3142238</RequestId>
</ErrorResponse>

I would expect to handle this by either removing the previous one and re-attempting, or ignoring and letting it use the existing one.

jmetzmeier commented 9 years ago

We should probably add a flag to tell it remove the previous one. This failure here should be more helpful and recommend the flag to delete the existing cert or use the existing one (issue #20).