---
policy: /ce/ca/aws/mq/activemq-broker-deployment-mode
logic: /ce/ca/aws/mq/activemq-broker-deployment-mode/prod.logic.yaml
executionTime: 2026-01-31T12:02:06.286742432Z
generationMs: 69
executionMs: 718
rows:
  - id: '001'
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__engineType__c') != 'ActiveMQ'
      actual: extract('CA10__engineType__c') != 'ActiveMQ'
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__deploymentMode__c') == 'ACTIVE_STANDBY_MULTI_AZ'
      actual: extract('CA10__deploymentMode__c') == 'ACTIVE_STANDBY_MULTI_AZ'
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10__deploymentMode__c') == 'SINGLE_INSTANCE'
      actual: extract('CA10__deploymentMode__c') == 'SINGLE_INSTANCE'
    runtimeError: {}
  - id: '004'
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 400
      actual: 400
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/mq/activemq-broker-deployment-mode/policy.yaml
    md5Hash: DADE251304BE48276EFB985942C15215
    content: "---\nnames:\n  full: AWS MQ ActiveMQ Broker uses the single instance\
      \ deployment mode\n  contextual: ActiveMQ Broker uses the single instance deployment\
      \ mode\ndescription: >\n  Ensure that Amazon MQ ActiveMQ brokers are configured\
      \ with high availability. \n  Active/standby deployment mode is recommended\
      \ for production environments to \n  provide redundancy and ensure continuity\
      \ of service if a broker instance fails \n  or undergoes maintenance.\ntype:\
      \ \"COMPLIANCE_POLICY\"\ncategories:\n  - RELIABILITY\nframeworkMappings:\n\
      \  - \"/frameworks/cloudaware/resource-reliability/system-configuration\"\n\
      \  - \"/frameworks/nist-sp-800-53-r5/cp/10\"\n  - \"/frameworks/nist-sp-800-53-r5/cp/06/02\"\
      \n  - \"/frameworks/nist-sp-800-53-r5/sc/36\"\n  - \"/frameworks/nist-sp-800-53-r5/sc/05/02\"\
      \n  - \"/frameworks/nist-sp-800-53-r5/si/13/05\"\nsimilarPolicies:\n  cloudConformity:\n\
      \    - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/aws/MQ/deployment-mode.html\n\
      \      name: MQ Deployment Mode\n"
  - path: /ce/ca/aws/mq/activemq-broker-deployment-mode/prod.logic.yaml
    md5Hash: 418A6CA373597F6E0F5EEDABF5AFDCF7
    content: "---\ninputType: \"CA10__CaAwsMqBroker__c\"\ntestData:\n  - file: test-data.json\n\
      importExtracts:\n  - file: /types/CA10__CaAwsMqBroker__c/object.extracts.yaml\n\
      conditions:\n  - status: \"INAPPLICABLE\"\n    currentStateMessage: \"This policy\
      \ applies only to ActiveMQ brokers.\"\n    check:\n      NOT_EQUAL:\n      \
      \  left:\n          EXTRACT: CA10__engineType__c\n        right:\n         \
      \ TEXT: \"ActiveMQ\"\n  - status: \"COMPLIANT\"\n    currentStateMessage: \"\
      The ActiveMQ Broker is using the active/standby deployment mode.\"\n    check:\n\
      \      IS_EQUAL:\n        left:\n          EXTRACT: CA10__deploymentMode__c\n\
      \        right:\n          TEXT: \"ACTIVE_STANDBY_MULTI_AZ\"\n  - status: \"\
      INCOMPLIANT\"\n    currentStateMessage: \"The ActiveMQ Broker is using the single-instance\
      \ deployment mode.\"\n    remediationMessage: \"Consider migrating to the active/standby\
      \ deployment mode.\"\n    check:\n      IS_EQUAL:\n        left:\n         \
      \ EXTRACT: CA10__deploymentMode__c\n        right:\n          TEXT: \"SINGLE_INSTANCE\"\
      \notherwise:\n  status: \"UNDETERMINED\"\n  currentStateMessage: \"Unexpected\
      \ Amazon MQ ActiveMQ Broker deployment mode value.\"\n  \n\n  "
  - path: /ce/ca/aws/mq/activemq-broker-deployment-mode/test-data.json
    md5Hash: F449D02AD35672B4933CF71AB97D4246
    content: |
      [
        {
          "expectedResult": {
            "status": "INAPPLICABLE",
            "conditionIndex": "199",
            "conditionText": "extract('CA10__engineType__c') != 'ActiveMQ'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-01T00:50:53Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__engineType__c": "RabbitMQ",
          "CA10__deploymentMode__c": "CLUSTER_MULTI_AZ",
          "Id": "001"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "299",
            "conditionText": "extract('CA10__deploymentMode__c') == 'ACTIVE_STANDBY_MULTI_AZ'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-01T00:50:53Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__engineType__c": "ActiveMQ",
          "CA10__deploymentMode__c": "ACTIVE_STANDBY_MULTI_AZ",
          "Id": "002"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "399",
            "conditionText": "extract('CA10__deploymentMode__c') == 'SINGLE_INSTANCE'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-01T00:50:53Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__engineType__c": "ActiveMQ",
          "CA10__deploymentMode__c": "SINGLE_INSTANCE",
          "Id": "003"
        },
        {
          "expectedResult": {
            "status": "UNDETERMINED",
            "conditionIndex": "400",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-01T00:50:53Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__engineType__c": "ActiveMQ",
          "CA10__deploymentMode__c": null,
          "Id": "004"
        }
      ]
  - path: /types/CA10__CaAwsMqBroker__c/object.extracts.yaml
    md5Hash: 1D91E5184493B4B1AF50FC5A1E53B744
    content: "---\nextracts:\n  # Checkbox.\n  - name: CA10__publiclyAccessible__c\n\
      \    value: \n      FIELD:\n        path: CA10__publiclyAccessible__c\n  # Checkbox.\n\
      \  - name: CA10__autoMinorVersionUpgrade__c\n    value: \n      FIELD:\n   \
      \     path: CA10__autoMinorVersionUpgrade__c\n  # Text.\n  - name: CA10__deploymentMode__c\n\
      \    value: \n      FIELD:\n        path: CA10__deploymentMode__c\n# Values:\
      \ Enabled | Disabled. Nullable.\n  - name: \"CA10__logsAudit__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10__logsAudit__c\"\n# Values: ACTIVEMQ |\
      \ RABBITMQ. Not nullable. \n  - name: \"CA10__engineType__c\"\n    value: \n\
      \      FIELD:\n        path: \"CA10__engineType__c\"\n        undeterminedIf:\n\
      \          noAccessDelegate:\n            path: \"CA10__engineType__c\"\n  \
      \          currentStateMessage: \"Broker Engine type cannot be empty. Possible\
      \ permission issue with mq:DescribeBroker.\"\n"
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "001",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__engineType__c') != 'ActiveMQ'",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__deploymentMode__c') == 'ACTIVE_STANDBY_MULTI_AZ'",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10__deploymentMode__c') == 'SINGLE_INSTANCE'",
      "runtimeError" : null
    }
  }, {
    "Id" : "004",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "400",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsMqBroker__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__engineType__c STRING,
      CA10__deploymentMode__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-12-01T00:50:53Z")
    },
    "CA10__engineType__c" : "RabbitMQ",
    "CA10__deploymentMode__c" : "CLUSTER_MULTI_AZ",
    "Id" : "001"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-01T00:50:53Z")
    },
    "CA10__engineType__c" : "ActiveMQ",
    "CA10__deploymentMode__c" : "ACTIVE_STANDBY_MULTI_AZ",
    "Id" : "002"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-01T00:50:53Z")
    },
    "CA10__engineType__c" : "ActiveMQ",
    "CA10__deploymentMode__c" : "SINGLE_INSTANCE",
    "Id" : "003"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-01T00:50:53Z")
    },
    "CA10__engineType__c" : "ActiveMQ",
    "CA10__deploymentMode__c" : null,
    "Id" : "004"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsMqBroker__c(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__engineType__c STRING,
          CA10__deploymentMode__c STRING,
          Id STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
  var TextLib = new function () {
      this.normalize = function(arg) {
          return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase();
      };
      this.isEmpty = function(arg) {
          return this.normalize(arg) == '';
      };
      this.isNotEmpty = function(arg) {
          return this.normalize(arg) != '';
      };
      this.equal = function(left, right) {
          return this.normalize(left) == this.normalize(right);
      };
      this.notEqual = function(left, right) {
          return this.normalize(left) != this.normalize(right);
      };
      this.startsWith = function(arg, substring) {
          return this.normalize(arg).startsWith(this.normalize(substring));
      };
      this.endsWith = function(arg, substring) {
          return this.normalize(arg).endsWith(this.normalize(substring));
      };
      this.contains = function(arg, substring) {
          return this.normalize(arg).includes(this.normalize(substring));
      };
      this.containsAll = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
      };
      this.containsAny = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
      };
  }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c);
      if (obj.CA10__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function fieldChecked4() {
          if (TextLib.isEmpty(obj.CA10__engineType__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__engineType__c.delegatedTo(CA10__engineType__c).isEmpty()", currentStateMessage: "Broker Engine type cannot be empty. Possible permission issue with mq:DescribeBroker.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__engineType__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Engine Type [obj.CA10__engineType__c]: ' + obj.CA10__engineType__c);
      try {
          if (TextLib.notEqual(extract3.call(extract3), 'ActiveMQ')) {
              return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__engineType__c') != 'ActiveMQ'", currentStateMessage: "This policy applies only to ActiveMQ brokers.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function extract6() { if (!this.out) { this.out = obj.CA10__deploymentMode__c; } return this.out; };
      references1.push('Deployment Mode [obj.CA10__deploymentMode__c]: ' + obj.CA10__deploymentMode__c);
      if (TextLib.equal(extract6.call(extract6), 'ACTIVE_STANDBY_MULTI_AZ')) {
          return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__deploymentMode__c') == 'ACTIVE_STANDBY_MULTI_AZ'", currentStateMessage: "The ActiveMQ Broker is using the active/standby deployment mode.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      function extract9() { if (!this.out) { this.out = obj.CA10__deploymentMode__c; } return this.out; };
      if (TextLib.equal(extract9.call(extract9), 'SINGLE_INSTANCE')) {
          return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__deploymentMode__c') == 'SINGLE_INSTANCE'", currentStateMessage: "The ActiveMQ Broker is using the single-instance deployment mode.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating to the active/standby deployment mode.", runtimeError: null};
      }
      return {status: 'UNDETERMINED', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "Unexpected Amazon MQ ActiveMQ Broker deployment mode value.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;


  SELECT
    expectedResult.Id as Id,
    IF (
      IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '')
      AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1)
      AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '')
      AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''),
      "MATCH",
      "FAIL"
    ) as match,
    expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus,
    expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex,
    expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText,
    expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError
  FROM UNNEST(mock_ExpectedResult()) expectedResult
  LEFT JOIN (
      SELECT
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__engineType__c AS CA10__engineType__c,
          sObject.CA10__deploymentMode__c AS CA10__deploymentMode__c,
          sObject.Id AS Id,
          process_CA10__CaAwsMqBroker__c(
              STRUCT(
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__engineType__c AS CA10__engineType__c,
                  sObject.CA10__deploymentMode__c AS CA10__deploymentMode__c,
                  sObject.Id AS Id
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsMqBroker__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
