From 74f044d8cede23b84a810f10612fd438f8505d99 Mon Sep 17 00:00:00 2001 From: burncitiesburn Date: Thu, 2 Nov 2023 10:17:20 +1100 Subject: [PATCH 1/2] add ability to pass host through to ssm to allow testing with localstack --- com/api.cfc | 6 +++++- services/ssm.cfc | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/com/api.cfc b/com/api.cfc index cda1082..d70ae4d 100644 --- a/com/api.cfc +++ b/com/api.cfc @@ -35,7 +35,8 @@ component accessors="true" { public struct function resolveRequestSettings( struct awsCredentials = { }, string region = defaultRegion, - string bucket = '' + string bucket = '', + string host = '' ) { if ( !awsCredentials.isEmpty() ) { awsCredentials = credentials.defaultCredentials( argumentCollection = awsCredentials ); @@ -44,6 +45,9 @@ component accessors="true" { if ( len( arguments.bucket ) ) { settings.bucket = arguments.bucket; } + if( len( arguments.host )){ + settings.host = arguments.host; + } return settings; } diff --git a/services/ssm.cfc b/services/ssm.cfc index 1552854..8381f96 100644 --- a/services/ssm.cfc +++ b/services/ssm.cfc @@ -8,6 +8,7 @@ component { ) { variables.api = arguments.api; variables.apiVersion = arguments.settings.apiVersion; + variables.settings = arguments.settings; return this; } @@ -50,7 +51,12 @@ component { public string function getHost( required string region ) { - return variables.service & '.' & region & '.amazonaws.com'; + if ( structKeyExists( variables.settings, 'host' ) && len( variables.settings.host ) ) { + var host = variables.settings.host; + } else { + var host = variables.service & '.' & region & '.amazonaws.com'; + } + return host; } private any function apiCall( @@ -74,9 +80,15 @@ component { { }, headers, payloadString, - requestSettings.awsCredentials + requestSettings.awsCredentials, + true ); - apiResponse[ 'data' ] = deserializeJSON( apiResponse.rawData ); + if (isJson(apiResponse.rawData)){ + apiResponse[ 'data' ] = deserializeJSON( apiResponse.rawData ); + }else{ + apiResponse[ 'data' ] = apiResponse.rawData; + } + return apiResponse; } From 1acb645d743b18578748b419dd56a05833c98f7e Mon Sep 17 00:00:00 2001 From: burncitiesburn Date: Thu, 9 Nov 2023 15:31:47 +1100 Subject: [PATCH 2/2] Update ssm.cfc Remove passing true for encodeURL. Testing shows its not needed. --- services/ssm.cfc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/ssm.cfc b/services/ssm.cfc index 8381f96..263403e 100644 --- a/services/ssm.cfc +++ b/services/ssm.cfc @@ -80,8 +80,7 @@ component { { }, headers, payloadString, - requestSettings.awsCredentials, - true + requestSettings.awsCredentials ); if (isJson(apiResponse.rawData)){ apiResponse[ 'data' ] = deserializeJSON( apiResponse.rawData );