
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
    <channel>
        <title><![CDATA[ The Cloudflare Blog ]]></title>
        <description><![CDATA[ Get the latest news on how products at Cloudflare are built, technologies used, and join the teams helping to build a better Internet. ]]></description>
        <link>https://blog.cloudflare.com</link>
        <atom:link href="https://blog.cloudflare.com/" rel="self" type="application/rss+xml"/>
        <language>en-us</language>
        <image>
            <url>https://blog.cloudflare.com/favicon.png</url>
            <title>The Cloudflare Blog</title>
            <link>https://blog.cloudflare.com</link>
        </image>
        <lastBuildDate>Sun, 14 Jun 2026 09:32:14 GMT</lastBuildDate>
        <item>
            <title><![CDATA[Defend against frontier cyber models: Cloudflare's architecture as customer zero]]></title>
            <link>https://blog.cloudflare.com/frontier-model-defense/</link>
            <pubDate>Tue, 09 Jun 2026 06:00:00 GMT</pubDate>
            <description><![CDATA[ In our post about Project Glasswing, we made the argument that the architecture around a vulnerability matters more than the speed of the patch. Here we walk through what that architecture looks like, the threats it defends against, and how we run it ourselves as Cloudflare's customer zero. ]]></description>
            <content:encoded><![CDATA[ <p></p><p></p><p>A few weeks ago, we <a href="https://blog.cloudflare.com/cyber-frontier-models/"><u>wrote about Project Glasswing</u></a> and what we observed when we pointed cyber frontier models at our own code. Since then, we’ve seen that the part of the post that has resonated most deeply is the argument that the architecture around the vulnerability matters more than the speed of the patch.</p><p>In the conversations we've had with CISOs and security teams since, the questions have been consistent: what does our architecture actually look like, what should we monitor for, where do we start, and how can Cloudflare help?</p><p>Before getting into the details: the architecture below is built almost entirely from Cloudflare's own products, because Cloudflare security is <a href="https://blog.cloudflare.com/tag/customer-zero/"><u>customer zero</u></a> for the security products we build. The Cloudflare stack already exists in front of our code, employees, and customer-facing applications. If you're a Cloudflare customer, every layer below is available to you today. If you're not, the principles still apply to whatever stack you've built.</p>
    <div>
      <h2>What a cyber frontier model actually changes</h2>
      <a href="#what-a-cyber-frontier-model-actually-changes">
        
      </a>
    </div>
    <p>In the <a href="https://blog.cloudflare.com/cyber-frontier-models/"><u>previous post</u></a>, we showed how a cyber frontier model like Mythos changes the attacker’s timeline. It can find vulnerabilities, reason through exploit chains, and generate working proofs faster than earlier models. While models like Mythos do not change the shape of an intrusion — reconnaissance, initial access, lateral movement, persistence, and exfiltration still have to happen — the difference is in the speed and scale. When pointed at the open web, a model can find and hit low-hanging fruit quickly. Against a hardened target, it still has to probe, and adapt, and it often produces more noise than a careful human operator would.</p><p>Discovery, exploit chain construction, and proof-of-concept generation used to be the gating constraints on producing a working attack. A frontier model handles all three in a fraction of the time. Work that used to be slow and methodical is now fast and indiscriminate.</p><p>While AI is accelerating how fast developer teams at Cloudflare and many other companies can ship code, the security team’s work has not compressed the same way. An attacker only needs one opening to get in, while security teams need to find and close them all. Writing a fix, regressing it, and shipping it without breaking the code around it has constraints that AI doesn't remove. We learned this the hard way when we let an AI coding assistant write its own patches against our own bugs, as we described at the end of the previous <a href="https://blog.cloudflare.com/cyber-frontier-models/"><u>post</u></a>. Some of those patches fixed the original bug while quietly breaking something else the code depended on.</p><p>As these models become more competent and capable, our main focus from a threat standpoint comes down to three things. Each one shapes the architecture we walk through in the rest of this post.</p><ul><li><p>The first is the <b>speed of discovery.</b> Frontier models make it easier to search large bodies of public code, including the open-source libraries that many companies depend on. That does not mean every bug in a library is exploitable, or that library bugs are where most vulnerabilities live. Exploitability still depends on how the code is used, whether attacker-controlled input can reach the vulnerable path, and the protections that sit around it. But widely used open-source libraries and frameworks give attackers a shared surface to study at scale. When a real, reachable vulnerability exists there, a model can help find it, reason about possible exploit paths, and generate proof-of-concept variants faster than maintainers and defenders can review every downstream use. The gap between when an attacker discovers a vulnerability and when defenders learn it exists is what worries us most. If you are not running these models against your own code, it is safe to assume someone else is.</p></li><li><p>The second is <b>exploit</b> <b>volume and adaptation.</b> A model can produce thousands of variations of a single exploit and run reconnaissance at the same scale. All that volume gives an attacker an advantage, but it won’t necessarily get them past signature-based detections. Many of those iterations will have the same underlying signature, so a rule that catches the first one will catch the rest. Adaptation is how they will get past signature-based detections. Ask a model to show you a SQL injection, and it will return a textbook example. Tell it there is a WAF in the way, and it will start probing, learning what gets blocked, and rewriting the payload until it can slip past the rule blocking it. </p></li><li><p>The third is <b>the impact when a vulnerability is inevitably exploited. </b>No architecture catches everything. After the vulnerability is exploited, the question we ask ourselves is: where can the attacker get to with one identity, one path, or one credential, before something else stops them? If the answer is "anywhere they want," the vulnerability was never the problem. The architecture around the vulnerability was.</p></li></ul>
    <div>
      <h2>Cloudflare’s superpower: visibility</h2>
      <a href="#cloudflares-superpower-visibility">
        
      </a>
    </div>
    <p>We see roughly a fifth of the web and that tells us, in real time, which payloads are mutating, which patterns are picking up, and where attacker tooling is moving next. Two teams turn that visibility into defense.</p><p>First is <a href="https://www.cloudflare.com/cloudforce-one/"><b><u>Cloudforce One</u></b></a>, our threat intelligence, research, and operations team, which sits within the Cloudflare security organization. They turn what we see across the network into insights the rest of the stack can act on: tracked adversaries, emerging campaigns, and indicators of compromise (IOCs). The hard part of this work was never knowing what is malicious — it was the delay in mitigation. Knowledge of a new threat normally has to travel from a threat report, into a feed, and then into a company’s defense before it can be used to block anything. Attackers have learned to move faster than that. Our network closes that gap: Cloudflare customers can now use Cloudforce One threat intelligence <a href="https://blog.cloudflare.com/realtime-threat-intel-waf-rules/"><u>directly within the WAF</u></a> to block high-risk traffic.</p><p>Second is the team that owns the WAF engine that does the actual detecting: the managed rulesets that run in front of our own properties and are available to every Cloudflare customer, the machine learning behind <a href="https://developers.cloudflare.com/waf/about/waf-attack-score/"><u>WAF Attack Score</u></a>, and the relationships that sometimes let us ship a rule before a CVE is publicly disclosed. The team is globally distributed and moves fast, releasing rules within hours of a proof-of-concept of an attack becoming known. Once a detection is deployed, it reaches our entire network, along with every Cloudflare customer, in under 30 seconds. <a href="https://blog.cloudflare.com/react2shell-rsc-vulnerabilities-exploitation-threat-brief/"><u>React2Shell</u></a> is a recent example: a managed WAF rule <a href="https://blog.cloudflare.com/waf-rules-react-vulnerability/"><u>was protecting our own properties, and everyone else's on Cloudflare</u></a>, hours before the official advisory was published.</p><p>The scoring layer, the defenses we put in front of the application, and the containment around the vulnerability all build on what these two teams see. </p>
    <div>
      <h2>Scores over signatures</h2>
      <a href="#scores-over-signatures">
        
      </a>
    </div>
    <p>Signature-based defenses were built for a world where novel exploits were scarce and variations took weeks. Cloudflare's traditional SLA from a fresh proof-of-concept to a live, deployed rule has been 12 hours. With the advent of frontier models, this is not good enough anymore. Detections need to be in place <a href="https://blog.himanshuanand.com/2026/05/the-90-day-disclosure-policy-is-dead/"><u>before a CVE is discovered</u></a>. This is why we layer ML-based detection in front of the traditional signature-based WAF.</p><p>The model is trained on a large body of past attack traffic, and it catches new variants of vulnerabilities before they're publicly known. A novel <a href="https://www.cloudflare.com/learning/security/threats/sql-injection/"><u>SQL injection</u></a> or remote code execution chain is almost always a rearrangement of attack shapes the model has seen before, even when the specific exploit is brand new. We run the model on every request and assign a WAF Attack Score between 1 and 99, based on how closely the request resembles those underlying shapes, not against a list of known-bad signatures. The lower the score, the more aggressively we treat the request. That score determines whether we let the request through. We apply a similar scoring methodology to AI prompts with <a href="https://developers.cloudflare.com/waf/detections/ai-security-for-apps/"><u>AI Security for Apps</u></a>: rather than check each prompt against a list of known malicious prompts, we score how closely a prompt resembles an actual attack. </p>
    <div>
      <h2>The architecture around the vulnerability</h2>
      <a href="#the-architecture-around-the-vulnerability">
        
      </a>
    </div>
    <p>Those capabilities only matter once they're stacked in front of an application, and the first layer in our defense-in-depth approach is the <a href="https://www.cloudflare.com/en-gb/application-services/products/waf/"><b><u>WAF</u></b></a>. Anything that matches a known-bad pattern gets dropped before it reaches the application, which clears the bulk of the obvious traffic and lets the more specialized layers below focus on what's left.

On the API surface, we run a positive security model through <a href="https://www.cloudflare.com/en-gb/application-services/products/api-shield/"><b><u>API Shield</u></b></a>. Instead of trying to anticipate every bad request, we describe what a valid request to each API looks like, either from the API's own definition or learned from our real traffic, and anything that doesn't fit doesn't get through. This neutralizes the advantage of frontier AI models: because we only permit validated traffic, generating thousands of new attack variations fails to bypass the system.</p>
          <figure>
          <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/5KSSyocxKzsJsOfG4pxOM7/059a597af1b67a3d5a5ccdeda5ab7ca1/image2.png" />
          </figure><p><sup><i>Cloudflare’s layered architecture</i></sup></p><p><a href="https://www.cloudflare.com/learning/bots/what-is-bot-management/"><b><u>Bot Management</u></b></a> catches probing traffic on our network before frontier models can build a map. It scores every request on how likely it is to be automated, using the same signals across our whole network: how the client behaves, whether it looks like a real browser, and whether the connection matches a known-bad pattern. An attack only lands if it can find a soft spot. </p><p><a href="https://www.cloudflare.com/sase/products/access/"><b><u>Zero Trust Network Access</u></b></a> is used for every internal application. The implicit trust of being inside the network is replaced with explicit per-request identity and policy for every employee accessing every tool. The value of this was clear when one of our engineers shipped a misconfigured tool. A flat network would have exposed everything on the same segment, but in our deployment, the exposure stopped at the tool itself. We built <a href="https://developers.cloudflare.com/cloudflare-one/access-controls/access-settings/require-access-protection/"><b><u>Require Access Protection</u></b></a> afterwards so newly deployed or misconfigured applications can't be reachable before an access policy is in place.</p><p><a href="https://developers.cloudflare.com/cloudflare-one/integrations/identity-providers/idp-federation/"><b><u>IdP Federation</u></b></a> makes that secure by default posture easier to keep consistent across every Cloudflare account — which becomes even more necessary when more people are shipping internal tools quickly. Instead of asking each team to wire up SSO separately, we configure our identity provider (IdP) once and share it across the organization. New accounts get SSO automatically, recipient-side IdP connections are read-only, and Access policies in each account still evaluate the resulting identity as part of the normal request flow. </p><p><a href="https://developers.cloudflare.com/cloudflare-one/access-controls/ai-controls/mcp-portals/"><b><u>MCP Server Portal</u></b></a> gives teams a controlled way to connect AI agents to enterprise systems. Agents access MCP servers that are centrally managed through a single portal, with every action logged. That way when an agent acts on someone's behalf, we know what it did, what it touched, and whether it should have been allowed to. The full picture of how we built it is in our post on <a href="https://blog.cloudflare.com/enterprise-mcp/"><u>enterprise MCP</u></a>.</p><p><a href="https://www.cloudflare.com/developer-platform/products/ai-gateway/"><b><u>AI Gateway</u></b></a> runs in front of our internal AI tools the same way <a href="https://developers.cloudflare.com/waf/detections/ai-security-for-apps/"><u>AI Security for Apps</u></a> runs in front of customer-facing AI features, with the same scoring and the same visibility. Inside the company, the visibility piece is more useful than the blocking, because we needed to see what engineers were actually building before we could write meaningful policy on it.</p>
    <div>
      <h2>Where your teams can start </h2>
      <a href="#where-your-teams-can-start">
        
      </a>
    </div>
    <p>Frontier models can help attackers find vulnerabilities, adapt payloads, and move faster, but they still have to pass through the layered defense you deploy in front of your application. That is where teams should start:</p><ul><li><p>Put inspection in front of public applications.</p></li><li><p>Define what valid API traffic looks like.</p></li><li><p>Use bot detection to limit automated probing.</p></li><li><p>Require identity and access policy before any internal tool is reachable.</p></li></ul><p>For AI and agentic systems:</p><ul><li><p>Route model traffic through a gateway.</p></li><li><p>Keep agents connected through approved MCP servers.</p></li><li><p>Log what they do. </p></li></ul><p>The goal is to make sure that when one layer misses, the next layer limits what the attacker can see, reach, or change.</p><p>That is the point of the architecture around the vulnerability: to limit the scope of an attack. The vulnerability may be what starts the attack, but the architecture determines how far it can go.</p>
    <div>
      <h2>How do we know this approach works?</h2>
      <a href="#how-do-we-know-this-approach-works">
        
      </a>
    </div>
    <p>Plenty of security stacks look impenetrable on a whiteboard but fall over in practice. That is why we test ours continuously, both at the perimeter and inside our environment, with our red team involved across both.</p><p><b>At the perimeter</b>, frontier models are one tool we use to test our application security stack as an adaptive attacker. These models sit alongside the rest of our red team and detection workflows including: manual testing, threat intelligence, observed traffic patterns, proof-of-concept analysis, and signals from our own network. Together, those inputs help us decide where to aim testing: newly launched products, recently changed surfaces, and the paths an attacker is most likely to probe first. The most important part is the process that follows. When something gets through, we identify the gap, use the right mix of tools to understand it, write the rule or mitigation, ship the update, and test again to make sure the gap is closed.</p><p><b>Inside the environment,</b> our red team starts from the assumption that the perimeter has already failed. They look at what has changed, where sensitive systems carry risk, and whether one compromised identity, path, or credential can reach farther than it should. When we change the architecture based on what they find, they run the scenario again against the new version to confirm the gap is actually closed.</p><p>We confirm that this architecture is working by continuously testing its behavior during failures, rather than relying on the perfection of individual layers.</p><p>If your team is working on the same problems and would like to compare notes, reach out to us at <a href="#"><u>security-ai-research@cloudflare.com</u></a>.</p> ]]></content:encoded>
            <category><![CDATA[Security]]></category>
            <category><![CDATA[AI]]></category>
            <category><![CDATA[Threat Intelligence]]></category>
            <category><![CDATA[Risk Management]]></category>
            <category><![CDATA[Customer Zero]]></category>
            <category><![CDATA[WAF]]></category>
            <category><![CDATA[Zero Trust]]></category>
            <category><![CDATA[Cloudforce One]]></category>
            <category><![CDATA[Bot Management]]></category>
            <guid isPermaLink="false">5Jw5AkmauDqCVgDeCs0mBa</guid>
            <dc:creator>Rohit Chenna Reddy</dc:creator>
            <dc:creator>Chase Catelli</dc:creator>
            <dc:creator>Dan Jones</dc:creator>
        </item>
        <item>
            <title><![CDATA[Shifting left at enterprise scale: how we manage Cloudflare with Infrastructure as Code]]></title>
            <link>https://blog.cloudflare.com/shift-left-enterprise-scale/</link>
            <pubDate>Tue, 09 Dec 2025 06:00:00 GMT</pubDate>
            <description><![CDATA[ Cloudflare has shifted to Infrastructure as Code and policy enforcement to manage internal Cloudflare accounts. This new architecture uses Terraform, custom tooling, and Open Policy Agent to enforce security baselines and increase engineering velocity. ]]></description>
            <content:encoded><![CDATA[ <p></p><p>The Cloudflare platform is a critical system for Cloudflare itself. We are our own Customer Zero – using our products to secure and optimize our own services. </p><p>Within our security division, a dedicated Customer Zero team uses its unique position to provide a constant, high-fidelity feedback loop to product and engineering that drives continuous improvement of our products<b>. </b>And we do this at a global scale — where a single misconfiguration can propagate across our edge in seconds and lead to unintended consequences. If you've ever hesitated before pushing a change to production, sweating because you know one small mistake could lock every employee out of critical application or take down a production service, you know the feeling. The risk of unintended consequences is real, and it keeps us up at night.</p><p>This presents an interesting challenge: How do we ensure hundreds of internal production Cloudflare accounts are secured consistently while minimizing human error?</p><p>While the Cloudflare dashboard is excellent for <a href="https://www.cloudflare.com/learning/performance/what-is-observability/">observability</a> and analytics, manually clicking through hundreds of accounts to ensure security settings are identical is a recipe for mistakes. To keep our sanity and our security intact, we stopped treating our configurations as manual point-and-click tasks and started treating them like code. We adopted “shift left” principles to move security checks to the earliest stages of development. </p><p>This wasn't an abstract corporate goal for us. It was a survival mechanism to catch errors before they caused an incident, and it required a fundamental change in our governance architecture.</p>
    <div>
      <h2>What Shift Left means to us</h2>
      <a href="#what-shift-left-means-to-us">
        
      </a>
    </div>
    <p>"Shifting left" refers to moving validation steps earlier in the software development lifecycle (SDLC). In practice, this means integrating testing, security audits, and policy compliance checks directly into the <a href="https://www.cloudflare.com/learning/serverless/glossary/what-is-ci-cd/">continuous integration and continuous deployment (CI/CD) pipeline</a>. By catching issues or misconfigurations at the merge request stage, we identify issues when the cost of remediation is lowest, rather than discovering them after deployment.</p><p>When we think about applying shift left principles at Cloudflare, four key principles stand out:</p><ul><li><p><b>Consistency</b>: Configurations must be easily copied and reused across accounts.</p></li><li><p><b>Scalability</b>: Large changes can be applied rapidly across multiple accounts.</p></li><li><p><b>Observability</b>: Configurations must be auditable by anyone for current state, accuracy, and security.</p></li><li><p><b>Governance</b>: Guardrails must be proactive — enforced before deployment to avoid incidents.</p></li></ul>
    <div>
      <h2>A production IaC operating model</h2>
      <a href="#a-production-iac-operating-model">
        
      </a>
    </div>
    <p>To support this model, we transitioned all production accounts to being managed with Infrastructure as Code (IaC). Every modification is tracked, tied to a user, commit, and an internal ticket. Teams still use the dashboard for analytics and insights, but critical production changes are all done in code.</p><p>This model ensures every change is peer-reviewed, and policies, though set by the security team, are implemented by the owning engineering teams themselves.</p><p>This setup is grounded in two major technologies: <a href="https://developer.hashicorp.com/terraform"><u>Terraform</u></a> and a custom CI/CD pipeline.</p>
    <div>
      <h2>Our enterprise IaC stack</h2>
      <a href="#our-enterprise-iac-stack">
        
      </a>
    </div>
    <p>We chose Terraform for its mature open-source ecosystem, strong community support, and deep integration with Policy as Code tooling. Furthermore, using the <a href="https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs"><u>Cloudflare Terraform Provider</u></a> internally allows us to actively <a href="https://blog.cloudflare.com/tag/dogfooding/"><u>dogfood</u></a> the experience and improve it for our customers.</p><p>To manage the scale of hundreds of accounts and around 30 merge requests per day, our CI/CD pipeline runs on <a href="https://www.runatlantis.io/"><u>Atlantis</u></a>, integrated with <a href="https://about.gitlab.com/"><u>GitLab</u></a>. We also use a custom go program, tfstate-butler, that acts as a broker to securely store state files.</p><p>tfstate-butler operates as an HTTP backend for Terraform. The primary design driver was security: It ensures unique encryption keys per state file to limit the blast radius of any potential compromise. </p><p>All internal account configurations are defined in a centralized <a href="https://developers.cloudflare.com/pages/configuration/monorepos/"><u>monorepo</u></a>. Individual teams own and deploy their specific configurations and are the designated code owners for their sections of this centralized repository, ensuring accountability. To read more about this configuration, check out <a href="https://blog.cloudflare.com/terraforming-cloudflare-at-cloudflare/"><u>How Cloudflare uses Terraform to manage Cloudflare</u></a>.</p>
          <figure>
          <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/17DDCeUrkEeWqtqpIPZoV4/114b63e0b8c408843b14c447ed27ed97/image1.png" />
          </figure><p><sup>Infrastructure as Code Data Flow Diagram</sup></p>
    <div>
      <h2>Baselines and Policy as Code</h2>
      <a href="#baselines-and-policy-as-code">
        
      </a>
    </div>
    <p>The entire shift left strategy hinges on establishing a strong security baseline for all internal production Cloudflare accounts. The baseline is a collection of security policies that are defined in code (Policy as Code). This baseline is not merely a set of guidelines but rather a required security configuration we enforce across the platform — e.g., maximum session length, required logs, specific WAF configurations, etc. </p><p>This setup is where policy enforcement shifts from manual audits to automated gates. We use the <a href="https://www.openpolicyagent.org/"><u>Open Policy Agent (OPA)</u></a> framework and its policy language, <a href="https://www.openpolicyagent.org/docs/policy-language#what-is-rego"><u>Rego</u></a>, via the Atlantis Conftest Policy Checking feature.</p>
    <div>
      <h2>Defining policies as code</h2>
      <a href="#defining-policies-as-code">
        
      </a>
    </div>
    <p>Rego policies define the specific security requirements that make up the baseline for all Cloudflare provider resources. We currently maintain approximately 50 policies.</p><p>For example, here is a Rego policy that validates only @cloudflare.com emails are allowed to be used in an access policy: </p>
            <pre><code># validate no use of non-cloudflare email
warn contains reason if {
    r := tfplan.resource_changes[_]
    r.mode == "managed"
    r.type == "cloudflare_access_policy"

    include := r.change.after.include[_]
    email_address := include.email[_]
    not endswith(email_address, "@cloudflare.com")

    reason := sprintf("%-40s :: only @cloudflare.com emails are allowed", [r.address])
}
warn contains reason if {
    r := tfplan.resource_changes[_]
    r.mode == "managed"
    r.type == "cloudflare_access_policy"

    require := r.change.after.require[_]
    email_address := require.email[_]
    not endswith(email_address, "@cloudflare.com")

    reason := sprintf("%-40s :: only @cloudflare.com emails are allowed", [r.address])
}</code></pre>
            
    <div>
      <h2>Enforcing the baseline</h2>
      <a href="#enforcing-the-baseline">
        
      </a>
    </div>
    <p>The policy check runs on every merge request (MR), ensuring configurations are compliant <i>before</i> deployment. Policy check output is shown directly in the GitLab MR comment thread. </p><p>Policy enforcement operates in two modes:</p><ol><li><p><b>Warning:</b> Leaves a comment on the MR, but allows the merge.</p></li><li><p><b>Deny:</b> Blocks the deployment outright.</p></li></ol><p>If the policy check determines the configuration being applied in the MR deviates from the baseline, the output will return which resources are out of compliance.</p><p>The example below shows an output from a policy check identifying 3 discrepancies in a merge request:</p>
            <pre><code>WARN - cloudflare_zero_trust_access_application.app_saas_xxx :: "session_duration" must be less than or equal to 10h

WARN - cloudflare_zero_trust_access_application.app_saas_xxx_pay_per_crawl :: "session_duration" must be less than or equal to 10h

WARN - cloudflare_zero_trust_access_application.app_saas_ms :: you must have at least one require statement of auth_method = "swk"

41 tests, 38 passed, 3 warnings, 0 failures, 0 exception</code></pre>
            
    <div>
      <h2>Handling policy exceptions</h2>
      <a href="#handling-policy-exceptions">
        
      </a>
    </div>
    <p>We understand that exceptions are necessary, but they must be managed with the same rigor as the policy itself. When a team requires an exception, they submit a request via Jira.</p><p>Once approved by the Customer Zero team, the exception is formalized by submitting a pull request to the central exceptions.rego repository. Exceptions can be made at various levels:</p><ul><li><p><b>Account:</b> Exclude account_x from policy_y.</p></li><li><p><b>Resource Category</b>: Exclude all resource_a’s in account_x from policy_y.</p></li><li><p><b>Specific Resource: </b>Exclude resource_a_1 in account_x from policy_y.</p></li></ul><p>This example shows a session length exception for five specific applications under two separate Cloudflare accounts: </p>
            <pre><code>{  
    "exception_type": "session_length",
    "exceptions": [
        {
            "account_id": "1xxxx",
              "tf_addresses": [
                "cloudflare_access_application.app_identity_access_denied",
                "cloudflare_access_application.enforcing_ext_auth_worker_bypass",
                "cloudflare_access_application.enforcing_ext_auth_worker_bypass_dev",
            ],
        },
        {
            "account_id": "2xxxx",
              "tf_addresses": [
                "cloudflare_access_application.extra_wildcard_application",
                "cloudflare_access_application.wildcard",
            ],
        },
    ],
}</code></pre>
            
    <div>
      <h2>Challenges and lessons learned</h2>
      <a href="#challenges-and-lessons-learned">
        
      </a>
    </div>
    <p>Our journey wasn't without obstacles. We had years of clickops (manual changes made directly in the dashboard) scattered across hundreds of accounts. Trying to import the existing chaos into a strict infrastructure as code system felt like trying to change the tires on a moving car. To this day, importing resources continues to be an ongoing process.</p><p>We also ran into limitations of our own tools. We found edge cases in the Cloudflare Terraform provider that only appear when you try to manage infrastructure at this scale. These weren't just minor speed bumps. They were hard lessons on the necessity of eating our own dogfood, so we could build even better solutions.</p><p>That friction clarified exactly what we were up against, leading us to three hard-earned lessons.</p>
    <div>
      <h2>Lesson 1: high barriers to entry stall adoption </h2>
      <a href="#lesson-1-high-barriers-to-entry-stall-adoption">
        
      </a>
    </div>
    <p>The first hurdle for any large-scale IaC rollout is onboarding existing, manually configured resources. We gave teams two options: manually creating Terraform resources and import blocks, or using <a href="https://github.com/cloudflare/cf-terraforming"><u>cf-terraforming</u></a>.</p><p>We quickly discovered that Terraform fluency varies across teams, and the learning curve for manually importing existing resources proved to be much steeper than we anticipated.</p><p>Luckily the cf-terraforming command-line utility uses the Cloudflare API to automatically generate the necessary Terraform code and import statements, significantly accelerating the migration process. </p><p>We also formed an internal community where experienced engineers could guide teams through the nuances of the provider and help unblock complex imports.</p>
    <div>
      <h2>Lesson 2: drift happens </h2>
      <a href="#lesson-2-drift-happens">
        
      </a>
    </div>
    <p>We also had to tackle configuration drift, which occurs when the IaC process is bypassed to expedite urgent changes. While making edits directly in the dashboard is faster during an incident, it leaves the Terraform state out of sync with reality.</p><p>We implemented a custom drift detection service that constantly compares the state defined by Terraform with the actual deployed state via the Cloudflare API. When drift is detected, an automated system creates an internal ticket and assigns it to the owning team with varying Service Level Agreements (SLAs) for remediation. </p>
    <div>
      <h2>Lesson 3: automation is key</h2>
      <a href="#lesson-3-automation-is-key">
        
      </a>
    </div>
    <p>Cloudflare innovates quickly, so our set of products and APIs is ever-growing. Unfortunately, that meant that our Terraform provider was often behind in terms of feature parity with the product. </p><p>We solved that issue with the release of our <a href="https://blog.cloudflare.com/automatically-generating-cloudflares-terraform-provider/"><u>v5 provider</u></a>, which automatically generates the Terraform provider based on the OpenAPI specification. This transition wasn’t without bumps as we hardened our approach to code generation, but this approach ensures that the API and Terraform stay in sync, reducing the chance of capability drift. </p>
    <div>
      <h2>The core lesson: proactive &gt; reactive</h2>
      <a href="#the-core-lesson-proactive-reactive">
        
      </a>
    </div>
    <p>By centralizing our security baselines, mandating peer reviews, and enforcing policies before any change hits production, we minimize the possibility of configuration errors, accidental deletions, or policy violations. The architecture not only helps to prevent manual mistakes, but actually increases engineering velocity because teams are confident their changes are compliant. </p><p>The key lesson from our work with Customer Zero is this: While the Cloudflare dashboard is excellent for day-to-day operations, achieving enterprise-level scale and consistent governance requires a different approach. When you treat your Cloudflare configurations as living code, you can scale securely and confidently. </p><p>Have thoughts on Infrastructure as Code? Keep the conversation going and share your experiences over at <a href="http://community.cloudflare.com"><u>community.cloudflare.com</u></a>.</p> ]]></content:encoded>
            <category><![CDATA[Infrastructure as Code]]></category>
            <category><![CDATA[Customer Zero]]></category>
            <category><![CDATA[Terraform]]></category>
            <category><![CDATA[Dogfooding]]></category>
            <guid isPermaLink="false">6Kx2Ob32avdygaasok3ZCr</guid>
            <dc:creator>Chase Catelli</dc:creator>
            <dc:creator>Ryan Pesek</dc:creator>
            <dc:creator>Derek Pitts</dc:creator>
        </item>
    </channel>
</rss>