[BUG] func NewWorkspace
does not create deep copy of terraformTemplates
#1101
Labels
bug
Something isn't working
Description
The function
NewWorkspace
does not create a deep copy of Terraform Templates which are read from the respective service definition.Expected Behavior
The function should create a deep copy.
Changes to Terraform Templates which are saved for a distinct workspace object must not affect Terraform Templates which are stored for the serviceDefinition object.
Actual Behavior
Changes to Terraform Templates which are stored for a workspace object overwrite the serviceDefinition:
pkg/providers/tf/provision.go, line 185:
Possible Fix
Steps to Reproduce
Context
We created a Brokerpak which allows to provision new S3 buckets or import existing ones. The brokerpak manifest looks similar to this (excerpt):
The Brokerpak allows us to:
cf create-service <service> <plan> <instance> -c '{}'
cf create-service <service> <plan> <instance> -c '{"subsume": true, "s3_bucket_name_subsume": <bucket-name>}'
cf update-service <service> -c '{"subsume": false}'
. This allows to patch settings of imported buckets.The service and plan ids do not change for these three operations.
We observe that the broker generates a new
main.tf
module when importing an existing bucket. After the import, the same generatedmain.tf
module is used for all newly provisioned buckets (without import) and for all service updates (in case the feature flagTERRAFORM_UPGRADES_ENABLED: true
is set) instead of themain.tf
which is actually part of the terraform template defined at the brokerpak.We believe that this is an effect of
NewWorkspace
not creating a deep copy ofterraformTemplates
.The wrong
main.tf
module is persisted to the database each time the terraform workspace is written for a service instance. As a consequence, once a single bucket has been imported, an update operation for any other service instance will break the stored workspace for the respective service instance.Oftentimes hard-coded resource-IDs are written to
main.tf
module which is generated after the import operation. As a consequence workflows like this possible:main.tf
with hard coded s3 bucket-id and settings of imported buckettofu apply
has no effect since terraform modules and state matchmain.tf
from imported bucket on service instance 1main.tf
Your Environment
The text was updated successfully, but these errors were encountered: