@@ -100,15 +100,15 @@ type AwsCloudfrontUpdateCmd struct {
100100 Function string `kong:"name='lambda-function',env='AWS_LAMBDA_FUNCTION'"`
101101 FunctionFile string `kong:"name='lambda-function-file',env='AWS_LAMBDA_FUNCTION_FILE'"`
102102 CloudfrontID string `kong:"name='cloudfront-id',env='AWS_CLOUDFRONT_ID'"`
103- RedirectsJSON string `kong:"name='redirects-json',env='REDIRECTS_JSON '"`
104- RedirectsPrefixesJSON string `kong:"name='redirects-prefixes-json',env='REDIRECTS_PREFIXES_JSON '"`
103+ RedirectsFile string `kong:"name='redirects-json',env='REDIRECTS_FILE '"`
104+ RedirectsPrefixesFile string `kong:"name='redirects-prefixes-json',env='REDIRECTS_PREFIXES_FILE '"`
105105}
106106
107107func (s * AwsCloudfrontUpdateCmd ) Run () error {
108108 var err error
109109 ver := time .Now ().UTC ().Format (time .RFC3339 )
110110
111- zipdt , err := getLambdaFunctionZip (s .FunctionFile , s .RedirectsJSON , s .RedirectsPrefixesJSON )
111+ zipdt , err := getLambdaFunctionZip (s .FunctionFile , s .RedirectsFile , s .RedirectsPrefixesFile )
112112 if err != nil {
113113 return fmt .Errorf ("cannot create lambda function zip: %w" , err )
114114 }
@@ -228,20 +228,29 @@ func (s *AwsCloudfrontUpdateCmd) Run() error {
228228 return nil
229229}
230230
231- func getLambdaFunctionZip (funcFilename string , redirectsJSON string , redirectsPrefixesJSON string ) ([]byte , error ) {
231+ func getLambdaFunctionZip (funcFilename string , redirectsFile string , redirectsPrefixesFile string ) ([]byte , error ) {
232232 funcdt , err := os .ReadFile (funcFilename )
233233 if err != nil {
234234 return nil , fmt .Errorf ("failed to read lambda function file %q: %w" , funcFilename , err )
235235 }
236236
237+ redirects , err := os .ReadFile (redirectsFile )
238+ if err != nil {
239+ return nil , fmt .Errorf ("failed to read redirects file %q: %w" , redirectsFile , err )
240+ }
241+ redirectsPrefixes , err := os .ReadFile (redirectsPrefixesFile )
242+ if err != nil {
243+ return nil , fmt .Errorf ("failed to read lambda function file %q: %w" , redirectsPrefixesFile , err )
244+ }
245+
237246 var funcbuf bytes.Buffer
238247 functpl := template .Must (template .New ("" ).Parse (string (funcdt )))
239248 if err = functpl .Execute (& funcbuf , struct {
240249 RedirectsJSON string
241250 RedirectsPrefixesJSON string
242251 }{
243- redirectsJSON ,
244- redirectsPrefixesJSON ,
252+ string ( redirects ) ,
253+ string ( redirectsPrefixes ) ,
245254 }); err != nil {
246255 return nil , err
247256 }
0 commit comments