File Coverage

blib/lib/Signer/AWSv4/RDS.pm
Criterion Covered Total %
statement 10 10 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 0 2 0.0
total 16 18 88.8


line stmt bran cond sub pod time code
1             package Signer::AWSv4::RDS;
2 2     2   113790 use Moo;
  2         19018  
  2         8  
3             extends 'Signer::AWSv4';
4 2     2   3347 use Types::Standard qw/Str Int/;
  2         125150  
  2         20  
5              
6             has '+expires' => (default => 900);
7             has '+service' => (default => 'rds-db');
8             has '+method' => (default => 'GET');
9             has '+uri' => (default => '/');
10              
11             has host => (is => 'ro', isa => Str, required => 1);
12             has user => (is => 'ro', isa => Str, required => 1);
13             has port => (is => 'ro', isa => Int, default => 3306);
14              
15             sub build_params {
16 2     2 0 22 my $self = shift;
17             {
18 2 100       63 'Action' => 'connect',
19             'DBUser' => $self->user,
20             'X-Amz-Algorithm' => $self->aws_algorithm,
21             'X-Amz-Credential' => $self->access_key . "/" . $self->credential_scope,
22             'X-Amz-Date' => $self->date_timestamp,
23             'X-Amz-Expires' => $self->expires,
24             ($self->session_token ? ('X-Amz-Security-Token' => $self->session_token) : () ),
25             'X-Amz-SignedHeaders' => $self->signed_header_list,
26             }
27             }
28              
29             sub build_headers {
30 2     2 0 36 my $self = shift;
31             {
32 2         41 Host => $self->host . ':' . $self->port,
33             }
34             }
35              
36             1;
37             ### main pod documentation begin ###
38              
39             =encoding UTF-8
40              
41             =head1 NAME
42              
43             Signer::AWSv4::RDS - Generate tokens for signing into MySQL/Aurora RDS servers with IAM credentials
44              
45             =head1 SYNOPSIS
46              
47             use Signer::AWSv4::RDS;
48             $pass_gen = Signer::AWSv4::RDS->new(
49             access_key => 'AKIAIOSFODNN7EXAMPLE',
50             secret_key => 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
51             session_token => 'EXAMPLESESSIONTOKEN', # Required if using temporary security credentials.
52              
53             host => 'MyRDSEndpoint',
54             user => 'iam_user',
55             region => 'us-east-1',
56             );
57             my $password = $pass_gen->signed_qstring;
58              
59             =head1 DESCRIPTION
60              
61             Generate tokens for signing into MySQL/Aurora RDS servers with IAM credentials.
62             You can find details of the process in L.
63              
64             =head1 Request Attributes
65              
66             This module adds two required attributes in the constructor for obtaining a token (to be used
67             as a MySQL password):
68              
69             =head2 host String
70              
71             The AWS RDS instance endpoint
72              
73             =head2 user String
74              
75             The user of the MySQL database
76              
77             =head2 port Integer
78              
79             The port the database is running on. Defaults to 3306.
80              
81             =head1 Signature Attributes
82              
83             =head2 signed_qstring
84              
85             This has to be used as the password for the MySQL Server. Please note that all of this needs
86             extra setup: correctly configuring your AWS environment AND your MySQL Client.
87              
88             =head1 SEE ALSO
89              
90             L
91              
92             =head1 BUGS and SOURCE
93              
94             The source code is located here: L
95              
96             Please report bugs to: L
97              
98             =head1 AUTHOR
99              
100             Jose Luis Martinez
101             pplusdomain@gmail.com
102              
103             =head1 COPYRIGHT and LICENSE
104              
105             Copyright (c) 2018 by Jose Luis Martinez
106              
107             This code is distributed under the Apache 2 License. The full text of the license can be found in the LICENSE file included with this module.
108              
109             =cut