33 lines
1.3 KiB
Jsonnet
33 lines
1.3 KiB
Jsonnet
local chart = import 'chart.jsonnet';
|
|
local common = import 'common.jsonnet';
|
|
local deployment_manifest = import 'deployment_manifest.jsonnet';
|
|
local deployment = deployment_manifest.deployment;
|
|
if 'securityGroup' in deployment then
|
|
local security_group = deployment.securityGroup;
|
|
[{
|
|
apiVersion: 'aws.navi.com/v1',
|
|
kind: 'SecurityGroup',
|
|
metadata: {
|
|
name: '%s-%s' % [chart.full_service_name(deployment_manifest.deployment.name), sg.name],
|
|
labels: common.labels,
|
|
namespace: deployment_manifest.deployment.namespace,
|
|
annotations: common.annotations,
|
|
},
|
|
spec: {
|
|
rules: [
|
|
{
|
|
local ipv4_cidrs = [cidr for cidr in rule.ingressCidr if std.findSubstr(':',cidr) == []],
|
|
local ipv6_cidrs = [cidr for cidr in rule.ingressCidr if std.findSubstr(':',cidr) != []],
|
|
[if 'fromPort' in rule then 'fromPort']: rule.fromPort,
|
|
[if 'toPort' in rule then 'toPort']: rule.toPort,
|
|
[if 'protocol' in rule then 'protocol']: rule.protocol,
|
|
[if 'description' in rule then 'description']: rule.description,
|
|
[if 'ingressCidr' in rule then 'ingressCidr']: ipv4_cidrs,
|
|
[if 'ingressCidr' in rule then 'ipv6ingressCidr']: ipv6_cidrs,
|
|
}
|
|
for rule in sg.rules
|
|
],
|
|
[if 'vpcId' in sg then 'vpcId']: sg.vpcId,
|
|
},
|
|
} for sg in security_group]
|