Skip to content

Add option for a lambda function URL for testing#17

Merged
ethanholz merged 2 commits into
omsf:mainfrom
dwhswenson:add-test-url
Feb 11, 2026
Merged

Add option for a lambda function URL for testing#17
ethanholz merged 2 commits into
omsf:mainfrom
dwhswenson:add-test-url

Conversation

@dwhswenson
Copy link
Copy Markdown
Member

Waiting for the scheduled job to kick off in order to do an E2E test is a hassle. This gives an option to add a test URL, so I can trigger the lambda it with a quick curl.

No auth, so not recommended for production, but very convenient for a quick test.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.28%. Comparing base (6f199a4) to head (7dc95d1).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #17   +/-   ##
=======================================
  Coverage   98.28%   98.28%           
=======================================
  Files          10       10           
  Lines         408      408           
=======================================
  Hits          401      401           
  Misses          7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dwhswenson dwhswenson marked this pull request as ready for review February 5, 2026 23:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds an optional Lambda Function URL feature to the scheduled-lambda module to enable on-demand testing without waiting for scheduled execution. The implementation introduces a new create_test_url variable that conditionally creates an unauthenticated, publicly accessible Lambda Function URL for testing purposes.

Changes:

  • Added create_test_url boolean variable with default false to control Function URL creation
  • Created AWS Lambda Function URL resource and associated permissions when enabled
  • Exposed the Function URL through module outputs for easy access

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
modules/scheduled-lambda/variables.tf Added create_test_url boolean variable to control test URL creation
modules/scheduled-lambda/outputs.tf Added test_function_url output to expose the generated URL when enabled
modules/scheduled-lambda/main.tf Implemented Lambda Function URL resource and two permission resources (conditionally created)
examples/basic/variables.tf Propagated create_test_url variable to example configuration
examples/basic/main.tf Passed through create_test_url to module and exposed output

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +86 to +101
resource "aws_lambda_permission" "allow_function_url" {
count = var.create_test_url ? 1 : 0
statement_id = "AllowFunctionUrlInvoke"
action = "lambda:InvokeFunctionUrl"
function_name = aws_lambda_function.scheduled.function_name
principal = "*"
function_url_auth_type = "NONE"
}

resource "aws_lambda_permission" "allow_function_url_invoke" {
count = var.create_test_url ? 1 : 0
statement_id = "AllowFunctionUrlInvokeFunction"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.scheduled.function_name
principal = "*"
}
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lambda permission resources appear to be redundant. When creating a Lambda Function URL with authorization_type = "NONE", only one aws_lambda_permission resource with action = "lambda:InvokeFunction" is needed. The "lambda:InvokeFunctionUrl" action and "function_url_auth_type" parameter in the first resource are not standard AWS Terraform provider parameters. Consider removing the first permission resource (allow_function_url) and keeping only the second one (allow_function_url_invoke), as it follows the correct pattern seen in the EventBridge permission at line 115.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread modules/scheduled-lambda/variables.tf Outdated
Comment on lines +80 to +93
resource "aws_lambda_function_url" "test" {
count = var.create_test_url ? 1 : 0
function_name = aws_lambda_function.scheduled.function_name
authorization_type = "NONE"
}

resource "aws_lambda_permission" "allow_function_url" {
count = var.create_test_url ? 1 : 0
statement_id = "AllowFunctionUrlInvoke"
action = "lambda:InvokeFunctionUrl"
function_name = aws_lambda_function.scheduled.function_name
principal = "*"
function_url_auth_type = "NONE"
}
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aws_lambda_function_url is configured with authorization_type = "NONE" and the corresponding aws_lambda_permission for lambda:InvokeFunctionUrl uses principal = "*", which makes this Lambda function URL publicly invokable over the internet with no authentication. Anyone who discovers the URL can trigger the function, potentially leading to data exfiltration, unintended side effects, or abuse if this module is used in a non-test or production environment. Consider requiring authenticated access (e.g., AWS_IAM) or at minimum documenting and enforcing that this resource can only be enabled in tightly controlled, non-production environments (for example via environment-specific variables or additional guards).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more clear warning about risks in README and variable description (7dc95d1)

Comment on lines +95 to +102
resource "aws_lambda_permission" "allow_function_url_invoke" {
count = var.create_test_url ? 1 : 0
statement_id = "AllowFunctionUrlInvokeFunction"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.scheduled.function_name
principal = "*"
}

Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aws_lambda_permission resource allow_function_url_invoke grants lambda:InvokeFunction with principal = "*", which allows any AWS account to invoke this Lambda directly via the AWS API if they know its ARN. This creates a broad cross-account access exposure that goes beyond the unauthenticated function URL and could be abused for unauthorized invocation or lateral movement in multi-account setups. Restrict this permission to the specific AWS service or account that needs to invoke the function (or remove it entirely if it is not required for the function URL path).

Suggested change
resource "aws_lambda_permission" "allow_function_url_invoke" {
count = var.create_test_url ? 1 : 0
statement_id = "AllowFunctionUrlInvokeFunction"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.scheduled.function_name
principal = "*"
}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more clear warning about risks in README and variable description (7dc95d1)

@dwhswenson dwhswenson requested a review from ethanholz February 5, 2026 23:36
@dwhswenson
Copy link
Copy Markdown
Member Author

@ethanholz This should be ready for review. I might improve docs on the URL variable to emphasize that it isn't recommended for long-lived deployments. This should be a pretty easy review.

Copy link
Copy Markdown
Contributor

@ethanholz ethanholz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this looks great, merging.

@ethanholz ethanholz merged commit cf444da into omsf:main Feb 11, 2026
3 checks 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.

3 participants