-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AWS profile parameter support (#171)
* Add AWS profile parameter support * Changeset * Fix package.json & lock * Fix formatting * Test ci command * Update action versions
- Loading branch information
1 parent
7f90266
commit 01223ed
Showing
16 changed files
with
4,806 additions
and
10,541 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@mirohq/cloud-data-import': minor | ||
--- | ||
|
||
Add AWS profile parameter support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {AwsCredentialIdentity} from '@aws-sdk/types' | ||
import {fromIni} from '@aws-sdk/credential-providers' | ||
|
||
/** | ||
* Builds the AwsCredentialIdentity | ||
* | ||
* it is important to note that if there is more than one credential source available to the SDK, a default precedence of selection will be followed. | ||
* see: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html | ||
*/ | ||
export const buildCredentialIdentity = async (profile: string): Promise<AwsCredentialIdentity> => { | ||
const credentialsProvider = fromIni({ | ||
profile: profile, | ||
}) | ||
|
||
let credentialIdentity: AwsCredentialIdentity | ||
try { | ||
credentialIdentity = await credentialsProvider() | ||
} catch (error) { | ||
console.error(`\n[ERROR] Failed to resolve AWS credentials\n`) | ||
throw error | ||
} | ||
|
||
return credentialIdentity | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import {getDefaultConfigValues} from '@/aws-app/config/getConfigViaGui' | ||
import {getDefaultOutputName} from '@/aws-app/config/getDefaultOutputName' | ||
|
||
jest.mock('@/aws-app/config/getDefaultOutputName') | ||
|
||
describe('getConfigViaGui', () => { | ||
const defaultConfigResponse = { | ||
output: 'dummyOutputName', | ||
regions: undefined, | ||
profile: 'default', | ||
regionalOnly: false, | ||
callRate: 10, | ||
compressed: false, | ||
} | ||
|
||
const originalEnv = process.env | ||
|
||
beforeEach(() => { | ||
;(getDefaultOutputName as jest.Mock).mockReturnValue('dummyOutputName') | ||
|
||
jest.clearAllMocks() | ||
|
||
process.env = { | ||
...originalEnv, | ||
} | ||
}) | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks() | ||
jest.resetAllMocks() | ||
}) | ||
|
||
it('should return correct default values', async () => { | ||
const defaultConfig = await getDefaultConfigValues() | ||
|
||
expect(defaultConfig).toStrictEqual(defaultConfigResponse) | ||
}) | ||
|
||
it('should return correct prioritize the CLOUDVIEW_AWS_PROFILE environment variable over the AWS_PROFILE environment variable', async () => { | ||
process.env.CLOUDVIEW_AWS_PROFILE = 'dummyCloudviewAwsProfileEnvVar' | ||
process.env.AWS_PROFILE = 'dummyAwsProfileEnvVar' | ||
|
||
const defaultConfig = await getDefaultConfigValues() | ||
|
||
expect(defaultConfig).toStrictEqual({ | ||
...defaultConfigResponse, | ||
profile: 'dummyCloudviewAwsProfileEnvVar', | ||
}) | ||
}) | ||
|
||
it('should fall back to the AWS_PROFILE environment variable when CLOUDVIEW_AWS_PROFILE is not configured', async () => { | ||
process.env.AWS_PROFILE = 'dummyAwsProfileEnvVar' | ||
|
||
const defaultConfig = await getDefaultConfigValues() | ||
|
||
expect(defaultConfig).toStrictEqual({ | ||
...defaultConfigResponse, | ||
profile: 'dummyAwsProfileEnvVar', | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.