AWS-CLI-Config

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

{
   "abstract" : "Interface to access AWS CLI configs and credentials",
   "author" : [
      "IKEDA Kiyoshi <keyamb@cpan.org>"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Dist::Zilla version 6.009, CPAN::Meta::Converter version 2.150005",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'Interface to access AWS CLI configs and credentials'
author:
  - 'IKEDA Kiyoshi <keyamb@cpan.org>'
build_requires:
  File::Temp: '0'
  Test::More: '0.98'
  perl: '5.008001'
configure_requires:
  ExtUtils::MakeMaker: '0'
  Module::Build::Tiny: '0.035'
  perl: '5.008001'

Makefile.PL  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.009.
use strict;
use warnings;

use 5.008001;

use ExtUtils::MakeMaker;

my %WriteMakefileArgs = (
  "ABSTRACT" => "Interface to access AWS CLI configs and credentials",
  "AUTHOR" => "IKEDA Kiyoshi <keyamb\@cpan.org>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0,
    "Module::Build::Tiny" => "0.035"
  },
  "DISTNAME" => "AWS-CLI-Config",
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.008001",
  "NAME" => "AWS::CLI::Config",
  "PREREQ_PM" => {

README.md  view on Meta::CPAN

# NAME

AWS::CLI::Config - Interface to access AWS CLI configs and credentials

# SYNOPSIS

    use AWS::CLI::Config;
    my $aws_access_key_id     = AWS::CLI::Config::access_key_id;
    my $aws_secret_access_key = AWS::CLI::Config::secret_access_key($profile);
    my $aws_session_token     = AWS::CLI::Config::session_token($profile);
    my $region                = AWS::CLI::Config::region($profile);

# DESCRIPTION

**AWS::CLI::Config** provides an interface to access AWS CLI configuration and
credentials. It fetches its values from the appropriate environment variables,
or a credential or config file in the order described in
[AWS CLI Documents](http://docs.aws.amazon.com/cli/).

# SUBROUTINES

## access\_key\_id (Str)

Fetches $ENV{AWS\_ACCESS\_KEY\_ID} or _aws\_access\_key\_id_ defined in the
credential or config file. You can optionally specify the profile as the
first argument.

lib/AWS/CLI/Config.pm  view on Meta::CPAN

    my $env_var = $opt{env};
    my $profile_key = $opt{key} || $attr;

    return sub {
        if ($env_var && exists $ENV{$env_var} && $ENV{$env_var}) {
            return $ENV{$env_var};
        }

        my $profile = shift || _default_profile();

        my $credentials = credentials($profile);
        if ($credentials && $credentials->$profile_key) {
            return $credentials->$profile_key;
        }

        my $config = config($profile);
        if ($config && $config->$profile_key) {
            return $config->$profile_key;
        }

        return undef;
    };
}

sub credentials {
    my $profile = shift || _default_profile();

    $CREDENTIALS ||= _parse(
        (exists $ENV{AWS_CONFIG_FILE} and $ENV{AWS_CONFIG_FILE})
            ? $ENV{AWS_CONFIG_FILE}
            : File::Spec->catfile(_default_dir(), 'credentials')
    );

    return unless (exists $CREDENTIALS->{$profile});
    $CREDENTIALS_PROFILE_OF{$profile} ||=
        AWS::CLI::Config::Profile->new($CREDENTIALS->{$profile});
    return $CREDENTIALS_PROFILE_OF{$profile};
}

sub config {
    my $profile = shift || _default_profile();

t/03_output.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;

use AWS::CLI::Config;

subtest 'From credentials file' => sub {
    my $output = '__format__';
    no strict 'refs';
    no warnings 'redefine';
    *AWS::CLI::Config::credentials = sub {
        return AWS::CLI::Config::Profile->new({
                output => $output,
            });
    };
    is(AWS::CLI::Config::output, $output, 'set by credentials');
};

subtest 'From config file' => sub {
    my $output = '__format__';
    no strict 'refs';
    no warnings 'redefine';
    *AWS::CLI::Config::credentials = sub {
        return undef;
    };
    *AWS::CLI::Config::config = sub {
        return AWS::CLI::Config::Profile->new({
                output => $output,
            });
    };
    is(AWS::CLI::Config::output, $output, 'set by config');
};

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 3.333 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-72ae3ad1e6da )