Skip to content
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

Add parameter to place Convox managed Lambdas in VPC for private racks #3716

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion provider/aws/formation/app.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"InternalDomains": { "Fn::Equals": [ { "Ref": "InternalDomains" }, "Yes" ] },
"Isolate": { "Fn::And": [ { "Condition": "Private" }, { "Fn::Equals": [ { "Ref": "Isolate" }, "Yes" ] } ] },
"IsolateServices": { "Fn::Or": [ { "Condition": "FargateServicesEither" }, { "Condition": "Isolate" } ] },
"PlaceLambdaInVpcCond": { "Fn::Equals": [ { "Ref": "PlaceLambdaInVpc" }, "Yes" ] },
"PrivateAndPlaceLambdaInVpc": { "Fn::And": [ { "Condition": "Private" }, { "Condition": "PlaceLambdaInVpcCond" } ] },
"Private": { "Fn::Equals": [ { "Ref": "Private" }, "Yes" ] },
"RackUrl": { "Fn::Equals": [ { "Ref": "RackUrl" }, "Yes" ] }
},
Expand Down Expand Up @@ -119,6 +121,12 @@
"Description": "Number of days to keep logs (blank for unlimited)",
"Type": "String"
},
"PlaceLambdaInVpc": {
"Type": "String",
"Description": "Place convox related lambdas in vpc if rack is private",
"Default": "No",
"AllowedValues": [ "Yes", "No" ]
},
"Private": {
"Type": "String",
"Default": "No",
Expand Down Expand Up @@ -471,7 +479,16 @@
" });",
"};"
] ] }
}
},
"VpcConfig": { "Fn::If": [ "PrivateAndPlaceLambdaInVpc",
{
"SecurityGroupIds": [
{ "Fn::ImportValue": { "Fn::Sub": "${Rack}:InstancesSecurityGroup" }}
],
"SubnetIds": [{ "Fn::ImportValue": { "Fn::Sub": "${Rack}:SubnetPrivate0" } }, { "Fn::ImportValue": { "Fn::Sub": "${Rack}:SubnetPrivate1" } }]
},
{ "Ref": "AWS::NoValue" }
]}
}
},
"TimerRole": {
Expand Down
41 changes: 38 additions & 3 deletions provider/aws/formation/rack.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@
"Internal": { "Fn::Equals": [ { "Ref": "Internal" }, "Yes" ] },
"InternetGateway": { "Fn::Not": [ { "Fn::Equals": [ { "Ref": "InternetGateway" }, "" ] } ] },
"NotExistingVpcAndBlankInternetGateway": { "Fn::Not": [ { "Condition": "ExistingVpcAndBlankInternetGateway" } ] },
"PlaceLambdaInVpcCond": { "Fn::Equals": [ { "Ref": "PlaceLambdaInVpc" }, "Yes" ] },
"PrivateAndPlaceLambdaInVpc": { "Fn::And": [ { "Condition": "PrivateInstances" }, { "Condition": "PlaceLambdaInVpcCond" } ] },
"Private": { "Fn::Or": [ { "Condition": "PrivateBuild" }, { "Condition": "PrivateInstances" } ] },
"PrivateAndThirdAvailabilityZoneAndHighAvailability": {
"Fn::And": [ { "Condition": "Private" }, { "Condition": "ThirdAvailabilityZone" }, { "Condition": "HighAvailability" } ]
Expand Down Expand Up @@ -870,6 +872,12 @@
"MaxLength": "50",
"NoEcho": true
},
"PlaceLambdaInVpc": {
"Type": "String",
"Description": "Place lambda in vpc",
"Default": "No",
"AllowedValues": [ "Yes", "No" ]
},
"Private": {
"Type": "String",
"Description": "Create non publicly routable resources",
Expand Down Expand Up @@ -1246,7 +1254,16 @@
"MemorySize": "128",
"Role": { "Fn::GetAtt": [ "CustomTopicRole", "Arn" ] },
"Runtime": "nodejs16.x",
"Timeout": "300"
"Timeout": "300",
"VpcConfig": { "Fn::If": [ "PrivateAndPlaceLambdaInVpc",
{
"SecurityGroupIds": [
{ "Fn::If": [ "BlankInstanceSecurityGroup", { "Ref": "InstancesSecurity" }, { "Ref": "InstanceSecurityGroup" }]}
],
"SubnetIds": [{ "Ref": "SubnetPrivate0" }, { "Ref": "SubnetPrivate1" }]
},
{ "Ref": "AWS::NoValue" }]
}
}
},
"Vpc": {
Expand Down Expand Up @@ -2297,7 +2314,16 @@
"MemorySize": "128",
"Role": { "Fn::GetAtt": [ "ApiRole", "Arn" ] },
"Runtime": "provided.al2",
"Timeout": "60"
"Timeout": "60",
"VpcConfig": { "Fn::If": [ "PrivateAndPlaceLambdaInVpc",
{
"SecurityGroupIds": [
{ "Fn::If": [ "BlankInstanceSecurityGroup", { "Ref": "InstancesSecurity" }, { "Ref": "InstanceSecurityGroup" }]}
],
"SubnetIds": [{ "Ref": "SubnetPrivate0" }, { "Ref": "SubnetPrivate1" }]
},
{ "Ref": "AWS::NoValue" }]
}
}
},
"InstancesAutoscalerPermission": {
Expand Down Expand Up @@ -2419,7 +2445,16 @@
"MemorySize": "128",
"Role": { "Fn::GetAtt": [ "InstancesLifecycleHandlerRole", "Arn" ] },
"Runtime": "provided.al2",
"Timeout": "300"
"Timeout": "300",
"VpcConfig": { "Fn::If": [ "PrivateAndPlaceLambdaInVpc",
{
"SecurityGroupIds": [
{ "Fn::If": [ "BlankInstanceSecurityGroup", { "Ref": "InstancesSecurity" }, { "Ref": "InstanceSecurityGroup" }]}
],
"SubnetIds": [{ "Ref": "SubnetPrivate0" }, { "Ref": "SubnetPrivate1" }]
},
{ "Ref": "AWS::NoValue" }]
}
}
},
"InstancesLifecycleHandlerPermission": {
Expand Down
6 changes: 6 additions & 0 deletions provider/aws/releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,15 @@
return err
}

lambdaInVpc, err := p.stackParameter(p.Rack, "PlaceLambdaInVpc")
if err != nil {
return err

Check warning on line 374 in provider/aws/releases.go

View check run for this annotation

Codecov / codecov/patch

provider/aws/releases.go#L372-L374

Added lines #L372 - L374 were not covered by tests
}

updates := map[string]string{
"LogBucket": p.LogBucket,
"LogDriver": p.LogDriver,
"PlaceLambdaInVpc": lambdaInVpc,

Check warning on line 380 in provider/aws/releases.go

View check run for this annotation

Codecov / codecov/patch

provider/aws/releases.go#L380

Added line #L380 was not covered by tests
"Private": private,
"SyslogDestination": p.SyslogDestination,
"SyslogFormat": p.SyslogFormat,
Expand Down