Skip to content

Commit e426ace

Browse files
authored
Merge pull request #437 from Peefy/update-tf-validation-examples
chore: update terraform validation examples
2 parents 3c5e512 + a255fca commit e426ace

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

docs/user_docs/guides/working-with-terraform/3-validation.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,18 @@ schema TFPlan:
420420
schema AcceptableChange:
421421
# Omit other attributes
422422
[...str]: any
423+
$type: str
424+
name: str
425+
change: Change
423426
check:
424427
# Reject AWS autoscaling group Resource delete action
425428
all action in change.actions {
426429
action not in ["delete"]
427430
} if type == "aws_autoscaling_group", "Disable AWS autoscaling group resource delete action for the resource ${type} ${name}"
431+
432+
schema Change:
433+
[...str]: any
434+
actions: [str]
428435
```
429436

430437
This policy file checks that no AWS Auto Scaling groups are being deleted - even if that deletion is part of a delete-and-recreate operation.
@@ -450,11 +457,18 @@ schema TFPlan:
450457
schema AcceptableChange:
451458
# Omit other attributes
452459
[...str]: any
460+
$type: str
461+
name: str
462+
change: Change
453463
check:
454464
# Reject AWS autoscaling group Resource delete action
455465
all action in change.actions {
456-
action not in ["create"]
466+
action not in ["create"] # Use create to mock a check failure.
457467
} if type == "aws_autoscaling_group", "Disable AWS autoscaling group resource create action for the resource ${type} ${name}"
468+
469+
schema Change:
470+
[...str]: any
471+
actions: [str]
458472
```
459473

460474
Run the command

examples/terraform/validation/main.k

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ schema TFPlan:
66
schema AcceptableChange:
77
# Omit other attributes
88
[...str]: any
9+
$type: str
10+
name: str
11+
change: Change
912
check:
1013
# Reject AWS autoscaling group Resource delete action
1114
all action in change.actions {
1215
action not in ["delete"]
1316
} if type == "aws_autoscaling_group", "Disable AWS autoscaling group resource delete action for the resource ${type} ${name}"
17+
18+
schema Change:
19+
[...str]: any
20+
actions: [str]

examples/terraform/validation/main.policy.failure.k

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ schema TFPlan:
66
schema AcceptableChange:
77
# Omit other attributes
88
[...str]: any
9+
$type: str
10+
name: str
11+
change: Change
912
check:
1013
# Reject AWS autoscaling group Resource delete action
1114
all action in change.actions {
1215
action not in ["create"] # Use create to mock a check failure.
1316
} if type == "aws_autoscaling_group", "Disable AWS autoscaling group resource create action for the resource ${type} ${name}"
17+
18+
schema Change:
19+
[...str]: any
20+
actions: [str]

versioned_docs/version-0.9/user_docs/guides/working-with-terraform/3-validation.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,18 @@ schema TFPlan:
420420
schema AcceptableChange:
421421
# Omit other attributes
422422
[...str]: any
423+
$type: str
424+
name: str
425+
change: Change
423426
check:
424427
# Reject AWS autoscaling group Resource delete action
425428
all action in change.actions {
426429
action not in ["delete"]
427430
} if type == "aws_autoscaling_group", "Disable AWS autoscaling group resource delete action for the resource ${type} ${name}"
431+
432+
schema Change:
433+
[...str]: any
434+
actions: [str]
428435
```
429436

430437
This policy file checks that no AWS Auto Scaling groups are being deleted - even if that deletion is part of a delete-and-recreate operation.
@@ -450,11 +457,18 @@ schema TFPlan:
450457
schema AcceptableChange:
451458
# Omit other attributes
452459
[...str]: any
460+
$type: str
461+
name: str
462+
change: Change
453463
check:
454464
# Reject AWS autoscaling group Resource delete action
455465
all action in change.actions {
456-
action not in ["create"]
466+
action not in ["create"] # Use create to mock a check failure.
457467
} if type == "aws_autoscaling_group", "Disable AWS autoscaling group resource create action for the resource ${type} ${name}"
468+
469+
schema Change:
470+
[...str]: any
471+
actions: [str]
458472
```
459473

460474
Run the command

0 commit comments

Comments
 (0)