Skip to content

Commit

Permalink
Add option to configure credential_source
Browse files Browse the repository at this point in the history
  • Loading branch information
jsedlace committed Aug 29, 2019
1 parent d9d6a93 commit a3c22a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions manifests/profile.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
# [$source_profile]
# The profile to use for credentials to assume the specified role
#
# [credential_source]
# Used within EC2 instances or EC2 containers to specify where the AWS CLI can find credentials
# to use to assume the role you specified with the role_arn parameter.
# You cannot specify both source_profile and credential_source in the same profile.
#
# [$role_session_name]
# An identifier for the assumed role session
#
Expand Down Expand Up @@ -70,6 +75,7 @@
$aws_secret_access_key = undef,
$role_arn = undef,
$source_profile = undef,
$credential_source = undef,
$role_session_name = undef,
$aws_region = 'us-east-1',
$profile_name = 'default',
Expand Down Expand Up @@ -108,6 +114,14 @@
$group_real = $group
}

if ($source_profile != undef and $credential_source != undef) {
fail("aws cli profile cannot contain both source_profile and credential_source config option")
}
$valid_credential_sources = ['Environment', 'Ec2InstanceMetadata', 'EcsContainer']
if (!$credential_source in $valid_credential_sources) {
fail("credential_source config option can contain only $valid_credential_sources")
}

# ensure $homedir/.aws is available
if !defined(File["${homedir_real}/.aws"]) {
file { "${homedir_real}/.aws":
Expand Down
3 changes: 3 additions & 0 deletions templates/config_concat.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ role_arn=<%= @role_arn %>
<% if @source_profile -%>
source_profile=<%= @source_profile %>
<% end -%>
<% if @credential_source -%>
credential_source=<%= @credential_source %>
<% end -%>
<% if @role_session_name -%>
role_session_name=<%= @role_session_name %>
<% end -%>

0 comments on commit a3c22a4

Please sign in to comment.