Hello,
I have updated the terraform module from 0.13.2 to 0.14.11 and also make my .hcl lock file compatible for all the enviroment so that it will work for all types of machine we have in our organisation like Linux and MacOS.
I have executed that on MacOS it works fine, I would like to test for Linux as well before commit that file.
Kindly let me know way to test this before checkin and deploy to linux machine. So that I am sure 100% when I will checkin my file and try to run with CI/CD automated way with Linux environment it will work fine.
Cheers !
Hi @Snehil03,
I think what you are asking here is how you might verify that a Terraform configuration works on Linux without having access to a Linux system.
Unfortunately I don’t really have any answer to suggest here: in order to offer something like that, Terraform would need to include some way to emulate a full Linux execution environment on macOS, which is far outside of Terraform’s scope.
Instead, I would suggest considering typical solutions to this that are agnostic to what software you are running, such as Docker for Mac.
Another way to go could be to integrate some checks into your code review pipeline; if your primary concern is about whether the lock file is correctly populated then running terraform init
on each of your target operating systems should be sufficient to verify that, without the need for any subsequent action, although once you’ve set that up it could be useful to also run terraform validate
to catch situations where the configuration is invalid in some way.
Thanks @apparentlymart i tested it via docker for mac.
Is there any way where I can use these command in a automated way, rather than executing manually command and check in the file generated to git ?
may be a flag as part of terraform init ?
Hi @Snehil03,
I’m not sure I fully understand what you are asking, but if you are suggesting that terraform init
should run Docker then I think that seems the opposite of what I would expect: typically we run Terraform with Docker, not run Docker with Terraform. I doubt we would add any features to Terraform Core that specifically interact with a Docker daemon, because that sort of thing is outside of Terraform’s scope and is a matter for the execution environment you’re running Terraform in, not for Terraform itself.
If you’ve successfully run Terraform manually in a Docker container though, I expect you could get a similar result by automating exactly what you did using a wrapper script. That is the approach I would typically expect to see for automated checks that would run prior to merging a change.