» Mocking tfconfig Data

Below is a sample of what a mock for the tfconfig import would look like. You can use this data with the mocking or testing features of the Sentinel Simulator to create test data for rules.

For more details on how to work with mock data in Sentinel, see the section on Mocking Imports in the official Sentinel documentation.

» Current mock limitations

  • As functions cannot be mocked in the current Sentinel testing framework, the module() function is not available. As a result, only root module data can be mocked at this time.
{
  "mock": {
    "tfconfig": {
      "module_paths": [
        [],
        [
          "foo"
        ]
      ],
      "data": {
        "null_data_source": {
          "baz": {
            "config": {
              "inputs": [
                {
                  "bar_id": "${null_resource.bar.id}",
                  "foo_id": "${null_resource.foo.id}"
                }
              ]
            },
            "provisioners": []
          }
        }
      },
      "modules": {
        "foo": {
          "config": {
            "bar": "baz"
          },
          "source": "./foo"
        }
      },
      "providers": {
        "aws": {
          "config": {},
          "version": "~\u003e 1.34",
          "alias": {
            "east": {
              "config": {
                "region": "us-east-1"
              },
              "version": ""
            }
          }
        },
        "null": {
          "config": {},
          "version": "",
          "alias": {}
        }
      },
      "resources": {
        "null_resource": {
          "bar": {
            "config": {
              "triggers": [
                {
                  "foo_id": "${null_resource.foo.id}"
                }
              ]
            },
            "provisioners": []
          },
          "foo": {
            "config": {
              "triggers": [
                {
                  "foo": "bar"
                }
              ]
            },
            "provisioners": [
              {
                "config": {
                  "command": "echo hello"
                },
                "type": "local-exec"
              }
            ]
          }
        }
      },
      "variables": {
        "foo": {
          "default": "bar",
          "description": "foobar"
        },
        "map": {
          "default": {
            "foo": "bar",
            "number": 42
          },
          "description": ""
        },
        "number": {
          "default": "42",
          "description": ""
        }
      }
    }
  }
}