We have a function code in our organization's GitHub repository that is supposed to get compiled and deployed in an AWS Lambda Function and give emit an expected output. We are trying to implement this as an integration test in CI/CD pipeline using GitHub actions. We want this action to run each time a new PR is created to ensure that included code changes do not lead to any regression test failures.
This is how the GitHub action is expected to run:
- Use
aws-actions/configure-aws-credentials
to assume a role backed by OIDC connector behind the scenes, whereROLE_ARN
is passed as a secret. - Build code and update the AWS Lambda Function with the latest code
- Invoke Lambda Function
- Compare output from Step 3 with a pre-determined expected output
- Pass or fail the integration test based on comparison in Step 4
(Ideally, we would want to extend this to also create a new Lambda function with auto-generated name on every execution and clean it up after the execution is complete, but that's not relevant to the problem statement.)
We are aware that GitHub best practices recommend that organization secrets should not be shared on a forked PR as it opens up possibility of threats by bad actors using script injection attack. (Reference - Security hardening for GitHub Actions) Even if we set up an action, the secrets are not initialized in a fork-origin PR workflow.
We need to know, then, what are the recommended ways to implement the equivalent of what we are trying to achieve here? Since this might be one of the most common use cases encountered by the community.
We also tried seeing if environment secrets behave differently than repository secrets, but turns out for a fork-origin PR none of the secrets (including env secrets) get passed.
Why can't we have a manual approval-backed workflow (similar to environments) where an approver will first ensure if the corresponding GitHub action workflow isn't changed for dangerous actions (like an injection) and only then run the integration test?
Update 3/6: Turns out there is another downside with the fork-origin PRs apart from just passing secrets, the permission for id-token
cannot be set to write
, the most it could be set to is read
. (Reference - Automatic token authentication)