--- policy: /ce/ca/aws/rds/instance-copy-tags-to-snapshot logic: /ce/ca/aws/rds/instance-copy-tags-to-snapshot/prod.logic.yaml executionTime: 2026-02-10T22:33:10.26958704Z generationMs: 57 executionMs: 666 rows: - id: test1 match: true status: expected: DISAPPEARED actual: DISAPPEARED conditionIndex: expected: 99 actual: 99 conditionText: expected: isDisappeared(CA10__disappearanceTime__c) actual: isDisappeared(CA10__disappearanceTime__c) runtimeError: {} - id: test2 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10__status__c') != 'available' actual: extract('CA10__status__c') != 'available' runtimeError: {} - id: test3 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10__clusterArn__c').isNotEmpty() actual: extract('CA10__clusterArn__c').isNotEmpty() runtimeError: {} - id: test4 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: CA10__copyTagsToSnapshot__c == false actual: CA10__copyTagsToSnapshot__c == false runtimeError: {} - id: test5 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: CA10__copyTagsToSnapshot__c == true actual: CA10__copyTagsToSnapshot__c == true runtimeError: {} usedFiles: - path: /ce/ca/aws/rds/instance-copy-tags-to-snapshot/policy.yaml md5Hash: E4CDC4814285E381F2CF955443440D3F content: "---\nnames:\n full: \"AWS RDS Instance is not configured to copy all\ \ tags to snapshots\"\n contextual: \"Instance is not configured to copy all\ \ tags to snapshots\"\ndescription: >\n Ensure that RDS instances have the\ \ Copy Tags to Snapshots setting enabled. \n This practice ensures that database\ \ backups inherit the same metadata as the \n source instance, which is essential\ \ for cost allocation, security labeling, \n and access control consistency.\n\ type: \"COMPLIANCE_POLICY\"\ncategories:\n - \"RELIABILITY\"\nframeworkMappings:\n\ \ - \"/frameworks/cloudaware/resource-reliability/system-configuration\"\n\ \ - \"/frameworks/aws-fsbp-v1.0.0/rds/17\"\nsimilarPolicies:\n awsSecurityHub:\n\ \ - name: \"[RDS.17] RDS DB instances should be configured to copy tags to\ \ snapshots\"\n url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/rds-controls.html#rds-17\"\ \n" - path: /ce/ca/aws/rds/instance-copy-tags-to-snapshot/prod.logic.yaml md5Hash: DC0D4926A98B6B9C14D733598F337949 content: | --- inputType: "CA10__CaAwsDbInstance__c" testData: - file: "test-data.json" importExtracts: - file: "/types/CA10__CaAwsDbInstance__c/object.extracts.yaml" conditions: - status: "INAPPLICABLE" currentStateMessage: "The instance is not available." check: NOT_EQUAL: left: EXTRACT: "CA10__status__c" right: TEXT: "available" - status: "INAPPLICABLE" currentStateMessage: "This policy does not apply to cluster instances." check: NOT_EMPTY: arg: EXTRACT: "CA10__clusterArn__c" - status: "INCOMPLIANT" currentStateMessage: "The RDS instance is not configured to copy tags to snapshots." remediationMessage: "Enable copy tags to snapshots for the RDS instance." check: IS_EQUAL: left: FIELD: path: "CA10__copyTagsToSnapshot__c" right: BOOLEAN: false - status: "COMPLIANT" currentStateMessage: "The RDS instance is configured to copy tags to snapshots." check: IS_EQUAL: left: FIELD: path: "CA10__copyTagsToSnapshot__c" right: BOOLEAN: true otherwise: status: "UNDETERMINED" currentStateMessage: "Unexpected values in the field." - path: /ce/ca/aws/rds/instance-copy-tags-to-snapshot/test-data.json md5Hash: 23A419FCCA58C61563A5CCBD4D8529B8 content: |- [ { "expectedResult": { "runtimeError": null, "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "conditionIndex": 99, "status": "DISAPPEARED" }, "context": { "snapshotTime": "2026-01-30T10:53:34Z" }, "Id": "test1", "CA10__disappearanceTime__c": "2025-08-15T02:09:15Z", "CA10__copyTagsToSnapshot__c": false, "CA10__clusterArn__c": "", "CA10__status__c": "deleting" }, { "expectedResult": { "runtimeError": null, "conditionText": "extract('CA10__status__c') != 'available'", "conditionIndex": 199, "status": "INAPPLICABLE" }, "context": { "snapshotTime": "2026-01-30T10:53:34Z" }, "Id": "test2", "CA10__disappearanceTime__c": null, "CA10__copyTagsToSnapshot__c": true, "CA10__clusterArn__c": "", "CA10__status__c": "" }, { "expectedResult": { "runtimeError": null, "conditionText": "extract('CA10__clusterArn__c').isNotEmpty()", "conditionIndex": 299, "status": "INAPPLICABLE" }, "context": { "snapshotTime": "2026-01-30T10:53:34Z" }, "Id": "test3", "CA10__disappearanceTime__c": null, "CA10__copyTagsToSnapshot__c": false, "CA10__clusterArn__c": "clusterArn", "CA10__status__c": "available" }, { "expectedResult": { "runtimeError": null, "conditionText": "CA10__copyTagsToSnapshot__c == false", "conditionIndex": 399, "status": "INCOMPLIANT" }, "context": { "snapshotTime": "2026-01-30T10:53:34Z" }, "Id": "test4", "CA10__disappearanceTime__c": null, "CA10__copyTagsToSnapshot__c": false, "CA10__clusterArn__c": "", "CA10__status__c": "available" }, { "expectedResult": { "runtimeError": null, "conditionText": "CA10__copyTagsToSnapshot__c == true", "conditionIndex": 499, "status": "COMPLIANT" }, "context": { "snapshotTime": "2026-01-30T10:53:34Z" }, "Id": "test5", "CA10__disappearanceTime__c": null, "CA10__copyTagsToSnapshot__c": true, "CA10__clusterArn__c": "", "CA10__status__c": "available" } ] - path: /types/CA10__CaAwsDbInstance__c/object.extracts.yaml md5Hash: E3FA5A211AA9AD2418645BB09047D3D3 content: "---\nextracts:\n# Not Nullable. Can't have no access, retrieved via\ \ rds:DescribeDBInstances\n - name: CA10__engine__c\n value:\n FIELD:\n\ \ path: CA10__engine__c\n undeterminedIf:\n isEmpty:\ \ \"Corrupted data. DB Instance Engine cannot be empty.\"\n# Not Nullable. Can't\ \ have no access, retrieved via rds:DescribeDBInstances\n - name: CA10__endpointPort__c\n\ \ value:\n FIELD:\n path: CA10__endpointPort__c\n undeterminedIf:\n\ \ isEmpty: \"Corrupted data. DB Endpoint Port cannot be empty.\"\n\ # Checkbox. Can't have no access, retrieved via rds:DescribeDBInstances\n -\ \ name: CA10__publiclyAccessible__c\n value:\n FIELD:\n path:\ \ CA10__publiclyAccessible__c\n# Checkbox. Can't have no access, retrieved via\ \ rds:DescribeDBInstances\n - name: CA10__storageEncrypted__c\n value: \n\ \ FIELD:\n path: CA10__storageEncrypted__c\n# Checkbox. Can't have\ \ no access, retrieved via rds:DescribeDBInstances\n - name: CA10__autoMinorVersionUpgrade__c\n\ \ value: \n FIELD:\n path: CA10__autoMinorVersionUpgrade__c\n\ # Checkbox. Can't have no access, retrieved via rds:DescribeDBInstances\n -\ \ name: CA10__multiAz__c\n value: \n FIELD:\n path: CA10__multiAz__c\n\ # Nullable. Values: available, backing-up, creating ...\n - name: \"CA10__status__c\"\ \n value:\n FIELD:\n path: \"CA10__status__c\"\n# Nullable.\n\ \ - name: \"CA10__createTime__c\"\n value:\n FIELD:\n path:\ \ \"CA10__createTime__c\"\n# Nullable.\n - name: \"CA10__averageCpuOneMonth__c\"\ \n value:\n FIELD:\n path: \"CA10__averageCpuOneMonth__c\"\n\ # Nullable.\n - name: \"CA10__regionName__c\"\n value:\n FIELD:\n \ \ path: \"CA10__regionName__c\"\n# Nullable.\n - name: \"CA10__diskReadIopsAvg30d__c\"\ \n value:\n FIELD:\n path: \"CA10__diskReadIopsAvg30d__c\"\n\ # Nullable.\n - name: \"CA10__diskWriteIopsAvg30d__c\"\n value:\n FIELD:\n\ \ path: \"CA10__diskWriteIopsAvg30d__c\"\n# Nullable.\n - name: \"CA10__databaseConnectionsAvg30d__c\"\ \n value:\n FIELD:\n path: \"CA10__databaseConnectionsAvg30d__c\"\ \n# Not nullable. Can't have no access, retrieved via rds:DescribeDBInstances\n\ \ - name: \"CA10__backupRetentionPeriod__c\"\n value:\n FIELD:\n \ \ path: \"CA10__backupRetentionPeriod__c\"\n# Text.\n - name: CA10__masterUsername__c\n\ \ value:\n FIELD:\n path: CA10__masterUsername__c\n# Checkbox.\n\ \ - name: CA10__iamDatabaseAuthenticationEnabled__c\n value:\n FIELD:\n\ \ path: CA10__iamDatabaseAuthenticationEnabled__c\n# Text.\n - name:\ \ CA10__enabledCloudWatchLogsExports__c\n value:\n FIELD:\n path:\ \ CA10__enabledCloudWatchLogsExports__c\n# Checkbox.\n - name: CA10__deletionProtection__c\n\ \ value:\n FIELD:\n path: CA10__deletionProtection__c\n# Nullable.\ \ Can't have no access, retrieved via rds:DescribeDBInstances\n - name: CA10__clusterArn__c\n\ \ value:\n FIELD:\n path: CA10__clusterArn__c\n# Not nullable.\ \ Can't have no access, retrieved via rds:DescribeDBInstances\n - name: \"\ CA10__monitoringInterval__c\"\n value:\n FIELD:\n path: \"CA10__monitoringInterval__c\"\ \n# Checkbox.\n - name: CA10__copyTagsToSnapshot__c\n value:\n FIELD:\n\ \ path: CA10__copyTagsToSnapshot__c\n" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "runtimeError" : null, "conditionText" : "isDisappeared(CA10__disappearanceTime__c)", "conditionIndex" : 99, "status" : "DISAPPEARED" } }, { "Id" : "test2", "expectedResult" : { "runtimeError" : null, "conditionText" : "extract('CA10__status__c') != 'available'", "conditionIndex" : 199, "status" : "INAPPLICABLE" } }, { "Id" : "test3", "expectedResult" : { "runtimeError" : null, "conditionText" : "extract('CA10__clusterArn__c').isNotEmpty()", "conditionIndex" : 299, "status" : "INAPPLICABLE" } }, { "Id" : "test4", "expectedResult" : { "runtimeError" : null, "conditionText" : "CA10__copyTagsToSnapshot__c == false", "conditionIndex" : 399, "status" : "INCOMPLIANT" } }, { "Id" : "test5", "expectedResult" : { "runtimeError" : null, "conditionText" : "CA10__copyTagsToSnapshot__c == true", "conditionIndex" : 499, "status" : "COMPLIANT" } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsDbInstance__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-01-30T10:53:34Z") }, "CA10__disappearanceTime__c" : new Date("2025-08-15T02:09:15Z"), "CA10__status__c" : "deleting", "CA10__clusterArn__c" : "", "CA10__copyTagsToSnapshot__c" : false, "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2026-01-30T10:53:34Z") }, "CA10__status__c" : "", "CA10__clusterArn__c" : "", "CA10__copyTagsToSnapshot__c" : true, "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2026-01-30T10:53:34Z") }, "CA10__status__c" : "available", "CA10__clusterArn__c" : "clusterArn", "CA10__copyTagsToSnapshot__c" : false, "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2026-01-30T10:53:34Z") }, "CA10__status__c" : "available", "CA10__clusterArn__c" : "", "CA10__copyTagsToSnapshot__c" : false, "Id" : "test4" }, { "context" : { "snapshotTime" : new Date("2026-01-30T10:53:34Z") }, "CA10__status__c" : "available", "CA10__clusterArn__c" : "", "CA10__copyTagsToSnapshot__c" : true, "Id" : "test5" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsDbInstance__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__status__c STRING, CA10__clusterArn__c STRING, CA10__copyTagsToSnapshot__c BOOLEAN, 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__status__c; } return this.out; }; references1.push('Status [obj.CA10__status__c]: ' + obj.CA10__status__c); if (TextLib.notEqual(extract3.call(extract3), 'available')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__status__c') != 'available'", currentStateMessage: "The instance is not available.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract6() { if (!this.out) { this.out = obj.CA10__clusterArn__c; } return this.out; }; references1.push('Cluster ARN [obj.CA10__clusterArn__c]: ' + obj.CA10__clusterArn__c); if (TextLib.isNotEmpty(extract6.call(extract6))) { return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10__clusterArn__c').isNotEmpty()", currentStateMessage: "This policy does not apply to cluster instances.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[3], conditionIndex:[300..399] references1.push('Copy Tags To Snapshot [obj.CA10__copyTagsToSnapshot__c]: ' + obj.CA10__copyTagsToSnapshot__c); if (obj.CA10__copyTagsToSnapshot__c == false) { return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "CA10__copyTagsToSnapshot__c == false", currentStateMessage: "The RDS instance is not configured to copy tags to snapshots.", currentStateReferences: references1.join('\n'), remediation: "Enable copy tags to snapshots for the RDS instance.", runtimeError: null}; } // condition[4], conditionIndex:[400..499] if (obj.CA10__copyTagsToSnapshot__c == true) { return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "CA10__copyTagsToSnapshot__c == true", currentStateMessage: "The RDS instance is configured to copy tags to snapshots.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'UNDETERMINED', conditionIndex: 500, conditionText: "otherwise", currentStateMessage: "Unexpected values in the field.", 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__status__c AS CA10__status__c, sObject.CA10__clusterArn__c AS CA10__clusterArn__c, sObject.CA10__copyTagsToSnapshot__c AS CA10__copyTagsToSnapshot__c, sObject.Id AS Id, process_CA10__CaAwsDbInstance__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__status__c AS CA10__status__c, sObject.CA10__clusterArn__c AS CA10__clusterArn__c, sObject.CA10__copyTagsToSnapshot__c AS CA10__copyTagsToSnapshot__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsDbInstance__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;