Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Commit

Permalink
fixes #6 - require Terraform >= 0.6.16 as we need hashicorp/terraform…
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Aug 6, 2016
1 parent 242fa08 commit a36651e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Requirements
* An Amazon AWS account to run this all in (note - it will probably be cheap, but not free)
* Python 2.7+ (currently tested with 2.7, 3.3, 3.4, 3.5). Note that AWS Lambda currently only supports python 2.7 as an execution environment, but you're welcome to use other versions on the machine where you run this project.
* Python `VirtualEnv <http://www.virtualenv.org/>`_ and ``pip`` (recommended installation method; your OS/distribution should have packages for these)
* `HashiCorp Terraform <https://www.terraform.io/>`_ to manage the AWS infrastructure, if desired. Terraform is written in Go, and `distributed <https://www.terraform.io/downloads.html>`_ as a static binary.
* `HashiCorp Terraform <https://www.terraform.io/>`_ >= 0.6.16 to manage the AWS infrastructure, if desired. Terraform is written in Go, and `distributed <https://www.terraform.io/downloads.html>`_ as a static binary.

Architecture
------------
Expand Down
14 changes: 8 additions & 6 deletions webhook2lambda2sqs/terraform_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,19 @@ def _validate(self):
if res is None:
logger.error('Unable to determine terraform version; will not '
'validate config. Note that this may cause problems '
'when using older Terraform versions.')
'when using older Terraform versions. This program '
'requires Terraform >= 0.6.16.')
return
self.tf_version = (
int(res.group(1)), int(res.group(2)), int(res.group(3))
)
logger.debug('Terraform version: %s', self.tf_version)
if self.tf_version < (0, 6, 12):
logger.warning('Terraform config validation requires terraform '
'>= 0.6.12, but you are running %s. Config '
'validation will not be performed', self.tf_version)
return
if self.tf_version < (0, 6, 16):
raise Exception('This program requires Terraform >= 0.6.16, as '
'that version introduces a bug fix for working '
'with api_gateway_integration_response resources; '
'see: https://github.com/hashicorp/terraform/pull'
'/5893')
try:
self._run_tf('validate', ['.'])
except:
Expand Down
22 changes: 12 additions & 10 deletions webhook2lambda2sqs/tests/test_terraform_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ def se_run(*args, **kwargs):
assert mock_logger.mock_calls == [
call.error('Unable to determine terraform version; will not '
'validate config. Note that this may cause problems '
'when using older Terraform versions.')
'when using older Terraform versions. This program '
'requires Terraform >= 0.6.16.')
]

def test_validate_old_version(self):
Expand All @@ -482,16 +483,17 @@ def se_run(*args, **kwargs):
with patch('%s._run_tf' % pb, autospec=True) as mock_run:
mock_run.side_effect = se_run
with patch('%s.logger' % pbm) as mock_logger:
cls = TerraformRunner(self.mock_config(), 'terraform-bin')
with pytest.raises(Exception) as excinfo:
TerraformRunner(self.mock_config(), 'terraform-bin')
assert mock_logger.mock_calls == [
call.debug('Terraform version: %s', (0, 6, 3)),
call.warning('Terraform config validation requires terraform '
'>= 0.6.12, but you are running %s. Config '
'validation will not be performed', (0, 6, 3))
]
assert mock_run.mock_calls == [
call(cls, 'version')
]
call.debug('Terraform version: %s', (0, 6, 3))
]
assert exc_msg(excinfo.value) == 'This program requires Terraform >= ' \
'0.6.16, as that version introduces ' \
'a bug fix for working with api_' \
'gateway_integration_response ' \
'resources; see: https://github.com/' \
'hashicorp/terraform/pull/5893'

def test_validate_fail(self):
def se_run(*args, **kwargs):
Expand Down

0 comments on commit a36651e

Please sign in to comment.