Skip to main content

6.2.4 Integrating OPA with GHA

Youtube ๐Ÿ“บ

Now that we've seen the power of OPA and how it can help identify cloud misconfiguration before they are applied, let's look at how we can automated running OPA using Github Actions !

๐Ÿ› ๏ธ Preparing Codeโ€‹

The below command shall update the code to include Github Actions for OPA and also create a new branch called opa

cd ~/playground/
cp -r ~/s4cpcode/chapter6/6C/. ~/playground/
git checkout -b opa
git status
git add .
git commit -m "checking out opa"
git push --set-upstream origin opa

๐Ÿ”„ Create PRโ€‹

Let's create a PR from opa branch to main branch as shown below

๐Ÿ‘๏ธ View the PR Commentsโ€‹

Check the results of OPA in PR Comments

  • OPA Scan output for Global Infrastructure , showing excessive permissions being attached

  • OPA Scan output for Prod Infrastrucutre , showing excessive permissions attached to a security group

๐Ÿ› ๏ธ Preparing Code for Rolling Backโ€‹

Let's roll back the changes by firing the below commands , as we donot wish to commit the above identified abnormalities in the code.

cd ~/playground/
cp -r ~/s4cpcode/chapter6/6D/. ~/playground/
git status
git add .
git commit -m "rolling back changes"
git push --set-upstream origin opa

๐Ÿ”€ Merge the PRโ€‹

Lastly, we need to close the PR by merging the opa branch into main branch with [skip ci] in comments.

[skip ci]

Its important here to add the string [skip ci] in the message as we don't wish to run the Github Actions upon the merge. Same can be seen in the screenshot below.

  1. First enter [skip ci] in the comment.
  2. Click on Close with comment button.
End of Chapter 6

That completes the Chapter 6 and of the course ๐ŸŽ‰๐ŸŽŠ๐ŸŽ‰๐ŸŽŠ๐ŸŽ‰๐ŸŽŠ๐ŸŽ‰๐ŸŽŠ๐ŸŽ‰๐Ÿฅณ , highligthing what we've learned in Chapter 6