top of page

Back to the Basics: Policy-as-Code

Nov 21
5 min read

Hey y'all! Welcome back to another Mimi's Musings discussion around GRC Engineering.


A couple of months ago, I posted about starting the GRC Engineering Club labs challenge and finishing week two. Mind you, I hadn't done anything with GRC Engineering before this, at least not formally. I've worked with security controls, governance, and compliance throughout my career, but I hadn't taken it to this level. So I jumped right in! You can read about my first two weeks in the previous articles.


Well, I got stuck at week three trying to configure OpenID Connect (OIDC) to connect GitHub Actions to AWS without storing access keys in my configuration files. This was part of setting up the grc-gate workflow to check whether required security controls were implemented when changes were submitted through a pull request.


I kept getting the same error:

EntityAlreadyExists: Provider with url https://token.actions.githubusercontent.com already exists

I'm sitting here trying to figure out where this thing already exists because I hadn't changed the configuration. I tried several times, researched the error, and couldn't get it working. Eventually, I let it sit for about two weeks. But it kept bothering me because, being a builder and engineer, that's what I do. I want to figure out how things work and why something isn't working the way it should.


Time to PIVOT

This was a great PIVOT moment. Sometimes we jump right into something without having a clear idea, vision, or understanding of everything we're trying to accomplish. We just want to get it done. And sometimes, in those moments, you have to pause and ask yourself, "Okay, what am I doing and why?" Then you need to inventory what you know, what you're trying to accomplish, and what might be missing. Sometimes that means going back to the beginning and starting over.


That's exactly what I did. I went back and started working through all the labs in the GRC Engineering Club instead of trying to pick up where I left off. As I worked through the exercises, I started to understand Conftest, the different controls, and the guardrails you can put in place. I also started recognizing patterns and connecting what I was learning to things I'd encountered throughout my cybersecurity career.


Now, I was working with code that could evaluate configurations against those requirements. Depending on how the policies and workflows are implemented, you can check configurations as changes are proposed, identify violations, and collect evidence to support continuous monitoring.


Think about shadow IT, shadow AI, and all the new resources organizations are adding to their environments. We establish security baselines and policies, but how do we continue checking that those requirements are being followed? How do we know when a newly configured resource doesn't meet the baseline?


Back to the OIDC Problem

I started working through the labs until I got back to OIDC. And guess what? I got stuck again! LOL. This time, though, I didn't leave it sitting for another two weeks. I did more research, pulled up Claude, worked with ChatGPT, and used Google to understand exactly what was happening.

Turns out, I already had a GitHub OIDC provider configured in my AWS account, likely from an earlier attempt. AWS allows only one provider with the same URL in an account, and I was trying to create another one. Once I found the existing provider, removed it, and corrected the configuration, everything worked.


Now for the Juicy Part!

This is the part I really enjoy because I get to build something and show my work.

I have a GitHub profile where I've been adding projects and things I've worked on. If you want to check it out, my username is galloway03, and the repository for this project is cgep-labs.

Inside the repository, I've been working with Terraform configurations, Rego policies, test files, and the GitHub Actions workflow. I also wanted to create a pretty interface because, well, we like colors and pictures and things that are easy to navigate! LOL.


It's one thing to have security controls configured and working. It's another to give an auditor, analyst, engineer, or anyone else who needs the information an interface where they can find the controls they're interested in, review the configuration, understand what passed or failed, and export the results.


That's what I wanted to start building.


I began with CloudTrail, which records activity within AWS environments. I created a Rego policy associated with NIST SP 800-53 AU-12, Audit Record Generation, to check whether CloudTrail exists and whether certain logging configurations are enabled. One thing I spent time working through was how the policy should handle fields that are missing entirely. There is a difference between a configuration being explicitly disabled and a field not being present in the data being evaluated. Depending on how you write your Rego policy, a missing field may not trigger the violation you expected.

For my CloudTrail exercise, I wanted to account for that behavior. I worked through the rules, tested the configurations, and made changes so the policy could identify settings that weren't represented as enabled in my test data.

4 different test results based on the configuration changes. Click the photo to see this in action!
4 different test results based on the configuration changes. Click the photo to see this in action!

I then created an interactive assessment interface where someone can select different CloudTrail configurations, run checks, view the results, simulate remediation, and export a JSON evidence file.


Want to see how the assessment works? Watch my CloudTrail Compliance Assessment walkthrough.

You can also try the assessment yourself: CGEP Interactive Compliance Assessment.

The public interface currently demonstrates the assessment process using synthetic configurations and browser-based checks. The Rego policies are tested separately in my lab. My next step is connecting the actual policy evaluations to the interface and automating more of the evidence collection.


Why Is This Important?

Throughout my career, I've worked with security controls and compliance requirements. I've seen situations where compliance meant checking whether a setting was enabled, whether something was entered into a field, or whether we had documentation showing that a requirement was met. As I've been working through the GRC Engineering labs, I'm seeing how we can take some of those same requirements and evaluate them through code. Instead of only documenting that a control exists, we can write policies to check whether the configurations meet the requirements we've established.


Think about how many changes happen in an organization's environment. New resources are created, existing configurations are updated, and teams are constantly deploying something. We may have policies and security baselines in place, but how are we checking that those requirements are being followed as changes happen? That's part of what interests me about GRC Engineering. We can integrate these checks into engineering workflows, identify configuration issues earlier, and collect evidence from the evaluations. There is still work involved in defining the controls, writing the policies, and reviewing the results, but the evaluation doesn't have to depend entirely on someone manually checking a configuration or gathering screenshots for an audit.


And this brings me back to why I wanted to build the interactive assessment. I want engineers, auditors, analysts, and the people responsible for governance to have access to information they can actually review and use. This is the type of work I'm interested in continuing to develop. I want to help organizations visualize what's happening in their environments, understand where their configurations aren't meeting requirements, and improve how they manage security and governance across their systems.


If this is something you're interested in, whether for your organization or your own learning, let me know. I help organizations with cybersecurity, exposure management, governance, and security process improvement.


And if you're ready to make that PIVOT, Let's Talk.

Comments


  • LinkedIn

©2020 - 2026 by A&M Strategies. Shop

bottom of page