{"id":1114,"date":"2025-10-08T09:48:44","date_gmt":"2025-10-08T07:48:44","guid":{"rendered":"https:\/\/aymen-segni.com\/?p=1114"},"modified":"2025-10-08T11:40:55","modified_gmt":"2025-10-08T09:40:55","slug":"exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024","status":"publish","type":"post","link":"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/","title":{"rendered":"Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide (2024)"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-style-plain is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-8f6819680d913ae6b7dcb82cc2d55d77\">Introduction <\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>Organizations frequently use Terraform Modules to manage complex resource provisioning and to provide a straightforward interface for developers to input the necessary parameters for deploying desired infrastructures. Modules facilitate code reuse and allow organizations to standardize the deployment of common workloads, such as three-tier web applications, cloud networking environments, or data analytics pipelines. When developing Terraform modules, module authors typically begin with manual testing. This involves using commands such as `terraform validate` for syntax checking, `terraform plan` to preview the execution plan, and `terraform apply`, followed by a manual inspection of resource configurations in the AWS Management Console. However, manual testing is susceptible to human error, is not scalable, and can lead to unintended issues. Since modules are utilized by multiple teams within an organization, it is crucial to ensure that any changes to the modules undergo thorough testing before being released. In this blog post, we will demonstrate how to validate Terraform modules and automate this process using a Continuous Integration\/Continuous Deployment (CI\/CD) pipeline.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-2738acdde49aacd74dd123dad7e50182\"><br>What will be covered by this post?<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>\u2705  Get started with Terraform Testing using the new native command<\/p>\n\n\n\n<p>\u2705  Key Features of the Testing &#8220;Framework&#8221;  <\/p>\n\n\n\n<p>\u2705 Test Syntax: Building Blocks<\/p>\n\n\n\n<p>\u2705 Best Practices for Writing IaC Tests with OpenTofu \/ Terraform<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-0d5441ed3f03268ea50ad90230762398\">Disclaimer <\/h3>\n\n\n\n<p><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<ol class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-42309f5bbb58418e64db4a2bc2556e70\">To make my writing more concise, I will refer to the new &#8220;Terraform\/OpenTofu&#8221; test feature simply as the &#8220;Terraform \/ OpenTofu&#8221; test feature. I will only mention &#8220;Terraform only&#8221; or &#8220;OpenTofu only&#8221; explicitly when discussing capabilities that apply specifically to that technology and not the other.<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-182dff1e88ffafe3388e3196e68ab664\">Commands <code>tofu<\/code> and <code>terraform<\/code> are interchangeable in this post; using one or another should have no impact on the IaC testing goal.<\/li>\n<\/ol>\n<\/blockquote>\n\n\n\n<p class=\"has-black-color has-text-color has-link-color wp-elements-9ac00cf961d1ea846fe5a532228b76c6\"><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-ffb657fc04a1e7c5d3733d2272e2c186\">The &#8220;new&#8221; Terraform \/ OpenTofu Test<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>Terraform, a widely adopted IaC tool, has traditionally relied on third-party solutions for testing. Enter OpenTofu, a native testing framework integrated within Terraform, aiming to streamline and simplify the testing process.<\/p>\n\n\n\n<p>The new Terraform \/ OpenTofu testing framework represents an evolution of the testing capabilities provided by Terraform. Built to align with Infrastructure as Code (IaC) principles, it enables module authors to validate configurations without introducing risks to existing infrastructure. Unlike traditional approaches that relied heavily on tools like TerraTest, OpenTofu simplifies the process with built-in support for HCL-based tests.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-20b532f94c75562b01f01a86abd1eddd\">What Terraform \/ OpenTofu Test<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-black-color has-text-color has-link-color wp-elements-109ef96d913ff2c88504ceedcc218fa0\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-black-color\">Terraform (OpenTofu) tests let authors validate that module configuration updates do not introduce breaking changes.<\/mark><br>Tests run against test-specific, short-lived resources, preventing any risk to your existing infrastructure or state.<\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-05632029db11419b895fe2527d27a9af\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-4fe4174c1bf88f9c32398ee8df7f60f6\">Key Features of the Terraform \/ OpenTofu Testing Framework<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color has-link-color wp-elements-fb549a1eed0b6ce1ac3661df9a23dac5\"><strong>Seamless Integration and Discovery<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-cdd141e59a8d028ad9fb5ac4b283668a\">Test files are identified using the extensions <code>.tftest.hcl<\/code> or <code>.tftest.json<\/code>.<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-c64f5a4f0cb1d3a6145d8f49700c5cbb\">HCL syntax makes it intuitive for users already familiar with Terraform modules.<\/li>\n<\/ul>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color has-link-color wp-elements-fee1ff9a244f68bab974194c30de47aa\"><strong>Unified Testing Philosophy<\/strong><\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-2aefc20551d19e9cb3e2f0a64bd23f22\"><strong>Unit Tests<\/strong>: Validate logical operations, input validations, and custom conditions using <code>plan<\/code> commands.<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-096f8770207b8fd6fcab4ad5518e47da\"><strong>Integration Tests<\/strong>: Perform end-to-end testing by applying resources in isolated environments and validating outputs.<\/li>\n<\/ol>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color has-link-color wp-elements-985a9eccb9a905548365a7829a2ed617\"><strong>Declarative Syntax<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-f8f8febd7bce4acc9b38ee14c036b9e1\">OpenTofu leverages Terraform&#8217;s declarative language, making tests familiar and easy to write for existing Terraform users.<\/li>\n<\/ul>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color has-link-color wp-elements-4375b6eb6dec83a2bd5bea80bff0d1bd\"><strong>Resource Mocking<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-671a7bee8795fc7943dfa992da1ff9af\">Simulate external dependencies like APIs or cloud resources during testing to isolate the behavior of your IaC code.<\/li>\n<\/ul>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color has-link-color wp-elements-2de3c31f8a70433b664661d33b163002\"><strong>Assertions<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-d05cd33a0e1423c4c27213665a8c59a3\">Verify the expected state of your infrastructure after applying configurations. <\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-306d0bd0107d874a2dd547505faf95ce\">OpenTofu supports various assertion types, including existence, attribute checks, and relationship validation.<\/li>\n<\/ul>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color has-link-color wp-elements-c3d9cc17db83a9ac7059c64c7c2b5db4\"><strong>Parallel Execution<\/strong> (Only OpenTofu as of the time of writing this article)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-b8174fc65e31b6f3d0ef13f9563015c0\">Optimize testing time by running tests concurrently, especially beneficial for large infrastructure configurations.<\/li>\n<\/ul>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color has-link-color wp-elements-02de2dc9c68c157c4567f895a7c7aee0\"><strong>Enhanced Developer Experience<\/strong> <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-1cabb65fe335a487b78bcc31bc91d790\">OpenTofu\u2019s <code>tofu fmt<\/code> provides built-in formatting for test files. (only OpenTofu)<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-81558e793afc309740f377953d29531c\">Faster initialization with <code>tofu init<\/code>, outperforming Terraform\u2019s initialization process. (only OpenTofu)<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-722e7c972a43f443e0a16eaff5c7962a\">Comprehensive, verbose output following Go\u2019s test framework style.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-2f6e9a0535e825e92b0e28952178fc03\">OpenTofu Test Syntax: Building Blocks<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-647c35e0831ea4edabf51c947f089ba9\"><strong>Run Blocks<\/strong>:<ul><li>Encapsulate specific test logic. Support optional parameters like <code>command<\/code> (<code>plan<\/code> for unit tests, <code>apply<\/code> for integration tests).<\/li><\/ul><\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-a95c1cec5fbb3c60610d5c12017e0c70\"><strong>Variable Blocks<\/strong>:<ul><li>Define reusable variables across multiple tests.<\/li><\/ul>Example:<code>variables { region = \"us-east-1\" environment = \"test\" }<\/code><\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-516489d6c0235de756608c81a6e5c42e\"><strong>Provider Blocks<\/strong>:\n<ul class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-f0635ddec2f00e2795b6b1959c35d1d0\">Include necessary provider configurations for the tests.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-e987c6aef482bfd75f1b0967faa889c1\"><strong>Assertions<\/strong>:\n<ul class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-adb1595b658c5418299b374aa12f2c1f\">Define conditions to validate outputs or behavior.<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-f15ce893b9303d3a0b168bce98b3ec8e\">Support custom error messages for failed validations.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-d1830f752f5767c7f8378ee5e52a4415\"><strong>Expect Failures<\/strong>:<ul><li>Enable negative testing to ensure robust validation.<\/li><\/ul>Example:<code>run \"invalid_input\" { variables = { instance_type = \"invalid-type\" } command = \"plan\" expect_failures = [\"Invalid instance type\"] }<\/code><\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Comparative Analysis: OpenTofu vs Terraform Test<\/h3>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-black-color has-text-color has-link-color has-fixed-layout\"><tbody><tr><th>Feature<\/th><th>OpenTofu Test<\/th><th>Terraform Test<\/th><\/tr><tr><td>Licensing<\/td><td>Open-source, stable<\/td><td>BSL-licensed, experimental<\/td><\/tr><tr><td>Initialization<\/td><td>Faster (<code>tofu init<\/code>)<\/td><td>Slower<\/td><\/tr><tr><td>Test Execution Speed<\/td><td>Faster but CPU-intensive<\/td><td>Moderate<\/td><\/tr><tr><td>Formatting Support<\/td><td>Available (<code>tofu fmt<\/code>)<\/td><td>Lacking<\/td><\/tr><tr><td>Signal Handling<\/td><td>Supports Unix signals (e.g., <code>C-C<\/code>)<\/td><td>Not robust<\/td><\/tr><tr><td>Output Style<\/td><td>Verbose, Go-test-like<\/td><td>Basic<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Best Practices for Writing OpenTofu Tests<\/h3>\n\n\n\n<p><\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-aaeea9774184b21fe9ba1ebb9e05f686\"><strong>Granular Test Design<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Separate unit and integration tests into distinct files (e.g., <code>unit_tests.tftest.hcl<\/code>, <code>integration_tests.tftest.hcl<\/code>).<\/li>\n\n\n\n<li>Break down test scenarios to focus on single functionalities.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-4350fbaa183edd6fd50e7f1f2280d0c4\"><strong>Validation Rules<\/strong>:<ul><li>Use validation blocks in <code>variables.tf<\/code> to define strict input requirements.<\/li><\/ul>Example:<code>variable \"settings\" { type = any validation { condition = length(keys(var.settings)) &gt; 0 error_message = \"At least one setting must be provided.\" } }<\/code><\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-d4cc58739b0f7edfe56e6ea26c073254\"><strong>Negative Testing<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Incorporate tests that intentionally fail to validate edge cases.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-4162cded0a5ae6bd599e031941b08d10\"><strong>Dependency Management<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Use modular structures with <code>testing_setup<\/code> folders for dependencies in integration tests.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-6d331677dcb2e68d469f86148f556644\"><strong>Reuse Outputs<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Reference outputs from setup blocks in subsequent tests for efficient resource management.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Practical Example: Integration Testing a Security Group Module<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Directory Structure:<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">module\/\n  tests\/\n    integration_tests.tftest.hcl\n  testing_setup\/\n    setup_vpc.tf<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Setup VPC:<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">resource \"aws_vpc\" \"vpc\" {\n  cidr_block = \"10.0.0.0\/16\"\n  enable_dns_support = true\n}\n\noutput \"vpc_id\" {\n  value = aws_vpc.vpc.id\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Integration Test:<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">run \"setup_vpc\" {\n  command = \"apply\"\n  module {\n    source = \"..\/testing_setup\"\n  }\n  assert {\n    condition     = aws_vpc.vpc.id != null\n    error_message = \"VPC ID is missing.\"\n  }\n}\n\nrun \"validate_security_group\" {\n  command = \"apply\"\n  variables = {\n    vpc_id = run.setup_vpc.vpc_id\n  }\n  assert {\n    condition     = aws_security_group.sg.vpc_id == var.vpc_id\n    error_message = \"Security group not associated with the correct VPC.\"\n  }\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Integrating OpenTofu Tests with CI\/CD Using GitHub Actions<\/h3>\n\n\n\n<p><\/p>\n\n\n\n<p>A robust CI\/CD pipeline is critical for maintaining high-quality Infrastructure as Code. Below is a step-by-step guide to integrate OpenTofu testing into your GitHub Actions pipeline:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Example Workflow File: <code>.github\/workflows\/ci.yml<\/code><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">name: CI Pipeline\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - \"*\"\n\njobs:\n  test:\n    name: Run OpenTofu Tests\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Checkout Code\n        uses: actions\/checkout@v3\n\n      - name: Set up OpenTofu\n        run: |\n          curl -fsSL https:\/\/opentofu.org\/install.sh | bash\n          export PATH=$HOME\/.opentofu\/bin:$PATH\n\n      - name: Initialize Terraform\n        run: |\n          tofu init\n\n      - name: Run Tests\n        run: |\n          tofu test\n\n      - name: Format and Validate\n        run: |\n          tofu fmt -check\n          tofu validate\n\n      - name: Archive Test Results\n        if: failure()\n        run: |\n          mkdir -p artifacts\n          mv test-results\/* artifacts\/\n        continue-on-error: true\n\n      - name: Upload Artifacts\n        if: always()\n        uses: actions\/upload-artifact@v3\n        with:\n          name: test-results\n          path: artifacts\/<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Key Points:<\/h4>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-806ed633ff9d7a3577d0e6f703febff8\"><strong>Tool Installation<\/strong>:\n<ul class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-b69052db5efcbf6f6d1ae556ea0d32e4\">Use the OpenTofu installation script for setup.<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-603ea20dfacb3d5190aff85574f81e9c\">Ensure the <code>PATH<\/code> is updated to include OpenTofu binaries.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-669a132118f89faa7eef18caaed420b7\"><strong>Testing Steps<\/strong>:\n<ul class=\"wp-block-list\">\n<li class=\"has-black-color has-text-color has-link-color wp-elements-6aba61b3cb409742a0ec0ba4dd322aca\">Run <code>tofu init<\/code> to initialize modules.<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-ca85e68c6988e9f3dac4ccd0a62edaad\">Use <code>tofu test<\/code> to execute the test suite.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-51bd0d3b449abd3a693515417c7b3d59\"><strong>Error Handling and Artifacts<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Archive test results for post-mortem analysis on failures.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"has-black-color has-text-color has-link-color wp-elements-fe74fdc52b888aa528857d21c607adce\"><strong>Formatting and Validation<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Leverage <code>tofu fmt -check<\/code> and <code>tofu validate<\/code> for pre-merge checks.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion and Call to Action<\/h3>\n\n\n\n<p><\/p>\n\n\n\n<p>OpenTofu \/ Terraform testing framework democratizes testing for IaC practitioners by integrating a robust, intuitive, and performant solution directly into their workflow. The integration of this framework into CI\/CD pipelines ensures that every change to your IaC modules is rigorously validated before deployment.<\/p>\n\n\n\n<p>Adopt a Test-Driven Development (TDD) approach for your IaC projects. Write tests first, validate against them, and iterate to ensure your modules are resilient, maintainable, and future-proof. Let OpenTofu be your trusted ally in this journey.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide<\/p>\n","protected":false},"author":1,"featured_media":1116,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[38,9,13,8,1,39],"tags":[],"class_list":["post-1114","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-cloud","category-deployment","category-devops","category-non-classe","category-sre"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide (2024) - Run It On Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide (2024) - Run It On Cloud\" \/>\n<meta property=\"og:description\" content=\"Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide\" \/>\n<meta property=\"og:url\" content=\"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/\" \/>\n<meta property=\"og:site_name\" content=\"Run It On Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2025-10-08T07:48:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-08T09:40:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/aymen-segni.com\/wp-content\/uploads\/2025\/01\/terraform-test-banner.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1500\" \/>\n\t<meta property=\"og:image:height\" content=\"750\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"aymen-segni\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/x.com\/axsegni\" \/>\n<meta name=\"twitter:site\" content=\"@axsegni\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"aymen-segni\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/\"},\"author\":{\"name\":\"aymen-segni\",\"@id\":\"https:\/\/aymen-segni.com\/#\/schema\/person\/32033966e7bd410bbaf1b79c7e94b59d\"},\"headline\":\"Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide (2024)\",\"datePublished\":\"2025-10-08T07:48:44+00:00\",\"dateModified\":\"2025-10-08T09:40:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/\"},\"wordCount\":960,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/aymen-segni.com\/#\/schema\/person\/32033966e7bd410bbaf1b79c7e94b59d\"},\"articleSection\":[\"Azure\",\"Cloud\",\"Deployment\",\"Devops\",\"Non class\u00e9\",\"SRE\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/\",\"url\":\"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/\",\"name\":\"Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide (2024) - Run It On Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/aymen-segni.com\/#website\"},\"datePublished\":\"2025-10-08T07:48:44+00:00\",\"dateModified\":\"2025-10-08T09:40:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/aymen-segni.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide (2024)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/aymen-segni.com\/#website\",\"url\":\"https:\/\/aymen-segni.com\/\",\"name\":\"Run It On Cloud\",\"description\":\"Accelerate your Cloud &amp; MLOps Journey\",\"publisher\":{\"@id\":\"https:\/\/aymen-segni.com\/#\/schema\/person\/32033966e7bd410bbaf1b79c7e94b59d\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/aymen-segni.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/aymen-segni.com\/#\/schema\/person\/32033966e7bd410bbaf1b79c7e94b59d\",\"name\":\"aymen-segni\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/aymen-segni.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/aymen-segni.com\/wp-content\/uploads\/2025\/02\/72799.jpg\",\"contentUrl\":\"https:\/\/aymen-segni.com\/wp-content\/uploads\/2025\/02\/72799.jpg\",\"width\":896,\"height\":1152,\"caption\":\"aymen-segni\"},\"logo\":{\"@id\":\"https:\/\/aymen-segni.com\/#\/schema\/person\/image\/\"},\"description\":\"Staff Engineer with over a decade of experience in building, scaling, and leading MLOPS, Cloud Native, SRE, and DevOps platforms across high-growth and enterprise environments. I specialize in architecting production-grade systems with a strong emphasis on resilience, security, and developer experience; bringing together deep expertise in distributed systems, Kubernetes, and modern platform engineering to empower engineering teams and accelerate business value. My work spans Cloud (AWS, GCP, Azure, OpenStack), Kubernetes, SRE (SLOs, observability, incident response), AI infrastructure and AgentOps (vLLM, Nvidia, RayServe, etc), and Platform Engineering (Backstage, Keptn, GitOps, self-service). I\u2019ve led teams through Cloud Native transformations, established scalable SRE practices, and built internal platforms that streamline operations and reduce cognitive load. With a strong programming background, and Infrastructure as Code (Terraform, Helm, Ansible), I drive automation-first approaches to eliminate toil, ensure reliability, and enable secure, compliant deployment pipelines. My focus today is on building Cloud Native AI platforms, where DevOps meets AI Infrastructure Stacks to support scalable, production-ready LLMs and AI Platforms. As a dedicated mentor, both within my teams and through platforms like MentorCruise, I am passionate about helping engineers perform at their best and assisting organizations in scaling with confidence. Driven by systems thinking, platform-as-a-product mindset, and engineering excellence, I help teams ship faster, operate smarter, and scale with confidence.\",\"sameAs\":[\"https:\/\/aymen-segni.com\",\"https:\/\/www.linkedin.com\/in\/aymen-segni\",\"https:\/\/twitter.com\/https:\/\/x.com\/axsegni\"],\"url\":\"https:\/\/aymen-segni.com\/index.php\/author\/admin8647\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide (2024) - Run It On Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/","og_locale":"en_US","og_type":"article","og_title":"Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide (2024) - Run It On Cloud","og_description":"Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide","og_url":"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/","og_site_name":"Run It On Cloud","article_published_time":"2025-10-08T07:48:44+00:00","article_modified_time":"2025-10-08T09:40:55+00:00","og_image":[{"width":1500,"height":750,"url":"https:\/\/aymen-segni.com\/wp-content\/uploads\/2025\/01\/terraform-test-banner.webp","type":"image\/webp"}],"author":"aymen-segni","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/x.com\/axsegni","twitter_site":"@axsegni","twitter_misc":{"Written by":"aymen-segni","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/#article","isPartOf":{"@id":"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/"},"author":{"name":"aymen-segni","@id":"https:\/\/aymen-segni.com\/#\/schema\/person\/32033966e7bd410bbaf1b79c7e94b59d"},"headline":"Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide (2024)","datePublished":"2025-10-08T07:48:44+00:00","dateModified":"2025-10-08T09:40:55+00:00","mainEntityOfPage":{"@id":"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/"},"wordCount":960,"commentCount":0,"publisher":{"@id":"https:\/\/aymen-segni.com\/#\/schema\/person\/32033966e7bd410bbaf1b79c7e94b59d"},"articleSection":["Azure","Cloud","Deployment","Devops","Non class\u00e9","SRE"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/","url":"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/","name":"Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide (2024) - Run It On Cloud","isPartOf":{"@id":"https:\/\/aymen-segni.com\/#website"},"datePublished":"2025-10-08T07:48:44+00:00","dateModified":"2025-10-08T09:40:55+00:00","breadcrumb":{"@id":"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/aymen-segni.com\/index.php\/2025\/10\/08\/exploring-the-terraform-opentofu-testing-feature-a-complete-guide-2024\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/aymen-segni.com\/"},{"@type":"ListItem","position":2,"name":"Exploring the Terraform\/OpenTofu Testing Feature: A Complete Guide (2024)"}]},{"@type":"WebSite","@id":"https:\/\/aymen-segni.com\/#website","url":"https:\/\/aymen-segni.com\/","name":"Run It On Cloud","description":"Accelerate your Cloud &amp; MLOps Journey","publisher":{"@id":"https:\/\/aymen-segni.com\/#\/schema\/person\/32033966e7bd410bbaf1b79c7e94b59d"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/aymen-segni.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/aymen-segni.com\/#\/schema\/person\/32033966e7bd410bbaf1b79c7e94b59d","name":"aymen-segni","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/aymen-segni.com\/#\/schema\/person\/image\/","url":"https:\/\/aymen-segni.com\/wp-content\/uploads\/2025\/02\/72799.jpg","contentUrl":"https:\/\/aymen-segni.com\/wp-content\/uploads\/2025\/02\/72799.jpg","width":896,"height":1152,"caption":"aymen-segni"},"logo":{"@id":"https:\/\/aymen-segni.com\/#\/schema\/person\/image\/"},"description":"Staff Engineer with over a decade of experience in building, scaling, and leading MLOPS, Cloud Native, SRE, and DevOps platforms across high-growth and enterprise environments. I specialize in architecting production-grade systems with a strong emphasis on resilience, security, and developer experience; bringing together deep expertise in distributed systems, Kubernetes, and modern platform engineering to empower engineering teams and accelerate business value. My work spans Cloud (AWS, GCP, Azure, OpenStack), Kubernetes, SRE (SLOs, observability, incident response), AI infrastructure and AgentOps (vLLM, Nvidia, RayServe, etc), and Platform Engineering (Backstage, Keptn, GitOps, self-service). I\u2019ve led teams through Cloud Native transformations, established scalable SRE practices, and built internal platforms that streamline operations and reduce cognitive load. With a strong programming background, and Infrastructure as Code (Terraform, Helm, Ansible), I drive automation-first approaches to eliminate toil, ensure reliability, and enable secure, compliant deployment pipelines. My focus today is on building Cloud Native AI platforms, where DevOps meets AI Infrastructure Stacks to support scalable, production-ready LLMs and AI Platforms. As a dedicated mentor, both within my teams and through platforms like MentorCruise, I am passionate about helping engineers perform at their best and assisting organizations in scaling with confidence. Driven by systems thinking, platform-as-a-product mindset, and engineering excellence, I help teams ship faster, operate smarter, and scale with confidence.","sameAs":["https:\/\/aymen-segni.com","https:\/\/www.linkedin.com\/in\/aymen-segni","https:\/\/twitter.com\/https:\/\/x.com\/axsegni"],"url":"https:\/\/aymen-segni.com\/index.php\/author\/admin8647\/"}]}},"jetpack_featured_media_url":"https:\/\/aymen-segni.com\/wp-content\/uploads\/2025\/01\/terraform-test-banner.webp","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/aymen-segni.com\/index.php\/wp-json\/wp\/v2\/posts\/1114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aymen-segni.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aymen-segni.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aymen-segni.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aymen-segni.com\/index.php\/wp-json\/wp\/v2\/comments?post=1114"}],"version-history":[{"count":20,"href":"https:\/\/aymen-segni.com\/index.php\/wp-json\/wp\/v2\/posts\/1114\/revisions"}],"predecessor-version":[{"id":1168,"href":"https:\/\/aymen-segni.com\/index.php\/wp-json\/wp\/v2\/posts\/1114\/revisions\/1168"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aymen-segni.com\/index.php\/wp-json\/wp\/v2\/media\/1116"}],"wp:attachment":[{"href":"https:\/\/aymen-segni.com\/index.php\/wp-json\/wp\/v2\/media?parent=1114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aymen-segni.com\/index.php\/wp-json\/wp\/v2\/categories?post=1114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aymen-segni.com\/index.php\/wp-json\/wp\/v2\/tags?post=1114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}