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

Behavior of shared_config.go:validateSSOConfiguration does not allow reading credentials from environment variables if sso_account_id/sso_role_name is missing from ~/.aws/config #3768

Closed
christophetd opened this issue Feb 1, 2021 · 3 comments · Fixed by #3769
Labels
bug This issue is a bug.

Comments

@christophetd
Copy link

christophetd commented Feb 1, 2021

See also hashicorp/terraform-provider-aws#17370

Describe the bug
validateSSOConfiguration introduced in 04e0775 (@skmcgrail) does not allow to have a SSO configuration partially defined in ~/.aws/config and using credentials coming from environment variables. I've encountered this issue while using Terraform (v0.14.5) with the AWS Provider 3.26.0 using the latest version of aws-sdk-go.

Version of AWS SDK for Go? v1.37.0

Version of Go (go version)? go1.15.6

To Reproduce (observed behavior)
Create the following ~/.aws/config:

[default]
sso_start_url=https://xxx.awsapps.com/start
sso_region=eu-central-1
cli_pager=
region=eu-west-1

[okta]
aws_saml_url=xxx

Typically, you'd then have additional entries:

[profile dev]
sso_account_id=123456789123
sso_role_name=MyRole

The bug occurs when you have valid credentials in your environment, e.g.

$ aws-vault exec dev # Or using the AWS CLI
$ aws sts get-caller-identity
{
    "UserId": "AROXXXXXXXx:[email protected]",
    "Account": "123456789123",
    "Arn": "arn:aws:sts::123456789123:assumed-role/AWSReservedSSO_MyRole_xxx/[email protected]"
}

... and try to run Terraform:

$ cat main.tf
terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "3.26.0"
    }
  }
}

provider "aws" {
  region = "eu-west-1"
}

resource "aws_iam_user" "test" {
	name = "test"
}

$ terraform init && terraform apply
Error: error configuring Terraform AWS Provider: Error creating AWS session: profile "default" is configured to use SSO but is missing required configuration: sso_account_id, sso_role_name

Expected behavior
aws-sdk-go should take into account the credentials available in the environment and not crash on a (purposely incomplete) [default] entry in ~/.aws/config

@skmcgrail
Copy link
Member

skmcgrail commented Feb 1, 2021

The fix in #3769 will be included in the next SDK release. Thank you for providing details on how to reproduce what you were seeing.

@github-actions
Copy link

github-actions bot commented Feb 1, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@christophetd
Copy link
Author

Thanks @skmcgrail for the fix, do you have any time estimate for the next release?

aws-sdk-go-automation pushed a commit that referenced this issue Feb 2, 2021
===

### Service Client Updates
* `service/application-autoscaling`: Updates service API and documentation
* `service/appmesh`: Updates service API and documentation
* `service/iotwireless`: Updates service API and documentation
* `service/location`: Updates service documentation
* `service/lookoutvision`: Updates service API and documentation
* `service/medialive`: Updates service API and documentation
  * AWS Elemental MediaLive now supports Image Media Playlists on HLS outputs, version 0.4 (trick-mode).
* `service/organizations`: Updates service documentation
  * Documentation updates for AWS Organizations.
* `service/rds-data`: Updates service API and documentation
* `service/route53`: Updates service documentation
  * Documentation updates for Route 53
* `service/s3control`: Updates service API and documentation
  * Amazon S3 Batch Operations now supports Delete Object Tagging

### SDK Enhancements
* `service/s3`: Amazon S3 now supports AWS PrivateLink, providing direct access to S3 via a private endpoint within your virtual private network.

### SDK Bugs
* `aws/session`: Fixed a bug that prevented credentials from being sourced from the environment if the loaded shared config profile contained partial SSO configuration. ([#3769](#3769))
  * Fixes ([#3768](#3768))
aws-sdk-go-automation added a commit that referenced this issue Feb 2, 2021
Release v1.37.2 (2021-02-02)
===

### Service Client Updates
* `service/application-autoscaling`: Updates service API and documentation
* `service/appmesh`: Updates service API and documentation
* `service/iotwireless`: Updates service API and documentation
* `service/location`: Updates service documentation
* `service/lookoutvision`: Updates service API and documentation
* `service/medialive`: Updates service API and documentation
  * AWS Elemental MediaLive now supports Image Media Playlists on HLS outputs, version 0.4 (trick-mode).
* `service/organizations`: Updates service documentation
  * Documentation updates for AWS Organizations.
* `service/rds-data`: Updates service API and documentation
* `service/route53`: Updates service documentation
  * Documentation updates for Route 53
* `service/s3control`: Updates service API and documentation
  * Amazon S3 Batch Operations now supports Delete Object Tagging

### SDK Enhancements
* `service/s3`: Amazon S3 now supports AWS PrivateLink, providing direct access to S3 via a private endpoint within your virtual private network.

### SDK Bugs
* `aws/session`: Fixed a bug that prevented credentials from being sourced from the environment if the loaded shared config profile contained partial SSO configuration. ([#3769](#3769))
  * Fixes ([#3768](#3768))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
2 participants