Skip to content

Commit 97f7fb2

Browse files
LazerFXawschristou
authored andcommitted
Added Docker Network support for Locally Invoking SAM applications (#788)
* Docker Network Support Modified the template to add dockerNetwork option Passed the value through to the SAM Cli Note: dockerNetwork is not a boolean, rather it's a string (For obvious reasons). The template has auto-complete, and will handle null values sanely.
1 parent 6533f17 commit 97f7fb2

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Added docker network option support for invoking sam applications"
4+
}

src/lambda/config/templates.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ export interface HandlerConfig {
3838
environmentVariables: {
3939
[name: string]: string
4040
}
41+
dockerNetwork?: string
4142
}
4243

4344
export function generateDefaultHandlerConfig(): HandlerConfig {
4445
return {
4546
event: {},
46-
environmentVariables: {}
47+
environmentVariables: {},
48+
dockerNetwork: undefined
4749
}
4850
}
4951

src/schemas/templates.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
"type": "object",
3939
"default": {},
4040
"description": "Overrides the environment variable values defined in the SAM Template when running the Lambda function locally."
41+
},
42+
"dockerNetwork": {
43+
"type": "string",
44+
"default": null,
45+
"description": "If specified, adds a --docker-network parameter to the SAM CLI. If not specified, no parameter will be sent."
4146
}
4247
}
4348
}

src/shared/codelens/localLambdaRunner.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ export class LocalLambdaRunner {
188188
eventPath,
189189
environmentVariablePath,
190190
debugPort: !!this._debugPort ? this._debugPort.toString() : undefined,
191-
invoker: this.localInvokeCommand
191+
invoker: this.localInvokeCommand,
192+
dockerNetwork: config.dockerNetwork
192193
})
193194

194195
const timer = createInvokeTimer(this.configuration)
@@ -420,7 +421,8 @@ export async function invokeLambdaFunction(
420421
templatePath: invokeArgs.samTemplatePath,
421422
eventPath,
422423
environmentVariablePath,
423-
invoker: samLocalInvokeCommand
424+
invoker: samLocalInvokeCommand,
425+
dockerNetwork: config.dockerNetwork
424426
}
425427

426428
const debugArgs = invokeArgs.debugArgs

0 commit comments

Comments
 (0)