help me setup an AWS ci pipeline with codebuild and automated PR approval

Job ID: 33606793

Budget: $10 – $30 USD

Hi,
I have an AWS request that needs solving asap.
I use CODECOMMIT to control my code versioning
The Task is to have a CLOUDWATCH rule that monitors when a Pull Request is open
Trigger a LAMBDA function that posts comments on the PR and run whatever tests re on the BUILDSPEC.YML file that sits inside the repo.
IF tests are SUCCESS
Post comments on repo AND
Approve the PR

I have setup in my test environment two sets of links i got from the internet where:
This link:
https://www.freecodecamp.org/news/validate-pull-requests-in-aws/
This gets the rules created
This also gets the lambdas and the codebuilds built
when you run It run posts comments on PR, It runs the tests on the buildspec.yml file....but it does not approve the PR if success.

This second link:
https://helecloud.com/blog/how-to-aws-codecommit-continuous-integration/
This link builds a cloudwatch rule to monitor the PR creation
This link also builds a codebuild with some inline buildspec instructions
When you create a PR, it runs the tests(if any) that were bult inside this inline buildspec that sits inside the codebuild.....
This approves the PR.....but.............
It does not runs the tests that were built in the buildspec.yml file that are on the repo.

The TASK is to :
1.Get a cloudwatch rule to monitor a PR creation/change
2.Post a comment on the PR that tests started
3. Run the test FROM the buildspec.yml file that is in the repo. (for this any simple tests or commands are ok, just to test the functionality using dummy files)
4. IF success, update the PR approve status to "Approved". At this stage we should see in the APPROVALS tab that the pr has the automatic approval.
5. IF FAILURE update the approval status to REVOKED
6. post comments of the results on the PR

I guess the best is to get both links cloned and test them on your own environment.
Related categories: Aws Lambda