Skip to content

fix(aws): allow Fn::If in awsArn config validation - #13662

Open
josemfche wants to merge 1 commit into
serverless:mainfrom
josemfche:fix/aws-cf-if-in-awsCfFunction
Open

fix(aws): allow Fn::If in awsArn config validation#13662
josemfche wants to merge 1 commit into
serverless:mainfrom
josemfche:fix/aws-cf-if-in-awsCfFunction

Conversation

@josemfche

@josemfche josemfche commented Jun 23, 2026

Copy link
Copy Markdown

Fixes #11611

Summary

  • Allow Fn::If (YAML !If) on awsArn, which is used by HTTP API authorizer arn fields
  • Reuse the existing awsCfIf schema definition as a sibling ref on awsArn, matching the cfValue() pattern already used elsewhere in the AWS provider schema
  • Avoid adding awsCfIf to awsCfFunction directly, which causes AJV recursion at schema compile time

Test plan

Made with Cursor

Summary by CodeRabbit

Release Notes

  • New Features

    • Extended ARN configuration validation to accept CloudFormation conditional expressions (Fn::If) alongside standard ARN strings and other CloudFormation intrinsic functions.
  • Tests

    • Added test suite for ARN configuration schema, verifying support for conditional expressions and CloudFormation functions in authorizer ARN configurations.

HTTP authorizer arn values using CloudFormation conditionals were valid at deploy time but rejected by the config schema. Accept Fn::If via the existing awsCfIf definition on awsArn, matching the cfValue pattern used elsewhere.
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Mmarzex

Mmarzex commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 35ca50f0-540b-4d5f-bb6d-65e1bc8c9b5b

📥 Commits

Reviewing files that changed from the base of the PR and between fb7ac39 and 127b7fe.

📒 Files selected for processing (2)
  • packages/serverless/lib/plugins/aws/provider.js
  • packages/serverless/test/unit/lib/plugins/aws/provider.test.js

📝 Walkthrough

Walkthrough

The awsArn JSON schema in provider.js is extended by adding awsCfIf (Fn::If) to its anyOf array, allowing conditional CloudFormation expressions to resolve to an ARN. A corresponding test suite is added to verify both schema structure and Ajv validation.

Changes

awsArn Fn::If schema support

Layer / File(s) Summary
awsArn anyOf extension and test coverage
packages/serverless/lib/plugins/aws/provider.js, packages/serverless/test/unit/lib/plugins/aws/provider.test.js
awsCfIf is added to awsArn's anyOf in the schema definition; a new describe('awsCfIf in awsArn schema') block asserts that awsCfIf appears alongside awsCfFunction in anyOf and that Ajv with the regexp keyword accepts an Fn::If authorizer ARN value.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A schema once grumbled, "No !If allowed!"
But the rabbit said, "Nonsense!" and fixed it out loud.
One line in the anyOf, a test for good measure,
Now Fn::If ARNs pass — what a small, tidy treasure.
The validator hops on, no warnings in sight! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: extending awsArn validation to accept Fn::If conditional expressions.
Linked Issues check ✅ Passed The PR directly addresses issue #11611 by allowing Fn::If in awsArn fields, enabling valid CloudFormation conditional configurations to pass schema validation.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing awsArn schema validation to accept Fn::If; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@josemfche

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

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.

Validator reports invalid configuration for !If function

2 participants