File tree Expand file tree Collapse file tree 1 file changed +22
-29
lines changed Expand file tree Collapse file tree 1 file changed +22
-29
lines changed Original file line number Diff line number Diff line change @@ -7,48 +7,41 @@ import { settingsPath } from '../../util/settings.js'
77export const getSSMParameter = async (
88 args : Parameters < typeof settingsPath > [ 0 ] ,
99) : Promise < string | undefined > => {
10+ const name = settingsPath ( args )
1011 const url = `http://localhost:${
1112 process . env . PARAMETERS_SECRETS_EXTENSION_HTTP_PORT ?? '2773'
1213 } /systemsmanager/parameters/get/?${ new URLSearchParams ( {
13- name : settingsPath ( args ) ,
14+ name,
1415 } ) . toString ( ) } `
1516
1617 console . log (
1718 JSON . stringify ( {
1819 url,
1920 } ) ,
2021 )
21- return fetch ( url , {
22- headers : {
23- 'X-Aws-Parameters-Secrets-Token' : process . env . AWS_SESSION_TOKEN ?? '' ,
24- } ,
25- } )
26- . then < {
27- Parameter : {
28- Value : string
29- }
30- } > ( async ( res ) => {
31- console . log (
32- JSON . stringify ( {
33- res : {
34- status : res . status ,
35- } ,
36- } ) ,
37- )
38- return res . json ( )
22+ try {
23+ const res = await fetch ( url , {
24+ headers : {
25+ 'X-Aws-Parameters-Secrets-Token' : process . env . AWS_SESSION_TOKEN ?? '' ,
26+ } ,
3927 } )
40- . then ( async ( payload ) => {
41- console . log (
42- JSON . stringify ( {
43- payload,
44- } ) ,
28+
29+ if ( ! res . ok ) {
30+ console . error (
31+ `Fetching SSM Parameter ${ name } failed: ${ await res . text ( ) } ` ,
4532 )
46- return payload . Parameter . Value
47- } )
48- . catch ( ( err ) => {
49- console . error ( err )
5033 return undefined
51- } )
34+ }
35+
36+ const {
37+ Parameter : { Value } ,
38+ } = await res . json ( )
39+
40+ return Value
41+ } catch ( err ) {
42+ console . error ( err )
43+ return undefined
44+ }
5245}
5346
5447export const getNRFCloudSSMParameters = async (
You can’t perform that action at this time.
0 commit comments