AWS-SNS-Confess
view release on metacpan or search on metacpan
README.markdown view on Meta::CPAN
# NAME
AWS::S3 - Publish Errors, with a full stack trace to an Amazon SNS
topic
# SYNOPSIS
use AWS::SNS::Confess 'confess';
AWS::SNS::Confess::setup(
access_key_id => 'E654SAKIASDD64ERAF0O',
secret_access_key => 'LgTZ25nCD+9LiCV6ujofudY1D6e2vfK0R4GLsI4H'
topic => 'arn:aws:sns:us-east-1:738734873:YourTopic',
);
confess "Something went wrong";
# DESCRIPTION
AWS::SNS::Confess uses [Amazon::SNS](http://search.cpan.org/perldoc?Amazon::SNS) to post any errors to an Amazon SNS
feed for more robust management from there.
# PUBLIC METHODS
## setup( access_key_id => $aws_access_key_id, secret_access_key => $aws_secret_access_key, topic => $aws_topic );
Sets up to send errors to the given AWS Account and Topic
## confess( $msg );
Publishes the given error message to SNS with a full stack trace
# SEE ALSO
[Amazon::SNS](http://search.cpan.org/perldoc?Amazon::SNS)
lib/AWS/SNS/Confess.pm view on Meta::CPAN
use base 'Exporter';
use Amazon::SNS;
use Devel::StackTrace;
use strict;
use warnings 'all';
our @EXPORT_OK = qw/confess/;
our ($access_key_id, $secret_access_key, $topic, $sns, $sns_topic);
sub setup
{
my (%args) = @_;
$access_key_id = $args{access_key_id};
$secret_access_key = $args{secret_access_key};
$topic = $args{topic};
$sns = $args{sns} || Amazon::SNS->new({
key => $access_key_id,
secret => $secret_access_key,
});
$sns->service(_service_url());
lib/AWS/SNS/Confess.pm view on Meta::CPAN
AWS::SNS::Confess - Publish errors to an SNS topic
=head1 VERSION
version 0.001
=head1 SYNOPSIS
use AWS::SNS::Confess 'confess';
AWS::SNS::Confess::setup(
access_key_id => 'E654SAKIASDD64ERAF0O',
secret_access_key => 'LgTZ25nCD+9LiCV6ujofudY1D6e2vfK0R4GLsI4H'
topic => 'arn:aws:sns:us-east-1:738734873:YourTopic',
);
confess "Something went wrong";
=head1 DESCRIPTION
AWS::SNS::Confess uses L<Amazon::SNS> to post any errors to an Amazon SNS
feed for more robust management from there.
=head1 NAME
AWS::S3 - Publish Errors, with a full stack trace to an Amazon SNS
topic
=head1 PUBLIC METHODS
=head2 setup( access_key_id => $aws_access_key_id, secret_access_key => $aws_secret_access_key, topic => $aws_topic );
Sets up to send errors to the given AWS Account and Topic
=head2 confess( $msg );
Publishes the given error message to SNS with a full stack trace
=head1 SEE ALSO
L<Amazon::SNS>
use Test::More 'no_plan';
use Test::Exception;
use Data::Dumper;
use FindBin qw/ $Bin /;
use lib "../lib";
BEGIN {
use_ok('AWS::SNS::Confess', qw/confess/);
}
can_ok('AWS::SNS::Confess', "setup");
my $topic_name = "arn:aws:sns:region:1234:topic";
my $sns = Amazon::SNS::Mock->new();
AWS::SNS::Confess::setup(
access_key_id => "key",
secret_access_key => "secret",
topic => $topic_name,
sns => $sns, # This is specified just for testing
);
is AWS::SNS::Confess::_service_url(), "http://sns.region.amazonaws.com";
is $AWS::SNS::Confess::access_key_id, "key", "correctly set access key";
is $AWS::SNS::Confess::secret_access_key, "secret", "correctly set secret";
is $AWS::SNS::Confess::topic, $topic_name, "correctly set topic";
SEND_TO_SNS: {
AWS::SNS::Confess::_send_msg("Hello");
is $sns->GetTopic($topic_name)->LastLogEntry(), "Hello";
}
CONFESSS: {
can_ok('main', 'confess');
dies_ok { confess("something went wrong") } "confess correctly dies";
t/integration.t view on Meta::CPAN
use Test::More 'no_plan';
use Test::Exception;
use lib "../lib";
BEGIN {
use_ok('AWS::SNS::Confess', qw/confess/);
}
SKIP: {
skip "no environment variables", 1 unless ( $ENV{AWS_ACCESS_KEY_ID} && $ENV{AWS_SECRET_ACCESS_KEY} && $ENV{AWS_TOPIC} );
ok(AWS::SNS::Confess::setup(
access_key_id => $ENV{AWS_ACCESS_KEY_ID},
secret_access_key => $ENV{AWS_SECRET_ACCESS_KEY},
topic => $ENV{AWS_TOPIC},
), "setup went okay");
dies_ok { confess "this should show up in the topic's feed" } "sending confess died";
print "check manually if the SNS message was sent\n";
};
( run in 1.726 second using v1.01-cache-2.11-cpan-49f99fa48dc )