Skip to content

Commit

Permalink
fix(cli): SSO credentials do not work when using a proxy (#22115)
Browse files Browse the repository at this point in the history
Passes `httpOptions` through to the SDK, which now recognizes `httpOptions`. Enables SSO to work with proxies. 

This was tested manually.

Fixes #21328. 

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
comcalvi authored Sep 28, 2022
1 parent 40ddfdd commit c425e8c
Show file tree
Hide file tree
Showing 26 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.848.0"
"aws-sdk": "^2.1211.0"
},
"dependencies": {
"@aws-cdk/aws-codebuild": "0.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/@aws-cdk/aws-apigateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"@aws-cdk/assertions": "0.0.0",
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/integ-tests": "0.0.0",
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront-origins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@aws-cdk/integ-tests": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.848.0"
"aws-sdk": "^2.1211.0"
},
"dependencies": {
"@aws-cdk/aws-apigateway": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"jest": "^27.5.1"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudtrail/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"jest": "^27.5.1"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"jest": "^27.5.1"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codecommit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"@aws-cdk/cloud-assembly-schema": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"jest": "^27.5.1"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-dynamodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@types/aws-lambda": "^8.10.104",
"@types/jest": "^27.5.2",
"@types/sinon": "^9.0.11",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"aws-sdk-mock": "5.6.0",
"jest": "^27.5.1",
"sinon": "^9.2.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-eks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"@types/jest": "^27.5.2",
"@types/sinon": "^9.0.11",
"@types/yaml": "1.9.6",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"cdk8s": "^2.4.33",
"cdk8s-plus-21": "^2.0.0-beta.12",
"jest": "^27.5.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events-targets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"aws-sdk-mock": "5.6.0",
"jest": "^27.5.1"
},
Expand Down
2 changes: 0 additions & 2 deletions packages/@aws-cdk/aws-events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/integ-tests": "0.0.0",
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/integ-tests": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"jest": "^27.5.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"aws-sdk-mock": "5.6.0",
"jest": "^27.5.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@types/aws-lambda": "^8.10.104",
"@types/jest": "^27.5.2",
"@types/sinon": "^9.0.11",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"aws-sdk-mock": "5.6.0",
"jest": "^27.5.1",
"nock": "^13.2.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-redshift/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"@aws-cdk/pkglint": "0.0.0",
"@aws-cdk/integ-tests": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"jest": "^27.5.1"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-route53/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"@aws-cdk/pkglint": "0.0.0",
"@types/aws-lambda": "^8.10.104",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"jest": "^27.5.1"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-sqs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"jest": "^27.5.1"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/custom-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"@types/fs-extra": "^8.1.2",
"@types/jest": "^27.5.2",
"@types/sinon": "^9.0.11",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"aws-sdk-mock": "5.6.0",
"fs-extra": "^9.1.0",
"nock": "^13.2.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH RE

----------------

** aws-sdk@2.1220.0 - https://www.npmjs.com/package/aws-sdk/v/2.1220.0 | Apache-2.0
** aws-sdk@2.1219.0 - https://www.npmjs.com/package/aws-sdk/v/2.1219.0 | Apache-2.0
AWS SDK for JavaScript
Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/integ-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@types/fs-extra": "^8.1.2",
"@types/jest": "^27.5.2",
"@types/node": "^14.18.29",
"aws-sdk": "^2.1093.0",
"aws-sdk": "^2.1211.0",
"aws-sdk-mock": "5.6.0",
"jest": "^27.5.1",
"nock": "^13.2.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/pipelines/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"aws-sdk": "^2.848.0"
"aws-sdk": "^2.1211.0"
},
"peerDependencies": {
"@aws-cdk/aws-codebuild": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/triggers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/aws-sns": "0.0.0",
"aws-sdk": "^2.848.0",
"aws-sdk": "^2.1211.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2",
"jest": "^27.5.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/THIRD_PARTY_LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH RE

----------------

** aws-sdk@2.1220.0 - https://www.npmjs.com/package/aws-sdk/v/2.1220.0 | Apache-2.0
** aws-sdk@2.1219.0 - https://www.npmjs.com/package/aws-sdk/v/2.1219.0 | Apache-2.0
AWS SDK for JavaScript
Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Expand Down
11 changes: 7 additions & 4 deletions packages/aws-cdk/lib/api/aws-auth/awscli-compatible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ export class AwsCliCompatible {
// we use that to the exclusion of everything else (note: this does not apply
// to AWS_PROFILE, environment credentials still take precedence over AWS_PROFILE)
if (options.profile) {
return new AWS.CredentialProviderChain(iniFileCredentialFactories(options.profile));
return new AWS.CredentialProviderChain(iniFileCredentialFactories(options.profile, options.httpOptions));
}

const implicitProfile = process.env.AWS_PROFILE || process.env.AWS_DEFAULT_PROFILE || 'default';

const sources = [
() => new AWS.EnvironmentCredentials('AWS'),
() => new AWS.EnvironmentCredentials('AMAZON'),
...iniFileCredentialFactories(implicitProfile),
...iniFileCredentialFactories(implicitProfile, options.httpOptions),
];

if (options.containerCreds ?? hasEcsCredentials()) {
Expand All @@ -75,10 +75,13 @@ export class AwsCliCompatible {
});
}

function iniFileCredentialFactories(theProfile: string) {
function iniFileCredentialFactories(theProfile: string, theHttpOptions?: AWS.HTTPOptions) {
return [
() => profileCredentials(theProfile),
() => new AWS.SsoCredentials({ profile: theProfile }),
() => new AWS.SsoCredentials({
profile: theProfile,
httpOptions: theHttpOptions,
}),
() => new AWS.ProcessCredentials({ profile: theProfile }),
];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"@aws-cdk/region-info": "0.0.0",
"@jsii/check-node": "1.68.0",
"archiver": "^5.3.1",
"aws-sdk": "^2.1093.0",
"aws-sdk": "^2.1211.0",
"camelcase": "^6.3.0",
"cdk-assets": "0.0.0",
"chokidar": "^3.5.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk-assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@aws-cdk/cloud-assembly-schema": "0.0.0",
"@aws-cdk/cx-api": "0.0.0",
"archiver": "^5.3.1",
"aws-sdk": "^2.1093.0",
"aws-sdk": "^2.1211.0",
"glob": "^7.2.3",
"mime": "^2.6.0",
"yargs": "^16.2.0"
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2626,10 +2626,10 @@ [email protected]:
sinon "^11.1.1"
traverse "^0.6.6"

aws-sdk@^2.1093.0, aws-sdk@^2.596.0, aws-sdk@^2.848.0, aws-sdk@^2.928.0:
version "2.1220.0"
resolved "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1220.0.tgz#5cec163ee7799875e484afcdde93c4b1e713c64c"
integrity sha512-l8KEOo2Cb066lLPhVDucx6JuNUrMVmZW937htKagf8rcADCbM0ySIGGKWbi2E8l44ptX3/tDOFnyiSislolATQ==
aws-sdk@^2.1211.0, aws-sdk@^2.596.0, aws-sdk@^2.928.0:
version "2.1219.0"
resolved "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1219.0.tgz#96d056fc4ebfd8417308f18a34f127dbaafc022e"
integrity sha512-KOGA0E3wZ/Zom1VDAd4ttsaq2LAVECXdHUs/i8OyJkuR3vSvmKQa/BOH4baIBNt4VMS062FhPA29UtT1YPTlwQ==
dependencies:
buffer "4.9.2"
events "1.1.1"
Expand Down

0 comments on commit c425e8c

Please sign in to comment.