fix(lambda): prevent strcontains null error on zip deploys @johncblandii (#54)
## Summary- Fix a plan-time failure that occurred whenever the function was deployed from a zip (
image_uri == null) whilecicd_ssm_param_namewas set. - Add a fast, credential-free
terraform testunit suite that reproduces the regression and guards theimage_uriresolution logic going forward.
Changes
src/main.tf: make thelocal.image_uriresolution null-safe. Terraform/OpenTofu's&&does not short-circuit, sostrcontains(var.image_uri, "%s")was evaluated even whenvar.image_uriwas null, failing withInvalid value for "str" parameter: argument must not be null. The string fed tostrcontains()now goes through an inner ternary (var.image_uri == null ? "" : var.image_uri), which does short-circuit. (Note:coalesce(var.image_uri, "")is not a valid fix here —coalescealso rejects empty strings and would error whenimage_uriis null.)test/unit/image_uri/: new nativeterraform testfixture mirroring thelocal.image_urilogic, runnable without AWS credentials. The component itself can only be planned via the atmos/Terratest harness (it depends onaccount-mapand remote-state modules), so this isolates the pure logic that broke.test/README.md: document the integration (atmos test run) and new unit test workflows.
Testing
- Unit tests added (
test/unit/image_uri/image_uri_unit_test.tftest.hcl, 4 cases) - Verified the test fails against the buggy logic, reproducing the exact production error (
Invalid value for "str" parameter) - Verified the test passes against the fix —
Success! 4 passed, 0 failed -
terraform fmt -check -recursiveclean
Run the unit tests with:
```bash
terraform -chdir=test/unit/image_uri init
terraform -chdir=test/unit/image_uri test
```
Notes
Covered scenarios: zip deploy with SSM param set (the regression), templated image_uri formatted with the SSM value, static image_uri passthrough, and image_uri passthrough when no SSM param is configured.
The unit fixture mirrors the src/main.tf expression rather than executing it directly (the component can't init standalone in plain CI). Cross-reference comments in both files note they must stay in sync.
Summary by CodeRabbit
-
Bug Fixes
- Fixed null-value handling in image URI computation to prevent errors when certain parameters are undefined.
-
Tests
- Added comprehensive unit tests validating image URI resolution behavior across multiple scenarios.
-
Documentation
- Added testing layer documentation covering integration and native unit tests with setup instructions.
🤖 Automatic Updates
chore(deps): update tflint plugin terraform-linters/tflint-ruleset-aws to v0.46.0 @[renovate[bot]](https://github.com/apps/renovate) (#50)
This PR contains the following updates:| Package | Type | Update | Change |
|---|---|---|---|
| terraform-linters/tflint-ruleset-aws | plugin | minor | 0.45.0 → 0.46.0 |
Release Notes
terraform-linters/tflint-ruleset-aws (terraform-linters/tflint-ruleset-aws)
v0.46.0
What's Changed
Enhancements
- Update AWS provider/module and generated content by @github-actions[bot] in #1028
- rds: accept sqlserver-dev-ee engine by @Nullh in #1045
- Update AWS provider/module and generated content by @github-actions[bot] in #1038
- Update AWS provider/module and generated content by @github-actions[bot] in #1053
Chores
- Fix maintenance script failure by @wata727 in #1027
- Bump the aws-sdk group with 7 updates by @dependabot[bot] in #1029
- Bump actions/setup-go from 6.1.0 to 6.2.0 by @dependabot[bot] in #1030
- Bump golang.org/x/net from 0.48.0 to 0.49.0 by @dependabot[bot] in #1032
- Bump the aws-sdk group with 3 updates by @dependabot[bot] in #1031
- Bump peter-evans/create-pull-request from 8.0.0 to 8.1.0 by @dependabot[bot] in #1033
- Bump github.com/aws/aws-sdk-go-v2/service/ec2 from 1.279.2 to 1.281.0 in the aws-sdk group by @dependabot[bot] in #1035
- Bump actions/checkout from 6.0.1 to 6.0.2 by @dependabot[bot] in #1034
- Bump actions/attest-build-provenance from 3.1.0 to 3.2.0 by @dependabot[bot] in #1036
- Bump github.com/aws/aws-sdk-go-v2/service/ec2 from 1.281.0 to 1.285.0 in the aws-sdk group by @dependabot[bot] in #1037
- Bump the aws-sdk group with 2 updates by @dependabot[bot] in #1039
- Bump golang.org/x/net from 0.49.0 to 0.50.0 by @dependabot[bot] in #1040
- Remove aws_s3_bucket_invalid_region from docs by @kakakakakku in #1041
- Bump goreleaser/goreleaser-action from 6.4.0 to 7.0.0 by @dependabot[bot] in #1042
- Bump github.com/aws/smithy-go from 1.24.0 to 1.24.1 by @dependabot[bot] in #1044
- Bump the aws-sdk group with 3 updates by @dependabot[bot] in #1043
- Bump hashicorp/setup-terraform from 3.1.2 to 4.0.0 by @dependabot[bot] in #1046
- Bump actions/attest-build-provenance from 3.2.0 to 4.1.0 by @dependabot[bot] in #1048
- Bump actions/setup-go from 6.2.0 to 6.3.0 by @dependabot[bot] in #1047
- Bump the aws-sdk group with 7 updates by @dependabot[bot] in #1049
- Bump github.com/zclconf/go-cty from 1.17.0 to 1.18.0 by @dependabot[bot] in #1052
- Bump golang.org/x/net from 0.50.0 to 0.51.0 by @dependabot[bot] in #1051
- Bump github.com/aws/smithy-go from 1.24.1 to 1.24.2 by @dependabot[bot] in #1050
- deps: Bump Go version to 1.26 by @wata727 in #1054
New Contributors
- @kakakakakku made their first contribution in #1041
- @Nullh made their first contribution in #1045
Full Changelog: terraform-linters/tflint-ruleset-aws@v0.45.0...v0.46.0
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
- If you want to rebase/retry this PR, check this box
This PR was generated by Mend Renovate. View the repository job log.