keilerkonzept / terraform-module-versions

CLI tool that checks Terraform code for module updates. Single binary, no dependencies. linux, osx, windows. #golang #cli #terraform
MIT License
188 stars 28 forks source link

feat: Add optional sed statements generation #65

Closed favoretti closed 2 years ago

favoretti commented 2 years ago

Added a -sed option to check to generate sed statements to upgrade to the latest version.

Example output:

emporio-terraform/nonprod git:(vlazarenko/module_updates) $ terraform-module-versions check -sed .
| UPDATE? |          NAME           | CONSTRAINT | VERSION | LATEST MATCHING | LATEST |
|---------|-------------------------|------------|---------|-----------------|--------|
| (Y)     | emporio_apis            |            | v1.2.0  |                 | v2.0.0 |
| (Y)     | emporio_external        |            | v1.2.0  |                 | v2.0.0 |
| (Y)     | emporio_customer_ad_app |            | v1.2.0  |                 | v2.0.0 |

To upgrade modules to the latest version, run the following commands:

gsed -i 's#git::git@ssh.dev.azure.com:v3/xxx/azure/terraform-azuread-sp?ref=v1.2.0#git::git@ssh.dev.azure.com:v3/xxx/azure/terraform-azuread-sp?ref=v2.0.0#g' aad_apps.tf
gsed -i 's#git::git@ssh.dev.azure.com:v3/xxx/azure/terraform-azuread-sp?ref=v1.2.0#git::git@ssh.dev.azure.com:v3/xxx/azure/terraform-azuread-sp?ref=v2.0.0#g' aad_apps.tf
gsed -i 's#git::git@ssh.dev.azure.com:v3/xxx/azure/terraform-azuread-sp?ref=v1.2.0#git::git@ssh.dev.azure.com:v3/xxx/azure/terraform-azuread-sp?ref=v2.0.0#g' emporio-b2c-ad-apps.tf
sgreben commented 2 years ago

cool idea, thanks! i'll fix the conflict & merge :)

favoretti commented 2 years ago

@sgreben thanks! Interesting that there are conflicts. Built just fine locally.

sgreben commented 2 years ago

@favoretti those aren't your fault - it's due to the other PRs i just merged :)

sgreben commented 2 years ago

fixing the CI right now, should have it all released in a minute

sgreben commented 2 years ago

ah, and i really meant "merge conflicts" above - the failing check is because the CI action was broken (hub can't* be installed via go get anymore)

*reliably, it seems. now it just works with the old pipeline as well 🤷

sgreben commented 2 years ago

released now: https://github.com/keilerkonzept/terraform-module-versions/releases/tag/3.0.28

favoretti commented 2 years ago

Thank you!