pulumi-eks icon indicating copy to clipboard operation
pulumi-eks copied to clipboard

eks.ClusterArgs{} StorageClasses field not working correctly

Open christopher-wong opened this issue 2 years ago • 2 comments

What happened?

I'm attempting to create a new EKS Cluster with the StorageClasses field.

Attempting to create a cluster with the StorageClasses field (see repro code below) during cluster creation fails with the following error:

pulumi:pulumi:Stack (infra2-dev): error: an unhandled error occurred: program failed: waiting for RPCs: marshaling properties: awaiting input property "clusterName": marshaling properties: awaiting input property "storageClasses": cannot marshal an input of type v1.StorageClassArgs with element type v1.storageClassArgs as a value of type v1.StorageClassArgs

If I use NewStorageClass directly with the same configuration, everything works as expected.

Expected Behavior

A cluster should be created with the custom storage class specified.

Steps to reproduce

import (
	eksCw "github.com/pulumi/pulumi-eks/sdk/go/eks"
	metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/meta/v1"
	storagev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/storage/v1"
)

...

cluster, err := eksCw.NewCluster(ctx, "cluster2", &eksCw.ClusterArgs{
	Version: pulumi.StringPtr("1.24"),
	VpcId:   pulumi.StringPtr("vpc-xxx"),
	StorageClasses: map[string]storagev1.StorageClassArgs{
		"ebs-sc": {
			AllowVolumeExpansion: pulumi.BoolPtr(true),
			Provisioner:          pulumi.String("ebs.csi.aws.com"),
			Parameters: pulumi.ToStringMap(map[string]string{
				"encrypted": "true",
				"kmsKeyId":  "xxx",
			}),
			ReclaimPolicy:     pulumi.String("Delete"),
			VolumeBindingMode: pulumi.String("WaitForFirstConsumer"),
			Metadata: &metav1.ObjectMetaArgs{
				Annotations: pulumi.ToStringMap(map[string]string{
					"name": "ebs-sc",
					"storageclass.kubernetes.io/is-default-class": "true",
				}),
			},
		},
	},
})

Output of pulumi about

CLI
Version 3.53.1 Go Version go1.19.5 Go Compiler gc

Plugins NAME VERSION aws 5.28.0 eks 1.0.1 go unknown kubernetes 3.17.0

Host
OS darwin Version 13.2 Arch arm64

This project is written in go: executable='/usr/local/go/bin/go' version='go version go1.19.5 darwin/arm64'

Backend
Name xxx URL s3://xxx/yyy User christopherwong Organizations

Dependencies: NAME VERSION github.com/pulumi/pulumi-aws/sdk/v5 5.28.0 github.com/pulumi/pulumi-eks/sdk 1.0.1 github.com/pulumi/pulumi/sdk/v3 3.53.0

Pulumi locates its logs in /var/folders/ry/jnycvnjj5f17q72tgwfm5jx40000gn/T/ by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

christopher-wong avatar Feb 01 '23 17:02 christopher-wong

Hi @christopher-wong

Thanks for reporting this issue to us. It looks like there is a marshaling error within the Go SDK from a Pulumi output to a Pulumi input. I was able to find a similar issue in the past and I'll file a issue to track that our codegen logic is updated to handle this.

In the meantime, I've identified a workaround for this to help unblock your workflows. Instead of using a map[string]storagev1.StorageClassArgs for the StorageClasses field, you should be able to use map[string]interface{} instead to create your clusters.

Expanded workaround example:

cluster, err := eksCw.NewCluster(ctx, "cluster2", &eksCw.ClusterArgs{
			Version: pulumi.StringPtr("1.24"),
			VpcId:   pulumi.StringPtr("vpc-xxx"),
			StorageClasses: map[string]interface{}{
				"ebs-sc": storagev1.StorageClassArgs{
					AllowVolumeExpansion: pulumi.BoolPtr(true),
					Provisioner:          pulumi.String("ebs.csi.aws.com"),
					Parameters: pulumi.ToStringMap(map[string]string{
						"encrypted": "true",
						"kmsKeyId":  "xxx",
					}),
					ReclaimPolicy:     pulumi.String("Delete"),
					VolumeBindingMode: pulumi.String("WaitForFirstConsumer"),
					Metadata: &metav1.ObjectMetaArgs{
						Annotations: pulumi.ToStringMap(map[string]string{
							"name": "ebs-sc",
							"storageclass.kubernetes.io/is-default-class": "true",
						}),
					},
				},
			},
		})

rquitales avatar Feb 01 '23 19:02 rquitales

Thank you!

christopher-wong avatar Feb 06 '23 17:02 christopher-wong