Cloud Custodian Policy not working
policies: | |
- name: ec2-mark-31-days-old-instance | |
resource: ec2 | |
description: | | |
Mark any ec2 instance for deletion in 10 days | |
If an instance is 31 days or older | |
filters: | |
- and: | |
- type: instance-age | |
op: ge | |
days: 31 | |
- type: value | |
key: "tag:Lifespan" | |
value: ongoing | |
value_type: normalize | |
op: not-equal | |
actions: | |
- type: mark-for-op | |
tag: custodian_terminate_31_days_old | |
op: terminate | |
- name: ec2-notify-before-terminate-marked-10-days | |
resource: ec2 | |
description: | | |
Notify on any ec2 instances that will be termnated in 10 days | |
comments: | | |
Your EC2 server will be terminated in 10 days. This is as per company policy for Sandbox. | |
filters: | |
- type: marked-for-op | |
tag: custodian_terminate_31_days_old | |
op: terminate | |
skew: 10 | |
actions: | |
- type: notify | |
template: default.html | |
priority_header: 2 | |
subject: "EC2 Instance Termination Scheduled in 10 days ! [custodian {{ account }} - {{ region }}]" | |
violation_desc: "EC2(s) have been created 21 days ago and will be terminated in 10 days" | |
action_desc: | | |
Your EC2 server will be terminated in 10 days as per company policy of keeping | |
Sandbox instances for only 31 days | |
to: | |
- resource-owner | |
transport: | |
type: sqs | |
queue: https://sqs.us-east-2.amazonaws.com/1234/sand-cloud-custodian | |
region: us-east-2 | |
- name: ec2-terminate-marked | |
resource: ec2 | |
description: | | |
Terminate and notify on any ec2 instances that were scheduled for termination. ( age >= 31 days ) | |
filters: | |
- and: | |
- type: marked-for-op | |
tag: custodian_terminate_31_days_old | |
op: terminate | |
- type: value | |
key: "tag:Lifespan" | |
value: ongoing | |
value_type: normalize | |
op: not-equal | |
actions: | |
- type: terminate | |
force: true | |
- type: notify | |
template: default.html | |
priority_header: 1 | |
subject: "EC2 Stopped Instance Terminated [custodian {{ account }} - {{ region }}]" | |
violation_desc: "EC2(s) had been created 31 ago have now been terminated:" | |
action_desc: | | |
Your EC2 server has been terminated as its age > 31 days | |
to: | |
- resource-owner | |
transport: | |
type: sqs | |
queue: https://sqs.us-east-2.amazonaws.com/1234/sand-cloud-custodian | |
region: us-east-2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment