runway: [BUG] 'runway tfenv install' broken

Bug Description

Hello,

This started happening yesterday Apr 13, 2022

We’ve tried all sort of combinations of runway/terraform/python versions and cannot seem to make this work anymore.

This is affect our CI/CD pipeline which can no longer install the version of terraform specified in the runway.yaml file because runway, i believe, is using runway tfenv to install the desired version of terraform

Any help would be greatly appreciated. Until then i’ll be creating my own “wrapper” to install the desired versions of terraform myself into the directory runway is looking for $HOME/.tfenv/versions

Thanks!


devops/tfetest|~/repos/innovyze/devops-terraform
😄-bash-⌲ runway tfenv install 1.0.0
Traceback (most recent call last):
  File "/Users/patrick.raco/.local/bin/runway", line 8, in <module>
    sys.exit(cli())
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/runway/_cli/main.py", line 33, in invoke
    return super().invoke(ctx)
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/runway/_cli/commands/_tfenv/_install.py", line 31, in install
    "terraform path: %s", TFEnvManager().install(version_requested=version)
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/runway/env_mgr/tfenv.py", line 348, in install
    if not self.version:
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/backports/cached_property/__init__.py", line 80, in __get__
    val = self.func(instance)
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/runway/env_mgr/tfenv.py", line 276, in version
    for i in get_available_tf_versions(include_prerelease_versions)
  File "/Users/patrick.raco/.local/lib/python3.7/site-packages/runway/env_mgr/tfenv.py", line 118, in get_available_tf_versions
    reverse=True,
  File "/Users/patrick.raco/.pyenv/versions/3.7.12/lib/python3.7/distutils/version.py", line 52, in __lt__
    c = self._cmp(other)
  File "/Users/patrick.raco/.pyenv/versions/3.7.12/lib/python3.7/distutils/version.py", line 337, in _cmp
    if self.version < other.version:
TypeError: '<' not supported between instances of 'str' and 'int'```

### Expected Behavior

1. run: `runway tfenv install VERSION`
2. expect specified terraform version to be installed


### Steps To Reproduce

1. install `runway`: `pip install runway [--user]`
2. make sure desired version of terraform is not installed with: `runway tfenv list`
3. try to install it: `runway tfenv install --version`

### Runway version

- 1.18.1
- 1.18.3
- 2.6.1

### Installation Type

pypi (pip, pipenv, poetry, etc)

### OS / Environment

- macos
- linux

### Anything else?

- seems to happen if/when the desired version of terraform is NOT installed
- Did notice these diffs in the installed python packages between a successful and failed run:

![image](https://user-images.githubusercontent.com/3203156/163601117-349be257-6cfc-4f1b-8b97-82237ed6bc91.png)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 16 (4 by maintainers)

Most upvoted comments

This is straying from the topic of this issue but @pataraco the issue you are referring to is not that YAML anchors are not supported its that invalid fields are no longer supported in the config file (e.g. air if not a valid field in a CFNgin or runway config file). All you need to do is define your anchors under a supported field.

Example:

deployments:
  - name: Core Infrastructure (Amazon VPC/Networking/Guardduty)
    modules:
      - path: terraform/configs/networking
        tags: [core, networking]
    module_options: &common_terraform_config
      terraform_version: 1.1.3
      terraform_backend_config:
        bucket: innovyze-${env DEPLOY_ENVIRONMENT}-${env AWS_REGION}-terraform-states
        dynamodb_table: innovyze-${env DEPLOY_ENVIRONMENT}-terraform-locks
        workspace_key_prefix: terraform-state-files  # default: 'env:'
        region: ${env AWS_REGION}
  - modules:
      - ...
    module_options:
      <<: *common_terraform_config

@sagargulabani as a workaround, i wrote something to install the required versions of terraform into the directory ($HOME/.tfenv/versions) that runway checks if it needs to install them itself using runway tfenv so it will be happy and just do the planning/deploying.