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

[Feature]: Sensible to perform integration/unit tests using PowerShell's Pester (with psake)? #27

Open
jimbrig opened this issue Mar 31, 2023 · 3 comments
Labels
feature new functionality for existing module

Comments

@jimbrig
Copy link

jimbrig commented Mar 31, 2023

Module Name

N/A

Description

Just a question here -- I was wondering if the testing code documentation restricts testing of terraform module's to just the terratest golang framework.

I have been using a combination of the following PowerShell (Core) modules lately with my Terraform projects and find it to be very fluent:

  • Az: Azure Suite of PowerShell Modules
  • Pester: Tests
  • psake: Task Runner
  • Plaster: Module templating and best practices
  • PSDepend: Dependency Management and Versioning
  • Crescendo: (Optional) Could be used to create custom wrapper utilities for classic terraform-cli commands/scenarios (for example converting terraform plan to JSON or setting up the remote-backend / service principal, etc.)
  • CredentialManager: Manage credentials and authentication
  • platyPS: Generate documentation similar to terraform-docs does (although I still prefer terraform-docs here).

Similar to how PSRule (see Validate infrastructure as code (IaC) and objects using PowerShell rules) works nicely with Bicep or ARM Templates; I feel like these PowerShell tools really integrate nicely with the Terraform infrastructure as code ecosystem, specifically for Azure infrastructural deployments.

It also is a more friendly interface to use for a typical Azure developer that is more likely used to PowerShell syntax and development over Go, especially if having to write complex tests (notice the similarities between Pester/psake/DSC syntax and Terraform configuration syntax?).

Just wanted to see if anyone had any food for thoughts on this subject - any criticism or feedback would be much appreciated.

Thanks!

  • Jimmy

Example usage

No response

Other information

No response

@jimbrig jimbrig added the feature new functionality for existing module label Mar 31, 2023
@matt-FFFFFF
Copy link
Member

Hi @jimbrig

Go is idiomatic of Terraform, historically. Due to this, I have created a fluent testing module in go, it allows code that is much more easy to read. It is built atop terratest.

See here: https://github.com/Azure/terratest-terraform-fluent

That's not to say we can't investigate other testing frameworks, but this might be worth considering.

@jimbrig
Copy link
Author

jimbrig commented May 20, 2023

@matt-FFFFFF - Awesome, thanks for that - will check it out. I'm starting to try and learn Go regardless due to the fact it teaches design patterns and best practices relevant across any language/framework.

@lonegunmanb
Copy link
Member

lonegunmanb commented May 22, 2023

Thanks @jimbrig for the suggestions! I'll take a look at the tools that you recommended.

CredentialManager: Manage credentials and authentication

We're using MSI as the authentication method, we're also considering OIDC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature new functionality for existing module
Projects
None yet
Development

No branches or pull requests

3 participants