---
policy: /ce/ca/aws/eks/cluster-oidc-provider
logic: /ce/ca/aws/eks/cluster-oidc-provider/prod.logic.yaml
executionTime: 2025-06-28T12:02:54.080804121Z
rows:
  - id: test
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10A1__disappearanceTime__c)
      actual: isDisappeared(CA10A1__disappearanceTime__c)
    runtimeError: {}
  - id: test2
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10A1__AWS_IAM_OpenID_Connect_Providers__r.hasNo(COMPLIANT)
      actual: CA10A1__AWS_IAM_OpenID_Connect_Providers__r.hasNo(COMPLIANT)
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10A1__AWS_IAM_OpenID_Connect_Providers__r.hasNo(COMPLIANT)
      actual: CA10A1__AWS_IAM_OpenID_Connect_Providers__r.hasNo(COMPLIANT)
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10A1__AWS_IAM_OpenID_Connect_Providers__r.has(COMPLIANT)
      actual: CA10A1__AWS_IAM_OpenID_Connect_Providers__r.has(COMPLIANT)
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/eks/cluster-oidc-provider/policy.yaml
    md5Hash: A3B7EFFF4184D0FD38DF04CBFD71FCA5
    content: "names:\n  full: \"AWS EKS Cluster IAM OIDC provider is not created\"\
      \n  contextual: \"Cluster IAM OIDC provider is not created\"\ndescription: >\n\
      \  Ensure that AWS EKS clusters have an OpenID Connect (OIDC) provider configured.\
      \ \n  This is required to enable IAM Roles for Service Accounts (IRSA), which\
      \ allows \n  IAM roles to be securely assigned to Kubernetes service accounts\
      \ for \n  fine-grained access to AWS resources.\ncategories:\n  - \"SECURITY\"\
      \ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n  - \"/frameworks/cloudaware/identity-and-access-governance/rbac-management\"\
      \n  - \"/frameworks/cloudaware/resource-security/secure-access\""
  - path: /ce/ca/aws/eks/cluster-oidc-provider/prod.logic.yaml
    md5Hash: 9D0888D7E548327EF4F3225D53D1BF94
    content: "inputType: \"CA10A1__CaAwsEksCluster__c\"\nimportExtracts:\n  - file:\
      \ \"/types/CA10A1__CaAwsEksCluster__c/object.extracts.yaml\"\ntestData:\n  -\
      \ file: \"test-data.json\"\nconditions:\n  - status: \"INCOMPLIANT\"\n    currentStateMessage:\
      \ \"The Cluster has no IAM OpenID Connect Provider.\"\n    remediationMessage:\
      \ \"Consider creating an IAM OIDC provider for the Cluster.\"\n    check:\n\
      \      RELATED_LIST_HAS_NO:\n        status: \"COMPLIANT\"\n        relationshipName:\
      \ \"CA10A1__AWS_IAM_OpenID_Connect_Providers__r\"\n  - status: \"COMPLIANT\"\
      \n    currentStateMessage: \"The Cluster has an IAM OpenID Connect Provider.\"\
      \n    check:\n      RELATED_LIST_HAS:\n        status: \"COMPLIANT\"\n     \
      \   relationshipName: \"CA10A1__AWS_IAM_OpenID_Connect_Providers__r\"\notherwise:\n\
      \  status: \"COMPLIANT\" \n  currentStateMessage: \"\"\nrelatedLists:\n  - relationshipName:\
      \ \"CA10A1__AWS_IAM_OpenID_Connect_Providers__r\"\n    conditions: []\n    otherwise:\n\
      \      status: \"COMPLIANT\"\n      currentStateMessage: \"This is an IAM OpenID\
      \ Connect Provider.\""
  - path: /ce/ca/aws/eks/cluster-oidc-provider/test-data.json
    md5Hash: 8EC08D90EF7405093EDFBE33F2E97B34
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10A1__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-26T03:04:55Z"
              },
              "Id": "test",
              "CA10A1__disappearanceTime__c": "2025-05-26T03:04:55Z",
              "CA10A1__AWS_IAM_OpenID_Connect_Providers__r": [
                  {
                      "Id": "test1_1",
                      "CA10A1__disappearanceTime__c": null,
                      "CA10A1__eksCluster__c": "test1"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10A1__AWS_IAM_OpenID_Connect_Providers__r.hasNo(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-26T03:04:55Z"
              },
              "Id": "test2",
              "CA10A1__disappearanceTime__c": null,
              "CA10A1__AWS_IAM_OpenID_Connect_Providers__r": [
                  {
                      "Id": "test2_1",
                      "CA10A1__disappearanceTime__c": "2025-05-26T03:04:55Z",
                      "CA10A1__eksCluster__c": "test2"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10A1__AWS_IAM_OpenID_Connect_Providers__r.hasNo(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-26T03:04:55Z"
              },
              "Id": "test3",
              "CA10A1__disappearanceTime__c": null,
              "CA10A1__AWS_IAM_OpenID_Connect_Providers__r": []
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "CA10A1__AWS_IAM_OpenID_Connect_Providers__r.has(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-05-26T03:04:55Z"
              },
              "Id": "test4",
              "CA10A1__disappearanceTime__c": null,
              "CA10A1__AWS_IAM_OpenID_Connect_Providers__r": [
                  {
                      "Id": "test4_1",
                      "CA10A1__disappearanceTime__c": null,
                      "CA10A1__eksCluster__c": "test4"
                  }
              ]
          }
      ]
  - path: /types/CA10A1__CaAwsEksCluster__c/object.extracts.yaml
    md5Hash: 601E751040B9EB5B832935218E31F406
    content: "---\nextracts:\n#Values: Enabled | Disabled. Not Nullable.\n  - name:\
      \ CA10A1__endpointPublicAccess__c\n    value: \n      FIELD:\n        path:\
      \ CA10A1__endpointPublicAccess__c\n        undeterminedIf:\n          noAccessDelegate:\n\
      \            path: CA10A1__endpointPublicAccess__c\n            currentStateMessage:\
      \ \"Endpoint Public Access cannot be empty. Possible permission issues with\
      \ eks:DescribeCluster.\"\n#LONG_TEXT_AREA with IP addresses divided by \\n.\
      \ Nullable\n  - name: CA10A1__publicAccessCidrs__c\n    value: \n      FIELD:\n\
      \        path: CA10A1__publicAccessCidrs__c\n#Values: array of strings\n   \
      \   # api: Enabled\\n\n      # audit: Enabled\\n\n      # authenticator: Enabled\\\
      n\n      # controllerManager: Enabled\\n\n      # scheduler: Enabled\\n\n  -\
      \ name: CA10A1__logging__c\n    value: \n      FIELD:\n        path: CA10A1__logging__c\n\
      \        undeterminedIf:\n          noAccessDelegate:\n            path: CA10A1__logging__c\n\
      \            currentStateMessage: \"Cluster Logging cannot be empty. Possible\
      \ permission issues with eks:DescribeCluster.\"\n  - name: caExtract_logging_asCollection__c\n\
      \    value:\n      COLLECTION_FROM:\n        separator: \"\\n\"\n        emptyValues:\
      \ SKIP\n        duplicateValues: SKIP\n        ordering: SORTED\n        arg:\
      \ \n          EXTRACT: \"CA10A1__logging__c\""
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" : "test",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10A1__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10A1__AWS_IAM_OpenID_Connect_Providers__r.hasNo(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10A1__AWS_IAM_OpenID_Connect_Providers__r.hasNo(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10A1__AWS_IAM_OpenID_Connect_Providers__r.has(COMPLIANT)",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10A1__CaAwsEksCluster__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10A1__disappearanceTime__c TIMESTAMP,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-05-26T03:04:55Z")
    },
    "Id" : "test",
    "CA10A1__disappearanceTime__c" : new Date("2025-05-26T03:04:55Z")
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-26T03:04:55Z")
    },
    "Id" : "test2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-26T03:04:55Z")
    },
    "Id" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-26T03:04:55Z")
    },
    "Id" : "test4"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10A1__CaAwsIamOpenIdConnectProvider__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10A1__disappearanceTime__c TIMESTAMP,
      CA10A1__eksCluster__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-05-26T03:04:55Z")
    },
    "Id" : "test1_1",
    "CA10A1__eksCluster__c" : "test1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-26T03:04:55Z")
    },
    "Id" : "test2_1",
    "CA10A1__disappearanceTime__c" : new Date("2025-05-26T03:04:55Z"),
    "CA10A1__eksCluster__c" : "test2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-05-26T03:04:55Z")
    },
    "Id" : "test4_1",
    "CA10A1__eksCluster__c" : "test4"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10A1__CaAwsEksCluster__c(
      obj STRUCT<
          Id STRING,
          CA10A1__disappearanceTime__c TIMESTAMP,
          CA10A1__AWS_IAM_OpenID_Connect_Providers__r ARRAY<STRUCT<
              Id STRING,
              CA10A1__disappearanceTime__c TIMESTAMP,
              CA10A1__eksCluster__c STRING,
              result STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError 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 references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10A1__disappearanceTime__c]: ' + obj.CA10A1__disappearanceTime__c);
      if (obj.CA10A1__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10A1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10A1__AWS_IAM_OpenID_Connect_Providers__r_COMPLIANT2 = 0;
      if (obj.CA10A1__AWS_IAM_OpenID_Connect_Providers__r != null) {
          for (var i3 = 0; i3 < obj.CA10A1__AWS_IAM_OpenID_Connect_Providers__r.length; i3++) {
              if (obj.CA10A1__AWS_IAM_OpenID_Connect_Providers__r[i3].result.status == 'COMPLIANT') {
                  count_CA10A1__AWS_IAM_OpenID_Connect_Providers__r_COMPLIANT2 += 1;
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10A1__AWS_IAM_OpenID_Connect_Providers__r] ' + (count_CA10A1__AWS_IAM_OpenID_Connect_Providers__r_COMPLIANT2 == 0 ? 'does not have' : 'has') + ' objects in COMPLIANT status');
      if (count_CA10A1__AWS_IAM_OpenID_Connect_Providers__r_COMPLIANT2 == 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10A1__AWS_IAM_OpenID_Connect_Providers__r.hasNo(COMPLIANT)", currentStateMessage: "The Cluster has no IAM OpenID Connect Provider.", currentStateReferences: references1.join('\n'), remediation: "Consider creating an IAM OIDC provider for the Cluster.", runtimeError: null};
      }
      var count_CA10A1__AWS_IAM_OpenID_Connect_Providers__r_COMPLIANT2 = 0;
      if (obj.CA10A1__AWS_IAM_OpenID_Connect_Providers__r != null) {
          for (var i4 = 0; i4 < obj.CA10A1__AWS_IAM_OpenID_Connect_Providers__r.length; i4++) {
              if (obj.CA10A1__AWS_IAM_OpenID_Connect_Providers__r[i4].result.status == 'COMPLIANT') {
                  count_CA10A1__AWS_IAM_OpenID_Connect_Providers__r_COMPLIANT2 += 1;
              }
          }
      }
      // condition[2], conditionIndex:[200..299]
      if (count_CA10A1__AWS_IAM_OpenID_Connect_Providers__r_COMPLIANT2 > 0) {
          return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "CA10A1__AWS_IAM_OpenID_Connect_Providers__r.has(COMPLIANT)", currentStateMessage: "The Cluster has an IAM OpenID Connect Provider.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10A1__AWS_IAM_OpenID_Connect_Providers__r(
      obj STRUCT<
          Id STRING,
          CA10A1__disappearanceTime__c TIMESTAMP,
          CA10A1__eksCluster__c 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 references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10A1__disappearanceTime__c]: ' + obj.CA10A1__disappearanceTime__c);
      if (obj.CA10A1__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10A1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 100, conditionText: "otherwise", currentStateMessage: "This is an IAM OpenID Connect Provider.", 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.Id AS Id,
          sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c,
          `CA10A1__AWS_IAM_OpenID_Connect_Providers__r`.arr AS CA10A1__AWS_IAM_OpenID_Connect_Providers__r,
          process_CA10A1__CaAwsEksCluster__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c,
                  `CA10A1__AWS_IAM_OpenID_Connect_Providers__r`.arr AS CA10A1__AWS_IAM_OpenID_Connect_Providers__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10A1__CaAwsEksCluster__c()) AS sObject
      LEFT JOIN (
          SELECT
              sObject.CA10A1__eksCluster__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c,
                      sObject.CA10A1__eksCluster__c AS CA10A1__eksCluster__c,
                      process_CA10A1__AWS_IAM_OpenID_Connect_Providers__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c,
                              sObject.CA10A1__eksCluster__c AS CA10A1__eksCluster__c
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10A1__CaAwsIamOpenIdConnectProvider__c()) AS sObject
          GROUP BY sObject.CA10A1__eksCluster__c
      ) AS `CA10A1__AWS_IAM_OpenID_Connect_Providers__r`
          ON sObject.Id = `CA10A1__AWS_IAM_OpenID_Connect_Providers__r`.CA10A1__eksCluster__c
  ) sObject ON sObject.Id = expectedResult.Id;
