Skip to content

Commit 97f33a7

Browse files
committed
use destroy value to check destroyed resources
1 parent ea126da commit 97f33a7

20 files changed

+60
-40
lines changed

governance/second-generation/aws/enforce-mandatory-tags.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ validate_attribute_contains_list = func(type, attribute, required_values) {
5555
for resource_instances as address, r {
5656

5757
# Skip resource instances that are being destroyed
58-
# to avoid unnecessary policy violations
59-
if length(r.diff) == 0 {
58+
# to avoid unnecessary policy violations.
59+
# Used to be: if length(r.diff) == 0
60+
if r.destroy {
6061
print("Skipping resource", address, "that is being destroyed.")
6162
continue
6263
}

governance/second-generation/aws/require-private-acl-and-kms-for-s3-buckets.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ validate_private_acl_and_kms_encryption = func() {
5757
for resource_instances as address, r {
5858

5959
# Skip resources that are being destroyed
60-
# to avoid unnecessary policy violations
61-
if length(r.diff) == 0 {
60+
# to avoid unnecessary policy violations.
61+
# Used to be: if length(r.diff) == 0
62+
if r.destroy {
6263
print("Skipping resource", address, "that is being destroyed.")
6364
continue
6465
}

governance/second-generation/aws/restrict-availability-zones.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ validate_attribute_in_list = func(type, attribute, allowed_values) {
5353
for resource_instances as address, r {
5454

5555
# Skip resource instances that are being destroyed
56-
# to avoid unnecessary policy violations
57-
if length(r.diff) == 0 {
56+
# to avoid unnecessary policy violations.
57+
# Used to be: if length(r.diff) == 0
58+
if r.destroy {
5859
print("Skipping resource", address, "that is being destroyed.")
5960
continue
6061
}

governance/second-generation/aws/restrict-db-instance-engines.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ validate_attribute_in_list = func(type, attribute, allowed_values) {
5252
for resource_instances as address, r {
5353

5454
# Skip resource instances that are being destroyed
55-
# to avoid unnecessary policy violations
56-
if length(r.diff) == 0 {
55+
# to avoid unnecessary policy violations.
56+
# Used to be: if length(r.diff) == 0
57+
if r.destroy {
5758
print("Skipping resource", address, "that is being destroyed.")
5859
continue
5960
}

governance/second-generation/aws/restrict-ec2-instance-type.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ validate_attribute_in_list = func(type, attribute, allowed_values) {
5252
for resource_instances as address, r {
5353

5454
# Skip resource instances that are being destroyed
55-
# to avoid unnecessary policy violations
56-
if length(r.diff) == 0 {
55+
# to avoid unnecessary policy violations.
56+
# Used to be: if length(r.diff) == 0
57+
if r.destroy {
5758
print("Skipping resource", address, "that is being destroyed.")
5859
continue
5960
}

governance/second-generation/aws/restrict-ingress-sg-rule-cidr-blocks.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ validate_sgr_cidr_blocks = func() {
5353
for resource_instances as address, r {
5454

5555
# Skip resources that are being destroyed
56-
# to avoid unnecessary policy violations
57-
if length(r.diff) == 0 {
56+
# to avoid unnecessary policy violations.
57+
# Used to be: if length(r.diff) == 0
58+
if r.destroy {
5859
print("Skipping resource", address, "that is being destroyed.")
5960
continue
6061
}

governance/second-generation/aws/restrict-launch-configuration-instance-type.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ validate_instance_types = func(allowed_types) {
5959
for resource_instances as address, r {
6060

6161
# Skip resource instances that are being destroyed
62-
# to avoid unnecessary policy violations
63-
if length(r.diff) == 0 {
62+
# to avoid unnecessary policy violations.
63+
# Used to be: if length(r.diff) == 0
64+
if r.destroy {
6465
print("Skipping resource", address, "that is being destroyed.")
6566
continue
6667
}

governance/second-generation/azure/enforce-mandatory-tags.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ validate_attribute_contains_list = func(type, attribute, required_values) {
5656
for resource_instances as address, r {
5757

5858
# Skip resource instances that are being destroyed
59-
# to avoid unnecessary policy violations
60-
if length(r.diff) == 0 {
59+
# to avoid unnecessary policy violations.
60+
# Used to be: if length(r.diff) == 0
61+
if r.destroy {
6162
print("Skipping resource", address, "that is being destroyed.")
6263
continue
6364
}

governance/second-generation/azure/restrict-app-service-to-https.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ validate_attribute_has_value = func(type, attribute, value) {
5353
for resource_instances as address, r {
5454

5555
# Skip resource instances that are being destroyed
56-
# to avoid unnecessary policy violations
57-
if length(r.diff) == 0 {
56+
# to avoid unnecessary policy violations.
57+
# Used to be: if length(r.diff) == 0
58+
if r.destroy {
5859
print("Skipping resource", address, "that is being destroyed.")
5960
continue
6061
}

governance/second-generation/azure/restrict-vm-size.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ validate_attribute_in_list = func(type, attribute, allowed_values) {
5252
for resource_instances as address, r {
5353

5454
# Skip resource instances that are being destroyed
55-
# to avoid unnecessary policy violations
56-
if length(r.diff) == 0 {
55+
# to avoid unnecessary policy violations.
56+
# Used to be: if length(r.diff) == 0
57+
if r.destroy {
5758
print("Skipping resource", address, "that is being destroyed.")
5859
continue
5960
}

governance/second-generation/common-functions/plan/validate_attribute_contains_list.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ validate_attribute_contains_list = func(type, attribute, required_values) {
1010
for resource_instances as address, r {
1111

1212
# Skip resource instances that are being destroyed
13-
# to avoid unnecessary policy violations
14-
if length(r.diff) == 0 {
13+
# to avoid unnecessary policy violations.
14+
# Used to be: if length(r.diff) == 0
15+
if r.destroy {
1516
print("Skipping resource", address, "that is being destroyed.")
1617
continue
1718
}

governance/second-generation/common-functions/plan/validate_attribute_greater_than_value.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ validate_attribute_greater_than_value = func(type, attribute, min_value) {
1111
for resource_instances as address, r {
1212

1313
# Skip resource instances that are being destroyed
14-
# to avoid unnecessary policy violations
15-
if length(r.diff) == 0 {
14+
# to avoid unnecessary policy violations.
15+
# Used to be: if length(r.diff) == 0
16+
if r.destroy {
1617
print("Skipping resource", address, "that is being destroyed.")
1718
continue
1819
}

governance/second-generation/common-functions/plan/validate_attribute_has_value.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ validate_attribute_has_value = func(type, attribute, value) {
1111
for resource_instances as address, r {
1212

1313
# Skip resource instances that are being destroyed
14-
# to avoid unnecessary policy violations
15-
if length(r.diff) == 0 {
14+
# to avoid unnecessary policy violations.
15+
# Used to be: if length(r.diff) == 0
16+
if r.destroy {
1617
print("Skipping resource", address, "that is being destroyed.")
1718
continue
1819
}

governance/second-generation/common-functions/plan/validate_attribute_in_list.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ validate_attribute_in_list = func(type, attribute, allowed_values) {
1111
for resource_instances as address, r {
1212

1313
# Skip resource instances that are being destroyed
14-
# to avoid unnecessary policy violations
15-
if length(r.diff) == 0 {
14+
# to avoid unnecessary policy violations.
15+
# Used to be: if length(r.diff) == 0
16+
if r.destroy {
1617
print("Skipping resource", address, "that is being destroyed.")
1718
continue
1819
}

governance/second-generation/common-functions/plan/validate_attribute_less_than_value.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ validate_attribute_less_than_value = func(type, attribute, max_value) {
1111
for resource_instances as address, r {
1212

1313
# Skip resource instances that are being destroyed
14-
# to avoid unnecessary policy violations
15-
if length(r.diff) == 0 {
14+
# to avoid unnecessary policy violations.
15+
# Used to be: if length(r.diff) == 0
16+
if r.destroy {
1617
print("Skipping resource", address, "that is being destroyed.")
1718
continue
1819
}

governance/second-generation/common-functions/plan/validate_attribute_matches_expression.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ validate_attribute_matches_expression = func(type, attribute, expression) {
1111
for resource_instances as address, r {
1212

1313
# Skip resource instances that are being destroyed
14-
# to avoid unnecessary policy violations
15-
if length(r.diff) == 0 {
14+
# to avoid unnecessary policy violations.
15+
# Used to be: if length(r.diff) == 0
16+
if r.destroy {
1617
print("Skipping resource", address, "that is being destroyed.")
1718
continue
1819
}

governance/second-generation/gcp/enforce-mandatory-labels.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ validate_attribute_contains_list = func(type, attribute, required_values) {
5656
for resource_instances as address, r {
5757

5858
# Skip resource instances that are being destroyed
59-
# to avoid unnecessary policy violations
60-
if length(r.diff) == 0 {
59+
# to avoid unnecessary policy violations.
60+
# Used to be: if length(r.diff) == 0
61+
if r.destroy {
6162
print("Skipping resource", address, "that is being destroyed.")
6263
continue
6364
}

governance/second-generation/gcp/restrict-gce-machine-type.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ validate_attribute_in_list = func(type, attribute, allowed_values) {
5252
for resource_instances as address, r {
5353

5454
# Skip resource instances that are being destroyed
55-
# to avoid unnecessary policy violations
56-
if length(r.diff) == 0 {
55+
# to avoid unnecessary policy violations.
56+
# Used to be: if length(r.diff) == 0
57+
if r.destroy {
5758
print("Skipping resource", address, "that is being destroyed.")
5859
continue
5960
}

governance/second-generation/vmware/restrict-vm-cpu-and-memory.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ validate_attribute_less_than_value = func(type, attribute, max_value) {
5252
for resource_instances as address, r {
5353

5454
# Skip resource instances that are being destroyed
55-
# to avoid unnecessary policy violations
56-
if length(r.diff) == 0 {
55+
# to avoid unnecessary policy violations.
56+
# Used to be: if length(r.diff) == 0
57+
if r.destroy {
5758
print("Skipping resource", address, "that is being destroyed.")
5859
continue
5960
}

governance/second-generation/vmware/restrict-vm-disk-size.sentinel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ validate_disk_size = func(disk_limit) {
5151
for resource_instances as address, r {
5252

5353
# Skip resources that are being destroyed
54-
# to avoid unnecessary policy violations
55-
if length(r.diff) == 0 {
54+
# to avoid unnecessary policy violations.
55+
# Used to be: if length(r.diff) == 0
56+
if r.destroy {
5657
print("Skipping resource", address, "that is being destroyed.")
5758
continue
5859
}

0 commit comments

Comments
 (0)