Create SQS message JSON by feeding in the policy yml, giving the policy name if there are multiple policies, and giving it the location of the output directory so it can read the resources.json file.
python sqs-message-json.py \
policies/ebs-garbage-collect.yml \
--policy ebs-mark-unattached-deletion \
--output-dir out > sqs-ebs-garbage-collect.json
Use SQS message JSON to print a template
c7n-mailer-replay \
--plain sqs-ebs-garbage-collect.json \
--config mailer.yml \
--templates templates/ \
--template-print
✗ python sqs-message-json.py --help
usage: sqs-message-json.py [-h] [--policy POLICY] --output-dir OUTPUT_DIR
[--notify-index NOTIFY_INDEX]
policy_file
Convert policy yml and output to an sqs message sent by c7n-mailer
positional arguments:
policy_file Policy file to create SQS message for
optional arguments:
-h, --help show this help message and exit
--policy POLICY, -p POLICY
Policy name if multiple policies. If none provided,
pick the first.
--output-dir OUTPUT_DIR, -s OUTPUT_DIR
[REQUIRED] Directory for policy output
--notify-index NOTIFY_INDEX, -n NOTIFY_INDEX
index of notify action if multiple notifies exist.
defaults to 0.
function convert-sqs-msg {
input=$(basename $1);
cat $input | jq -r '.Messages[].Body' | base64 -d > $input.zlib;
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - $input.zlib | gzip -dc | jq -M > $input.clean.json
rm $input.zlib
}
aws sqs receive-message \
--queue-url https://sqs.us-west-2.amazonaws.com/1234567890/cloud-custodian > sqs-message.json
convert-sqs-msg sqs-message.json
cat sqs-message.clean.json
Above figured out using davidclin's hode to decode sqs message