Skip to content

Keep the generated config.json out of the frontend fileset - #4

Merged
HarshCasper merged 1 commit into
mainfrom
fix/frontend-fileset-race
Oct 19, 2026
Merged

HarshCasper merged 1 commit into
mainfrom
fix/frontend-fileset-race

Conversation

@HarshCasper

Copy link
Copy Markdown
Member

The push run on main fails at "Deploy the infrastructure" (run):

Error: Error in function call
  on main.tf line 708, in resource "aws_s3_object" "frontend_files":
  708:   for_each = fileset("${path.module}/../frontend", "**/*.*")
Call to function "fileset" failed: function returned an inconsistent result.

local_file.config_json writes frontend/config.json during the apply, while aws_s3_object.frontend_files iterates fileset("../frontend", "**/*.*"), which Terraform evaluates again during the apply. On a fresh checkout the file appears between plan and apply, so the deploy fails. The PR run passed only because the S3 uploads happened to run first. Locally it fails every time on a fresh checkout. Filtering the result with setsubtract is not enough: Terraform checks the fileset() call itself.

The fileset now matches only static asset types (html, css, js, png, jpg, jpeg, gif, svg, ico), in terraform/ and terraform-local/. config.json is already uploaded by aws_s3_object.config_json. Before, a config.json left over from an earlier run was also uploaded under the same key, with stale URLs.

Tested locally with localstack/localstack-pro:latest (2026.10.0), following the CI job (OpenWeather stub): a fresh make deploy creates all 59 resources, make test passes, and a second apply with config.json present also succeeds. Without this change the fresh deploy fails with the error above.

local_file.config_json writes frontend/config.json during the apply, and
aws_s3_object.frontend_files iterates fileset("../frontend", "**/*.*"),
which Terraform evaluates again during the apply. On a fresh checkout the
file appears between plan and apply and the deploy fails with "function
returned an inconsistent result". Match only the static asset types;
config.json is uploaded by aws_s3_object.config_json.

Claude-Session: https://claude.ai/code/session_01DZfDmzUBPqNAu3yFKyfCNM
@HarshCasper
HarshCasper merged commit 9930526 into main Oct 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant