stravze [
str...@gmail.com] wrote:
>Hello all,
>Has anyone any experience with putting terraform config's into Octopus Deploy, to build out cloud infrastructure ?
Not done this myself but have used Octopus a lot in the past.
There are a lot of ways this could be done, depending on what you are looking to achieve.
If you want Octopus to run the relevant Terraform code and copy the code to somewhere where it will be ran, the files will need to be put in a Nuget package for it to be picked up with Octopus. You can use the option in Octopus to replace variables in files, and put in the files you want to be replaced. For example, in my code I have modules that use variables in a file, so you could do something like this:
module "dev" {
source = "./environment"
vpc_network = "#{VPC_Network}"
management_password = "#{Management_Password}"
}
Those variables will be replaced as part of the deployment process by the tentacle before the deployment script gets ran.
I would then put the relevant Terraform commands into a Powershell deploy.ps1 script, this can either be in the Nuget package itself or in Octopus using the scripts feature. This would call Terraform on the machine that is being deployed to from Octopus's point of view. The script should deal with the state file, and also doing Terraform get if necessary. You should probably look at calling out the Octopus variables for the environment etc, so that the relevant environment is manipulated and matches what is seen in Octopus.
These are just some initial thoughts.
Best,
Andrew.