cbtshare has asked for the wisdom of the Perl Monks concerning the following question:
My codeIN_SYNC Stack AviatrixGatewaySetup is OK!! IN_SYNC Stack ChildEC2 is out of sync!! SEND EMAIL NOW!! IN_SYNC IN_SYNC Stack ChildEFS is OK!! IN_SYNC IN_SYNC Stack ChildElasticache is OK!! IN_SYNC IN_SYNC Stack ChildFargate is OK!! IN_SYNC Stack ChildRDS is OK!! IN_SYNC IN_SYNC Stack ChildSQs is OK!! IN_SYNC Stack ChildSns is OK!! IN_SYNC Stack EFDEVProject is out of sync!! SEND EMAIL NOW!! IN_SYNC Stack S3 is out of sync!! SEND EMAIL NOW!! IN_SYNC Stack Users is OK!! IN_SYNC IN_SYNC Stack VPC2 is OK!! IN_SYNC IN_SYNC Stack parent is OK!! IN_SYNC Stack test-sample-function is OK!!
Any help would be appreciated thank you#!/usr/bin/perl use strict; use warnings; my $ID; my @FINAL; my $SYNC; my $stack; my $DETECTION; #my $email=''; my @STACK_NAME=qx(aws cloudformation list-stacks --stack-status-filter + CREATE_COMPLETE UPDATE_COMPLETE --query 'sort_by(StackSummaries, &S +tackName)[*].[StackName]' --output text ); for $stack (@STACK_NAME) { chomp($stack); $ID=qx(aws cloudformation detect-stack-drift --stack-name "$stack" | j +q .[] | awk -F '\"' '{print \$2}'); chomp($ID); ##Get status based on ID do { $SYNC=qx(aws cloudformation describe-stack-drift-detection-status +--stack-drift-detection-id $ID | grep StackDriftStatus | awk -F '\"' +'{print \$4}'); $DETECTION=qx(aws cloudformation describe-stack-drift-detection-st +atus --stack-drift-detection-id $ID | grep DetectionStatus | awk -F ' +\"' '{print \$4}'); #system qq{aws cloudformation describe-stack-drift-detection-statu +s --stack-drift-detection-id $ID | grep DetectionStatus | awk -F '"' +'{print \$4}'}; system qq{aws cloudformation describe-stack-drift-detection-status + --stack-drift-detection-id $ID | grep StackDriftStatus | awk -F '\"' + '{print \$4}'}; chomp($DETECTION); chomp($SYNC); } until(("$DETECTION" eq 'DETECTION_COMPLETE') || ("$DETECTION" =~ + /DETECTION_FAILED/mi)) ; #if($SYNC eq 'IN_SYNC') if ( 'IN_SYNC' =~ /$SYNC/mi ) { print "Stack $stack is OK!!\n"; } else { print "Stack $stack is out of sync!! SEND EMAIL NOW!!\n\n"; #system qq{aws ses send-email --from "systems\@eemail.com" --d +estination "ToAddresses=$email" --message "Subject={Data=Cloudformati +on Drift Detected,Charset=utf8},Body={Text={Data=String,Charset=utf8} +,Html={Data=A Cloudformation stack has been detected to be out of SYN +C on Stack $stack,Charset=utf8}}" --region us-east-1}; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: word search in perl script
by Corion (Patriarch) on Feb 08, 2020 at 07:26 UTC | |
by cbtshare (Monk) on Feb 08, 2020 at 21:33 UTC | |
|
Re: word search in perl script
by poj (Abbot) on Feb 08, 2020 at 13:35 UTC | |
by cbtshare (Monk) on Feb 08, 2020 at 21:27 UTC | |
|
Re: word search in perl script
by jcb (Parson) on Feb 09, 2020 at 00:00 UTC |