-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to deploy Lambda inside VPC #52
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -81,4 +81,14 @@ | |||||
* See CreateExecutionRole::policy for the IAM policy. | ||||||
*/ | ||||||
'execution_role' => env('SIDECAR_EXECUTION_ROLE'), | ||||||
|
||||||
/* | ||||||
* This is the VPC Configuration for Lambda. VPCs are optional | ||||||
* and may be left empty if there are no networking needs | ||||||
* to place sidecar lambda functions inside a VPC. | ||||||
*/ | ||||||
'vpc' => [ | ||||||
'security_groups' => env('SIDECAR_VPC_SECURITY_GROUP'), | ||||||
'subnets' => env('SIDECAR_VPC_SUBNETS'), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
] | ||||||
]; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -312,6 +312,29 @@ public function timeout() | |||||
return config('sidecar.timeout'); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Lambda Function VPC Configuration. This option is often used to place | ||||||
* functions within a VPC for accessibility to private RDS or | ||||||
* Elasticache instances that are not publicly accessible. | ||||||
* | ||||||
* @return null|array | ||||||
*/ | ||||||
public function vpc() | ||||||
{ | ||||||
$subnets = config('sidecar.vpc.subnets'); | ||||||
|
||||||
$sg = config('sidecar.vpc.security_group'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The AWS config is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
if ($subnets && $sg) { | ||||||
return [ | ||||||
'SecurityGroupIds' => Arr::wrap($sg), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
'SubnetIds' => Arr::wrap($subnets), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
]; | ||||||
} | ||||||
|
||||||
return null; | ||||||
} | ||||||
|
||||||
public function preparePayload($payload) | ||||||
{ | ||||||
return $payload; | ||||||
|
@@ -395,7 +418,8 @@ public function toDeploymentArray() | |||||
'Layers' => $this->layers(), | ||||||
'Publish' => true, | ||||||
'PackageType' => $this->packageType(), | ||||||
'Architectures' => [$this->architecture()] | ||||||
'Architectures' => [$this->architecture()], | ||||||
'VpcConfig' => $this->vpc(), | ||||||
]; | ||||||
|
||||||
// For container image packages, we need to remove the Runtime | ||||||
|
@@ -405,6 +429,13 @@ public function toDeploymentArray() | |||||
$config = Arr::except($config, ['Runtime', 'Handler']); | ||||||
} | ||||||
|
||||||
// Vpc Configuration is optional so let's delete it | ||||||
// from the final configuration if the user did | ||||||
// not opt to define a VPC. | ||||||
if ($config['VpcConfig'] === null) { | ||||||
unset($config['VpcConfig']); | ||||||
} | ||||||
|
||||||
return $config; | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.