Heya, I am Favour Lawrence I’m trying to deploy th...
# aws
i
Heya, I am Favour Lawrence I’m trying to deploy the AWS Load Balancer Controller via Helm in Pulumi using EKS. I’m passing the cluster name like this:
Copy code
python
alb_controller_helm = cluster.name.apply(lambda name: Release(..., values={"clusterName": name, ...}))
But I keep getting this error:
Copy code
Chart cannot be installed without a valid clusterName!
Hardcoding the name seems to work, but
.apply()
doesn’t seem to resolve it in time. Is this a known issue with Helm + Output values? What's the right way to pass
cluster.name
to a Helm chart in Pulumi? Appreciate any help! 🙏
l
Where are you using
alb_controller_helm
? That's where the apply should be, if you need it. The code you've got is putting a promise of a future string in that variable, it's not a string and can't be used as such.
i
I’m not actually using
alb_controller_helm
anywhere else. I’m assigning the result of
Release(...)
inside the
.apply()
like this:
Copy code
alb_controller_helm = cluster.name.apply(lambda name: Release(
    "aws-load-balancer-controller",
    ReleaseArgs(
        name="aws-load-balancer-controller",
        chart="aws-load-balancer-controller",
        namespace="kube-system",
        repository_opts=RepositoryOptsArgs(repo="
<https://aws.github.io/eks-charts>"),
        values={
            "clusterName": name,
            "serviceAccount": {
                "create": False,
                "name": "aws-load-balancer-controller"
            },
            "region": region,
            "vpcId": vpc.id,
        },
    ),
    opts=ResourceOptions(provider=k8s_provider, depends_on=[alb_controller_service_account])
))
l
That shouldn't be necessary, I think? I don't know Python syntax, but can't you just assign the name directly in the RepositoryOptArgs, and Pulumi figures it out? That won't resolve the problem though. Is
cluster
an instance of
aws.eks.Cluster
? What type is
Release
, what package is it in?
i
Thanks for the clarification. Yep ,
cluster
is an instance of
pulumi_eks.Cluster
, and
Release
is from
pulumi_kubernetes.helm.v3
. I initially tried passing
cluster.name
directly in
values={"clusterName": cluster.name, ...}
, but that gave me the
Chart cannot be installed without a valid clusterName!
error, likely because
cluster.name
is still an
Output[str]
, not a resolved string at that point. That’s why I tried the
.apply()
approach, to unwrap it but I now realize it turns the whole
alb_controller_helm
into an
Output
, which probably isn't valid for resource declarations. Any idea how to correctly pass
cluster.name
(an
Output[str]
) into the Helm chart
values
while still declaring the
Release
resource properly? Appreciate your time.
l
I can't find a definition of
RepositoryOpts
that includes
clusterName
,
serviceAccount
,
region
etc. Am I looking in the right place? https://www.pulumi.com/registry/packages/kubernetes/api-docs/helm/v3/release/ Generatlly, I'd say that you should be able to ignore the fact that it's an Output[str], but there are exceptions where the expected input might be an entire JSON or YAML doc, in which case you'd need to use an`apply()` to build it. Right now, I don't know enough to figure out which case applies here.
❤️ 1
👆 1
i
Thank you so much
m
I don't have an example with
Release
at hand, but you can use the outputs in the
values
as tenwit said:
Copy code
cluster = aws.eks.Cluster(...)

alb_controller_helm = k8s.helm.v3.Release(
    "aws-load-balancer-controller",
    ReleaseArgs(
        name="aws-load-balancer-controller",
        chart="aws-load-balancer-controller",
        namespace="kube-system",
        repository_opts=RepositoryOptsArgs(repo="
<https://aws.github.io/eks-charts>"),
        values={
            "clusterName": cluster.name,
            "serviceAccount": {
                "create": False,
                "name": alb_controller_service_account.metadata.name
            },
            "region": region,
            "vpcId": vpc.id,
        },
    ),
    opts=ResourceOptions(provider=k8s_provider)
)

pulumi.export("clusterName", cluster.name)
Pulumi will resolve them while creating the resources. In case this doesn't work, you can remove the Release resource and just export the cluster name and the values. This will show you exactly what
cluster.name
is resolved to.
👍 1