--- policy: /ce/ca/aws/ec2/elastic-ip-unused logic: /ce/ca/aws/ec2/elastic-ip-unused/prod.logic.yaml executionTime: 2026-02-10T22:32:41.82584917Z generationMs: 49 executionMs: 723 rows: - id: '001' match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10__associationId__c').isEmpty() actual: extract('CA10__associationId__c').isEmpty() runtimeError: {} - id: '002' match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/ec2/elastic-ip-unused/policy.yaml md5Hash: 327AB5F17E16596B740A0F0F38B667F7 content: "---\nnames:\n full: AWS EC2 Elastic IP is unused\n contextual: Elastic\ \ IP is unused\ndescription: >\n Identify and release unused Elastic IP addresses\ \ to avoid unnecessary charges. \n Elastic IPs that are allocated but not associated\ \ with a running resource incur costs.\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n\ \ - \"COST\"\nframeworkMappings:\n - \"/frameworks/cloudaware/cost-efficiency-and-optimization/waste-reduction\"" - path: /ce/ca/aws/ec2/elastic-ip-unused/prod.logic.yaml md5Hash: 75D74A1ADB76BA22DA440E05CC6FA0F7 content: | --- inputType: "CA10__CaAwsElasticIp__c" importExtracts: - file: "/types/CA10__CaAwsElasticIp__c/object.extracts.yaml" testData: - file: 'test-data.json' conditions: - status: INCOMPLIANT currentStateMessage: "The Elastic IP address is not associated with any EC2 instance or network interface." remediationMessage: "Release the unused Elastic IP address." check: IS_EMPTY: arg: EXTRACT: CA10__associationId__c otherwise: status: "COMPLIANT" currentStateMessage: "The Elastic IP address is in use." - path: /ce/ca/aws/ec2/elastic-ip-unused/test-data.json md5Hash: E3FE86128D26B54B7E67B935D70AD22F content: | [ { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "extract('CA10__associationId__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2025-09-01T16:12:36Z" }, "Id": "001", "CA10__disappearanceTime__c": null, "CA10__associationId__c": "" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-09-01T16:12:36Z" }, "Id": "002", "CA10__disappearanceTime__c": null, "CA10__associationId__c": "associationId" } ] - path: /types/CA10__CaAwsElasticIp__c/object.extracts.yaml md5Hash: F70A967FFE6C3B6C7D48474507307B38 content: |- --- extracts: # Nullable. - name: "CA10__associationId__c" value: FIELD: path: "CA10__associationId__c" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "001", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "199", "conditionText" : "extract('CA10__associationId__c').isEmpty()", "runtimeError" : null } }, { "Id" : "002", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsElasticIp__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-09-01T16:12:36Z") }, "CA10__associationId__c" : "", "Id" : "001" }, { "context" : { "snapshotTime" : new Date("2025-09-01T16:12:36Z") }, "CA10__associationId__c" : "associationId", "Id" : "002" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsElasticIp__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__associationId__c STRING, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT 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 extract3() { if (!this.out) { this.out = obj.CA10__associationId__c; } return this.out; }; references1.push('Association ID [obj.CA10__associationId__c]: ' + obj.CA10__associationId__c); if (TextLib.isEmpty(extract3.call(extract3))) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__associationId__c').isEmpty()", currentStateMessage: "The Elastic IP address is not associated with any EC2 instance or network interface.", currentStateReferences: references1.join('\n'), remediation: "Release the unused Elastic IP address.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "The Elastic IP address is in use.", 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__associationId__c AS CA10__associationId__c, sObject.Id AS Id, process_CA10__CaAwsElasticIp__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__associationId__c AS CA10__associationId__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsElasticIp__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;