Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: Support SSO and CA Bundle parameters in credentials file #1795

Merged
merged 1 commit into from Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changelog/6a9e3da6a75c41fd9efef3fdf2355f48.json
@@ -0,0 +1,8 @@
{
"id": "6a9e3da6-a75c-41fd-9efe-f3fdf2355f48",
"type": "feature",
"description": "Adds support for the following settings in the `~/.aws/credentials` file: `sso_account_id`, `sso_region`, `sso_role_name`, `sso_start_url`, and `ca_bundle`.",
"modules": [
"config"
]
}
6 changes: 5 additions & 1 deletion config/shared_config.go
Expand Up @@ -463,7 +463,6 @@ type LoadSharedConfigOptions struct {
//
// You can read more about shared config and credentials file location at
// https://docs.aws.amazon.com/credref/latest/refdocs/file-location.html#file-location
//
func LoadSharedConfigProfile(ctx context.Context, profile string, optFns ...func(*LoadSharedConfigOptions)) (SharedConfig, error) {
var option LoadSharedConfigOptions
for _, fn := range optFns {
Expand Down Expand Up @@ -680,6 +679,11 @@ func mergeSections(dst, src ini.Sections) error {
useFIPSEndpointKey,
defaultsModeKey,
retryModeKey,
ssoAccountIDKey,
ssoRegionKey,
ssoRoleNameKey,
ssoStartURL,
caBundleKey,
}
for i := range stringKeys {
if err := mergeStringKey(&srcSection, &dstSection, sectionName, stringKeys[i]); err != nil {
Expand Down
15 changes: 15 additions & 0 deletions config/shared_config_test.go
Expand Up @@ -591,6 +591,11 @@ func TestNewSharedConfig(t *testing.T) {
Profile: "merged_profiles",
RoleARN: "creds_profile_arn",
RoleDurationSeconds: aws.Duration(1023 * time.Second),
SSOAccountID: "0123456789",
SSORegion: "us-west-2",
SSORoleName: "CredProfileRole",
SSOStartURL: "https://my-sso-cred-profile-role.awsapps.com/start",
CustomCABundle: "/path/to/bundle.b",
},
},
"merged profiles across config files": {
Expand All @@ -601,6 +606,11 @@ func TestNewSharedConfig(t *testing.T) {
Profile: "merged_profiles",
RoleARN: "config_profile_arn",
RoleDurationSeconds: aws.Duration(3601 * time.Second),
SSOAccountID: "1234567890",
SSORegion: "us-east-1",
SSORoleName: "ConfigProfileRole",
SSOStartURL: "https://my-sso-config-profile-role.awsapps.com/start",
CustomCABundle: "/path/to/bundle.a",
},
},
"merged profiles across credentials files": {
Expand All @@ -611,6 +621,11 @@ func TestNewSharedConfig(t *testing.T) {
Profile: "merged_profiles",
RoleARN: "creds_profile_arn",
RoleDurationSeconds: aws.Duration(1023 * time.Second),
SSOAccountID: "0123456789",
SSORegion: "us-west-2",
SSORoleName: "CredProfileRole",
SSOStartURL: "https://my-sso-cred-profile-role.awsapps.com/start",
CustomCABundle: "/path/to/bundle.b",
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions config/testdata/shared_config
Expand Up @@ -19,6 +19,11 @@ duration_seconds = 3601
[profile merged_profiles]
duration_seconds = 3601
role_arn = config_profile_arn
sso_start_url = https://my-sso-config-profile-role.awsapps.com/start
sso_region = us-east-1
sso_account_id = 1234567890
sso_role_name = ConfigProfileRole
ca_bundle = /path/to/bundle.a

[profile short_profile_name_first]
region = short_profile_name_first_short
Expand Down
5 changes: 5 additions & 0 deletions config/testdata/shared_credentials
Expand Up @@ -22,3 +22,8 @@ region = eu-west-3
[merged_profiles]
duration_seconds = 1023
role_arn = creds_profile_arn
sso_start_url = https://my-sso-cred-profile-role.awsapps.com/start
sso_region = us-west-2
sso_account_id = 0123456789
sso_role_name = CredProfileRole
ca_bundle = /path/to/bundle.b