You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix custom_lifecycle_rules breakage introduced in v1.0.1 (#156): the rendered policy JSON included "targetStorageClass":null in every expire action and "storageClass":"standard" in every selection, which AWS ECR rejected with InvalidParameterException: Invalid parameter at 'LifecyclePolicyText'.
Make storageClass and targetStorageClass strictly optional — omitted from the rendered JSON when the user doesn't set them, so v1.0.0 behavior is restored for the common case while the archive/transition feature from v1.0.1 is preserved.
Support the sinceImageTransitioned countType and add two validations that mirror ECR's schema: selection.storageClass = "archive" requires countType = "sinceImageTransitioned", and vice versa. Users get a clear Terraform-side error instead of an apply-time 400 from ECR.
Add a new integration test (TestExamplesLifecyclePolicies) and a runnable examples/lifecycle-policies — custom_lifecycle_rules previously had zero test coverage, which is why the regression shipped.
Upgrade the test module to Go 1.26 and refresh dependencies (terratest 0.31.4 → 0.56.0, testify 1.6.1 → 1.11.1, plus transitive deps via go get -u all).
Drop the deprecated rand.Seed(time.Now().UnixNano()) calls from the test suite (no-op since Go 1.24) and standardize on a small randAttribute() helper.
why
Users upgrading from v1.0.0 → v1.0.1 hit an immediate apply failure for any custom_lifecycle_rules entry that didn't explicitly set the new storage-class fields. The reproducer in issue #158 is the common tagged + tagPatternList + expire case.
Root cause is two normalization gaps in the v1.0.1 PR (#156):
storageClass = optional(string, \"standard\") injected \"standard\" into every selection, even when users didn't ask for it. main.tf's selection normalizer didn't filter storageClass, so it always made it into the JSON.
targetStorageClass = optional(string) (no default) was passed through the action block unchanged, so expire actions serialized \"targetStorageClass\":null. The action block had no normalization at all.
Fix: drop the \"standard\" default on storageClass (so it's only emitted when explicitly set), extend selection normalization to strip it when null, and normalize the action block to strip null keys (removes targetStorageClass:null from expire actions).
While building end-to-end coverage, the archive-expire rule exposed a second ECR-side constraint: selection.storageClass = \"archive\" only accepts countType = \"sinceImageTransitioned\" (not sinceImagePushed or imageCountMoreThan). Added module-level validations so this fails at plan-time with a useful message rather than as an ECR 400 at apply-time.
The examples/lifecycle-policies added in v1.0.1 wasn't runnable (no context.tf, no fixtures, no outputs) and had no test driver — making this the right place to add regression coverage. The new test applies against real ECR (so ECR's schema validator serves as the primary oracle) and adds output-level assertions on the rendered JSON to pin the exact issue #158 bug.