Skip to content

Commit a3c22a4

Browse files
committed
Add option to configure credential_source
1 parent d9d6a93 commit a3c22a4

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

manifests/profile.pp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
# [$source_profile]
3333
# The profile to use for credentials to assume the specified role
3434
#
35+
# [credential_source]
36+
# Used within EC2 instances or EC2 containers to specify where the AWS CLI can find credentials
37+
# to use to assume the role you specified with the role_arn parameter.
38+
# You cannot specify both source_profile and credential_source in the same profile.
39+
#
3540
# [$role_session_name]
3641
# An identifier for the assumed role session
3742
#
@@ -70,6 +75,7 @@
7075
$aws_secret_access_key = undef,
7176
$role_arn = undef,
7277
$source_profile = undef,
78+
$credential_source = undef,
7379
$role_session_name = undef,
7480
$aws_region = 'us-east-1',
7581
$profile_name = 'default',
@@ -108,6 +114,14 @@
108114
$group_real = $group
109115
}
110116

117+
if ($source_profile != undef and $credential_source != undef) {
118+
fail("aws cli profile cannot contain both source_profile and credential_source config option")
119+
}
120+
$valid_credential_sources = ['Environment', 'Ec2InstanceMetadata', 'EcsContainer']
121+
if (!$credential_source in $valid_credential_sources) {
122+
fail("credential_source config option can contain only $valid_credential_sources")
123+
}
124+
111125
# ensure $homedir/.aws is available
112126
if !defined(File["${homedir_real}/.aws"]) {
113127
file { "${homedir_real}/.aws":

templates/config_concat.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ role_arn=<%= @role_arn %>
1111
<% if @source_profile -%>
1212
source_profile=<%= @source_profile %>
1313
<% end -%>
14+
<% if @credential_source -%>
15+
credential_source=<%= @credential_source %>
16+
<% end -%>
1417
<% if @role_session_name -%>
1518
role_session_name=<%= @role_session_name %>
1619
<% end -%>

0 commit comments

Comments
 (0)