1- const execSync = require ( "child_process" ) . execSync ;
21const core = require ( "@actions/core" ) ;
32const aws = require ( "aws-sdk" ) ;
43const ssm = new aws . SSM ( ) ;
@@ -7,7 +6,8 @@ async function main() {
76 try {
87 console . log ( "Begin AWS Param To Env" ) ;
98
10- const debuLogging = core . getInput ( "debug-logging" ) === "true" ;
9+ const debuLogging = core . getInput ( "debug-logging" ) === "true" ;
10+ const maskValues = ( core . getInput ( "mask-values" ) === "false" ) ? false : true ; // default to masking everything
1111 const decryptSecureStrings =
1212 core . getInput ( "decrypt-secure-strings" ) === "true" ;
1313 const paramStoreBasePathInput = core . getInput ( "param-store-base-paths" , {
@@ -20,7 +20,7 @@ async function main() {
2020 decryptSecureStrings ,
2121 debuLogging
2222 ) ;
23- setParamsInEnvironment ( basePath , parameters ) ;
23+ setParamsInEnvironment ( basePath , parameters , maskValues ) ;
2424 }
2525
2626 console . log ( "End AWS Param To Env" ) ;
@@ -36,7 +36,7 @@ async function getParamsByPath(path, decrypt, log) {
3636
3737 do {
3838 if ( log ) {
39- console . log ( `Begin getParametersByPath: ${ JSON . stringify ( NextToken ) } ` ) ;
39+ console . log ( `Begin getParametersByPath continued : ${ ! ! NextToken } ` ) ;
4040 }
4141
4242 ssmResult = await ssm
@@ -49,7 +49,18 @@ async function getParamsByPath(path, decrypt, log) {
4949 . promise ( ) ;
5050
5151 if ( log ) {
52- console . log ( `End getParametersByPath: ${ JSON . stringify ( ssmResult ) } ` ) ;
52+ if ( ! decrypt ) {
53+ console . log ( `End getParametersByPath: ${ JSON . stringify ( ssmResult ) } ` ) ;
54+ } else {
55+ const safeToLogResults = ssmResult . Parameters . map ( parameter => {
56+ let loggableParam = Object . assign ( { } , parameter ) ;
57+ if ( loggableParam . Type === 'SecureString' ) {
58+ loggableParam . Value = '***' ;
59+ }
60+ return loggableParam ;
61+ } ) ;
62+ console . log ( `End getParametersByPath: ${ JSON . stringify ( { Parameters : safeToLogResults } ) } ` ) ;
63+ }
5364 }
5465
5566 if ( ssmResult . Parameters . length ) {
@@ -59,7 +70,7 @@ async function getParamsByPath(path, decrypt, log) {
5970 } while ( NextToken ) ;
6071
6172 if ( log ) {
62- console . log ( `Loaded parameters: ${ JSON . stringify ( parameters ) } ` ) ;
73+ console . log ( "Parameter path load complete." ) ;
6374 }
6475
6576 return parameters ;
@@ -69,17 +80,21 @@ async function getParamsByPath(path, decrypt, log) {
6980 * Convert the heirarchical param name to a unix-style param name.
7081 * e.g. /test/api/key -> API_KEY
7182 */
72- async function setParamsInEnvironment ( path , params ) {
83+ async function setParamsInEnvironment ( path , params , maskValues ) {
7384 for ( const param of params ) {
7485 const shortName = param . Name . replace ( path , "" ) ;
7586 const unixName = shortName
7687 . replace ( / ^ \/ / , "" )
7788 . replace ( / \/ / g, "_" )
7889 . toUpperCase ( ) ;
7990
80- // write the value out to the environment and register it as a secret, so github logs will mask it
91+ // write the value out to the environment
8192 core . exportVariable ( unixName , param . Value ) ;
82- core . setSecret ( param . Value ) ;
93+
94+ // register it as a secret, so github logs will mask it
95+ if ( maskValues ) {
96+ core . setSecret ( param . Value ) ;
97+ }
8398 }
8499}
85100
0 commit comments