@@ -171,22 +171,22 @@ func (app *App) loadFunctionUrl(path string, functionName string) (*FunctionURL,
171
171
return f , nil
172
172
}
173
173
174
- func (app * App ) deployFunctionURL (ctx context.Context , fc * FunctionURL ) error {
175
- log .Println ("[info] deploying function url..." )
174
+ func (app * App ) deployFunctionURL (ctx context.Context , fc * FunctionURL , opt * DeployOption ) error {
175
+ log .Printf ("[info] deploying function url... %s" , opt . label () )
176
176
177
- if err := app .deployFunctionURLConfig (ctx , fc ); err != nil {
177
+ if err := app .deployFunctionURLConfig (ctx , fc , opt ); err != nil {
178
178
return fmt .Errorf ("failed to deploy function url config: %w" , err )
179
179
}
180
180
181
- if err := app .deployFunctionURLPermissions (ctx , fc ); err != nil {
181
+ if err := app .deployFunctionURLPermissions (ctx , fc , opt ); err != nil {
182
182
return fmt .Errorf ("failed to deploy function url permissions: %w" , err )
183
183
}
184
184
185
- log .Println ("[info] deployed function url" )
185
+ log .Println ("[info] deployed function url" , opt . label () )
186
186
return nil
187
187
}
188
188
189
- func (app * App ) deployFunctionURLConfig (ctx context.Context , fc * FunctionURL ) error {
189
+ func (app * App ) deployFunctionURLConfig (ctx context.Context , fc * FunctionURL , opt * DeployOption ) error {
190
190
create := false
191
191
fqFunctionName := fullQualifiedFunctionName (* fc .Config .FunctionName , fc .Config .Qualifier )
192
192
functinoUrlConfig , err := app .lambda .GetFunctionUrlConfig (ctx , & lambda.GetFunctionUrlConfigInput {
@@ -196,13 +196,18 @@ func (app *App) deployFunctionURLConfig(ctx context.Context, fc *FunctionURL) er
196
196
if err != nil {
197
197
var nfe * types.ResourceNotFoundException
198
198
if errors .As (err , & nfe ) {
199
- log .Printf ("[info] function url config for %s not found. creating" , fqFunctionName )
199
+ log .Printf ("[info] function url config for %s not found. creating %s " , fqFunctionName , opt . label () )
200
200
create = true
201
201
} else {
202
202
return fmt .Errorf ("failed to get function url config: %w" , err )
203
203
}
204
204
}
205
205
206
+ if opt .DryRun {
207
+ log .Println ("[info] dry-run mode. skipping function url config deployment" )
208
+ return nil
209
+ }
210
+
206
211
if create {
207
212
res , err := app .lambda .CreateFunctionUrlConfig (ctx , fc .Config )
208
213
if err != nil {
@@ -232,7 +237,7 @@ func (app *App) deployFunctionURLConfig(ctx context.Context, fc *FunctionURL) er
232
237
return nil
233
238
}
234
239
235
- func (app * App ) deployFunctionURLPermissions (ctx context.Context , fc * FunctionURL ) error {
240
+ func (app * App ) deployFunctionURLPermissions (ctx context.Context , fc * FunctionURL , opt * DeployOption ) error {
236
241
adds , removes , err := app .calcFunctionURLPermissionsDiff (ctx , fc )
237
242
if err != nil {
238
243
return err
@@ -242,22 +247,25 @@ func (app *App) deployFunctionURLPermissions(ctx context.Context, fc *FunctionUR
242
247
return nil
243
248
}
244
249
245
- log .Printf ("[info] adding %d permissions" , len (adds ))
246
- for _ , in := range adds {
247
- if _ , err := app .lambda .AddPermission (ctx , in ); err != nil {
248
- return fmt .Errorf ("failed to add permission: %w" , err )
250
+ log .Printf ("[info] adding %d permissions %s" , len (adds ), opt .label ())
251
+ if ! opt .DryRun {
252
+ for _ , in := range adds {
253
+ if _ , err := app .lambda .AddPermission (ctx , in ); err != nil {
254
+ return fmt .Errorf ("failed to add permission: %w" , err )
255
+ }
256
+ log .Printf ("[info] added permission Sid: %s" , * in .StatementId )
249
257
}
250
- log .Printf ("[info] added permission Sid: %s" , * in .StatementId )
251
258
}
252
259
253
- log .Printf ("[info] removing %d permissions" , len (removes ))
254
- for _ , in := range removes {
255
- if _ , err := app .lambda .RemovePermission (ctx , in ); err != nil {
256
- return fmt .Errorf ("failed to remove permission: %w" , err )
260
+ log .Printf ("[info] removing %d permissions %s" , len (removes ), opt .label ())
261
+ if ! opt .DryRun {
262
+ for _ , in := range removes {
263
+ if _ , err := app .lambda .RemovePermission (ctx , in ); err != nil {
264
+ return fmt .Errorf ("failed to remove permission: %w" , err )
265
+ }
266
+ log .Printf ("[info] removed permission Sid: %s" , * in .StatementId )
257
267
}
258
- log .Printf ("[info] removed permission Sid: %s" , * in .StatementId )
259
268
}
260
-
261
269
return nil
262
270
}
263
271
0 commit comments