Use Existing Terraform workspace functionality

Community Alums
Not applicable

Hello Experts,

I have observed below while doing POC on CPG using terraform connector:

Expectations of the “use existing workspace”

  1. Ability to deploy multiple stacks from the same catalog item into a single TFE workspace.

 

Challenge

  1. In testing we have found that the second catalog item to deploy into an existing workspace, terminates and destroys the first catalog item's provisioned resource. The third, destroys the second, the end result only one stack can be deployed to a workspace at any one point in time. Thus a 1-1 relationship between stack and workspace.

As we know Terraform Enterprise is licensed per workspace so the incentive / requirement is to reduce the number of workspaces we require. But above scenario doesn't help . Is this really how the ServiceNow  design is or i am missing something? 

Appreciate any help around this.

Best Regards,

Vishwajeet Anand

 

1 ACCEPTED SOLUTION

Ram Devanathan1
ServiceNow Employee
ServiceNow Employee

Deletion of resources/over-write is controlled by Terraform. if the state file is retained and you are applying the new configuration on top (while also having existing config) then the old resources would not go.

 

if you are using entirely new config and applying it, Terraform being declarative will keep only the resources defined in current template.

 

e.g. i have a terraform config to deploy VM with 1 disk, network card, and i run this through CPG catalog request - this creates the resources and saves the state file with the resource (VM, 1 disk, network card). now the devops team modifies the terraform config and *adds* 1 more disk to the config. then you can update the catalog item via IaC discovery and change task. with new catalog item, you can choose existing workspace and now it will deploy the config, but it will not remove existing resources as these are already in state file.

 

btw - you can try the same steps outside of cpg workflow - you will get same result.

 

Ram

View solution in original post

6 REPLIES 6

Hi wish you a happy new year.

Explained this feature and its usage in this youtube video.

Please take a look

https://www.youtube.com/watch?v=MrvfCmVOUE4

 

Community Alums
Not applicable

Happy New Year Ram. Thanks for sharing. This is very helpful.