brash-kite-78002
10/01/2021, 12:46 PMlet x = new k8s.core.v1.Service(
"test-service-lb",
{
metadata: {
name: "test-service-lb",
namespace: "default",
labels: {
"test-service": "test-service-lb"
},
annotations: {
"<http://service.beta.kubernetes.io/aws-load-balancer-type|service.beta.kubernetes.io/aws-load-balancer-type>": "nlb",
"<http://service.beta.kubernetes.io/aws-load-balancer-internal|service.beta.kubernetes.io/aws-load-balancer-internal>": "true",
"<http://service.beta.kubernetes.io/aws-load-balancer-backend-protocol|service.beta.kubernetes.io/aws-load-balancer-backend-protocol>": "http",
"<http://pulumi.com/skipAwait|pulumi.com/skipAwait>": "true"
}
},
spec: {
type: "LoadBalancer",
ports: [{
port: 80,
targetPort: 9090,
protocol: "TCP"
}],
selector: {
"app": "prometheus-operator-prometheus"
},
loadBalancerSourceRanges: [
"10.0.0.0/8",
(() => {
<http://pulumi.log.info|pulumi.log.info>("The cluster name is " + this.args.name)
if (`${this.args.name}`.toLowerCase().endsWith("-prod")) {
<http://pulumi.log.info|pulumi.log.info>("Subnet was not added")
return undefined
} else {
<http://pulumi.log.info|pulumi.log.info>("Added the subnet")
return "100.72.0.0/16"
}
})()
]
},
},
{
provider: this.asfEksCluster.provider
}
)
able-doctor-68496
10/01/2021, 12:50 PMreturn undefined
.bored-oyster-3147
10/01/2021, 12:51 PMable-doctor-68496
10/01/2021, 12:54 PMconst loadBalancerSourceRanges = ['10.0.0.0/8']
<http://pulumi.log.info|pulumi.log.info>("The cluster name is " + this.args.name)
if (`${this.args.name}`.toLowerCase().endsWith("-prod")) {
<http://pulumi.log.info|pulumi.log.info>("Subnet was not added")
} else {
<http://pulumi.log.info|pulumi.log.info>("Added the subnet")
loadBalancerSourceRanges.push("100.72.0.0/16")
}
let x = new k8s.core.v1.Service(
"test-service-lb",
...
spec: {
...
loadBalancerSourceRanges: loadBalancerSourceRanges
...
}
...
}
brash-kite-78002
10/01/2021, 1:07 PMable-doctor-68496
10/01/2021, 1:24 PMloadBalancerSourceRanges
can be undefined
. However, if you do provide an array to loadBalancerSourceRanges
, then the members of that array cannot be undefined
. You were effectively setting loadBalancerSourceRanges
to ['10.0.0.0/8', undefined]
, which is not allowed.