1- // @ts -check
2-
31// Copyright The Linux Foundation and each contributor to CommunityBridge.
42// SPDX-License-Identifier: MIT
53const AWS = require ( 'aws-sdk' ) ;
64
5+ // @ts -check
6+
7+
78/**
89 * @param {string[] } variables
910 * @param {string } stage
1011 * @param {string } region
11- * @param {string } profile
1212 * @returns {Promise<{ [key:string]: string}> }
1313 */
14- async function retrieveSSMValues ( variables , stage , region , profile ) {
14+ async function retrieveSSMValues ( variables , stage , region ) {
1515 const scopedVariables = variables . map ( ( param ) => `cla-${ param } -${ stage } ` ) ;
16- const result = await requestSSMParameters ( scopedVariables , stage , region , profile ) ;
16+ const result = await requestSSMParameters ( scopedVariables , stage , region ) ;
1717 const parameters = result . Parameters ;
1818 const error = result . $response . error ;
1919 if ( error !== null ) {
2020 throw new Error (
21- `Couldn't retrieve SSM parameters for stage ${ stage } in region ${ region } using profile ${ profile } - error ${ error } `
21+ `Couldn't retrieve SSM parameters for stage ${ stage } in region ${ region } - error ${ error } `
2222 ) ;
2323 }
2424 const scopedParams = createParameterMap ( parameters , stage ) ;
2525 const params = new Map ( ) ;
2626 Object . keys ( scopedParams ) . forEach ( ( key ) => {
27- // console.log(`processing ${key}`);
2827 const param = scopedParams [ key ] ;
2928 key = key . replace ( 'cla-' , '' ) ;
3029 key = key . replace ( `-${ stage } ` , '' ) ;
@@ -34,7 +33,7 @@ async function retrieveSSMValues(variables, stage, region, profile) {
3433 variables . forEach ( ( variable ) => {
3534 if ( params [ variable ] === undefined ) {
3635 throw new Error (
37- `Missing SSM parameter with name ${ variable } for stage ${ stage } in region ${ region } using profile ${ profile } ` ,
36+ `Missing SSM parameter with name ${ variable } for stage ${ stage } in region ${ region } ` ,
3837 ) ;
3938 }
4039 } ) ;
@@ -47,20 +46,14 @@ async function retrieveSSMValues(variables, stage, region, profile) {
4746 * @param {string[] } variables
4847 * @param {string } stage
4948 * @param {string } region
50- * @param {string } profile
5149 */
52- async function requestSSMParameters ( variables , stage , region , profile ) {
53- console . log ( `Loading AWS credentials from profile: ${ profile } ` )
54- AWS . config . credentials = new AWS . SharedIniFileCredentials ( { profile } ) ;
50+ async function requestSSMParameters ( variables , stage , region ) {
5551 const ssm = new AWS . SSM ( { region } ) ;
5652 const ps = {
5753 Names : variables ,
5854 WithDecryption : true
5955 } ;
60- // console.log(AWS.config.credentials);
61- // console.log(`fetching ssm parameters: ${variables}`);
6256 const response = await ssm . getParameters ( ps ) . promise ( ) ;
63- // console.log(response);
6457 return response ;
6558}
6659
0 commit comments