putting Terraform into Octopus Deploy

301 views
Skip to first unread message

stravze

unread,
Jul 6, 2016, 7:05:49 AM7/6/16
to Terraform
Hello all,

Has anyone any experience with putting terraform config's into Octopus Deploy, to build out cloud infrastructure ?

Can you put the variables into Octopus and Terraform will pick up those variables ? or does terraform require the variables in a file in the same directory ?

Any advise would be great

many thanks

stravze

Andrew Hodgson

unread,
Jul 6, 2016, 8:26:28 AM7/6/16
to terrafo...@googlegroups.com
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.

stravze

unread,
Jul 8, 2016, 5:33:54 AM7/8/16
to Terraform
Excellent thank you
Reply all
Reply to author
Forward
0 new messages