Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastly_service_compute.package does not update if package changes remotely and content is specified without filename #908

Open
noseglid opened this issue Dec 18, 2024 · 0 comments · May be fixed by #909

Comments

@noseglid
Copy link
Contributor

noseglid commented Dec 18, 2024

Affected Fastly Terraform Resource(s)

  • fastly_service_compute

Terraform Configuration Files

resource "fastly_service_compute" "my_serivce" {
  name = "my-service"
  package {
    content = sensitive(module.pkg.content)
  }
}

Expected Behavior

Terraform resets the package to whatever is configured (value of module.pkg.content) if it has been altered outside of terraform

Actual Behavior

Terraform doesn't identify the drift and does nothing, even if the content of module.pkg.content doesn't match what is currently deployed.

Details

Using the above configuration, when the remote package is changed (e.g. through manual upload in UI), terraform doesn't detect the drift and does nothing.

There is an option source_code_hash which seems to invoke the behavior I want, but it conflicts with providing content. I tried building the provider locally and removing this conflict and providing source_code_hash. This seems to create the behavior I'm seeking.

diff --git a/fastly/block_fastly_service_package.go b/fastly/block_fastly_service_package.go
index 69d38480a3cc77fd070698be1cd00c5a4849d0d6..ff3baca51f394cf48afb8a7a649662bf9b20d4e3 100644
--- a/fastly/block_fastly_service_package.go
+++ b/fastly/block_fastly_service_package.go
@@ -51,7 +51,6 @@ func (h *PackageServiceAttributeHandler) Register(s *schema.Resource) error {
                                        Optional:      true,
                                        Computed:      true,
                                        Description:   "Used to trigger updates. Must be set to a SHA512 hash of all files (in sorted order) within the package. The usual way to set this is using the fastly_package_hash data source.",
-                                       ConflictsWith: []string{"package.0.content"},
                                },
                        },
                },

I'm not aware of why this ConflictsWith is there. It stands to reason that you should be able to provide the file hash, regardless of where the bytes of the package comes from.

I've created a PR for my changes if I'm not misunderstanding the use for source_code_hash: #909

@noseglid noseglid changed the title fastly_service_compute.package does not update if package changes remotely fastly_service_compute.package does not update if package changes remotely and content is specified without filename Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant