Skip to content

archive_file resources fail in multi-stage pipelines during AFT upgrades #633

Description

@daniel-butroyd-ba

AFT Version:

  • AFT upgrade: 1.20.01.21.1

Terraform Version & Provider Versions

terraform version

1.7.5

terraform providers

    aws = {
      source  = "hashicorp/aws"
      version = "~> 6.0"
    }

Bug Description
Upgrading AFT from 1.20.0 to 1.21.1 fails during terraform apply because generated Lambda ZIP files are missing:

Error: reading ZIP file
(.terraform/modules/aft/src/aft_lambda/aft_account_request_framework.zip):
no such file or directory

The same error occurs for:

  • aft_account_request_framework.zip
  • aft_customizations.zip
  • aft_feature_options.zip

AFT 1.20.0 changed these packages from data.archive_file to resource archive_file to support multi-stage pipelines (#555).
However, existing archive resources are refreshed (and their ZIPs generated) during the plan job. Changes inside source_dir
do not cause an archive resource replacement.

The saved plan updates the affected Lambda functions, but contains no apply-time action that recreates the ZIPs.
When the plan is applied in a clean job, the AWS provider cannot read the missing files.

The three missing archives correspond exactly to the Lambda source directories changed between AFT 1.20.0 and 1.21.1.

To Reproduce

  1. Deploy AFT 1.20.0.
  2. Run terraform plan -out=tfplan in job A.
  3. Pass only the saved plan to a clean job B.
  4. Upgrade the module reference to 1.21.1.
  5. Run terraform apply tfplan in job B.
  6. Observe the missing ZIP errors.

Expected behavior

AFT should recreate changed Lambda archives during apply without requiring consumers to persist internal files from .terraform/modules.

Workaround

Persist .terraform/modules/aft/src/aft_lambda/*.zip between plan and apply, or run both stages in the same filesystem.

Suggested fix

Make an AFT version or source-content digest participate in an archive_file argument that forces replacement when
Lambda source contents change. This would ensure the archive is generated during the apply stage.

Related: #555

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpending investigationIssue needs further investigation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions