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

go sdk: undefined c.nodeGroupOptions #1581

Open
jdavredbeard opened this issue Jan 8, 2025 · 1 comment
Open

go sdk: undefined c.nodeGroupOptions #1581

jdavredbeard opened this issue Jan 8, 2025 · 1 comment
Labels
kind/bug Some behavior is incorrect or out of spec

Comments

@jdavredbeard
Copy link
Contributor

What happened?

When trying to create NodeGroupV2 in go, preview fails when specifying either InstanceProfile or InstanceProfileName.

    error: TypeError: Cannot read properties of undefined (reading 'instanceProfileName')
        at resolveInstanceProfileName (/snapshot/eks/bin/nodegroup.js:171:57)
        at /snapshot/eks/bin/nodegroup.js:530:51
        at /snapshot/eks/node_modules/@pulumi/pulumi/output.js:317:35
        at Generator.next (<anonymous>)
        at /snapshot/eks/node_modules/@pulumi/pulumi/output.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/snapshot/eks/node_modules/@pulumi/pulumi/output.js:17:12)
        at applyHelperAsync (/snapshot/eks/node_modules/@pulumi/pulumi/output.js:298:12)
        at /snapshot/eks/node_modules/@pulumi/pulumi/output.js:209:63
        at processTicksAndRejections (node:internal/process/task_queues:95:5)
    error: TypeError: Cannot read properties of undefined (reading 'ipFamily')
        at /snapshot/eks/bin/nodegroup.js:1290:20
        at /snapshot/eks/node_modules/@pulumi/pulumi/output.js:317:35
        at Generator.next (<anonymous>)
        at /snapshot/eks/node_modules/@pulumi/pulumi/output.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/snapshot/eks/node_modules/@pulumi/pulumi/output.js:17:12)
        at applyHelperAsync (/snapshot/eks/node_modules/@pulumi/pulumi/output.js:298:12)
        at /snapshot/eks/node_modules/@pulumi/pulumi/output.js:209:63
        at processTicksAndRejections (node:internal/process/task_queues:95:5)
    error: Error: invocation of aws:ssm/getParameter:getParameter returned an error: grpc: the client connection is closing
        at Object.callback (/snapshot/eks/node_modules/@pulumi/pulumi/runtime/invoke.js:233:33)
        at Object.onReceiveStatus (/snapshot/eks/node_modules/@grpc/grpc-js/src/client.ts:360:26)
        at Object.onReceiveStatus (/snapshot/eks/node_modules/@grpc/grpc-js/src/client-interceptors.ts:458:34)
        at Object.onReceiveStatus (/snapshot/eks/node_modules/@grpc/grpc-js/src/client-interceptors.ts:419:48)
        at /snapshot/eks/node_modules/@grpc/grpc-js/src/resolving-call.ts:163:24
        at processTicksAndRejections (node:internal/process/task_queues:77:11)```

### Example

package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
	"github.com/pulumi/pulumi-awsx/sdk/go/awsx/ec2"
	"github.com/pulumi/pulumi-eks/sdk/v3/go/eks"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		vpc, _ := ec2.NewVpc(ctx, "vpc", &ec2.VpcArgs{
			EnableDnsHostnames: pulumi.Bool(true),
			EnableDnsSupport:   pulumi.Bool(true),
			NatGateways: &ec2.NatGatewayConfigurationArgs{
				Strategy: ec2.NatGatewayStrategyNone,
			},
		})

		vpcId := vpc.VpcId

		privateSubnetIds := vpc.PrivateSubnetIds

		eksClusterArgs := &eks.ClusterArgs{
			Name:         pulumi.String("my-cluster"),
			VpcId:        vpcId,
			InstanceType: pulumi.String("t3.medium"),
			PrivateSubnetIds: privateSubnetIds,
		}

		cluster, err := eks.NewCluster(ctx,
			"my-cluster",
			eksClusterArgs,
			pulumi.Protect(false))

		if err != nil {
			return err
		}

		nodeGroupRole, err := iam.NewRole(ctx, "nodeGroupRole", &iam.RoleArgs{
			AssumeRolePolicy: pulumi.String(`{
				"Version": "2012-10-17",
				"Statement": [{
					"Effect": "Allow",
					"Principal": {
						"Service": "ec2.amazonaws.com"
					},
					"Action": "sts:AssumeRole"
				}]
			}`),
		})
		if err != nil {
			return err
		}

		// Attach managed policies to the role
		policyArns := []string{
			"arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy",
			"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy",
			"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly",
		}

		for _, policyArn := range policyArns {
			_, err = iam.NewRolePolicyAttachment(ctx, policyArn, &iam.RolePolicyAttachmentArgs{
				Role:      nodeGroupRole.Name,
				PolicyArn: pulumi.String(policyArn),
			})
			if err != nil {
				return err
			}
		}

		// Create IAM Instance Profile
		instanceProfile, err := iam.NewInstanceProfile(ctx, "nodeGroupInstanceProfile", &iam.InstanceProfileArgs{
			Role: nodeGroupRole.Name,
		})
		if err != nil {
			return err
		}

		// Create an additional node group
		_, err = eks.NewNodeGroupV2(ctx,
			"extra-node-group",
			&eks.NodeGroupV2Args{
				Cluster:         cluster.EksCluster.Name(),
				NodeSubnetIds:   privateSubnetIds,
				DesiredCapacity: pulumi.Int(2),
				InstanceType:    pulumi.String("t3.medium"),
				MinSize:         pulumi.Int(1),
				MaxSize:         pulumi.Int(3),
				InstanceProfile: instanceProfile,
			},
			pulumi.Protect(false))

		if err != nil {
			return err
		}

		return nil
	})
}


### Output of `pulumi about`

CLI          
Version      3.145.0
Go Version   go1.23.4
Go Compiler  gc

Plugins
KIND      NAME        VERSION
resource  aws         6.66.2
resource  aws         5.35.0
resource  awsx        1.0.6
resource  docker      3.2.0
resource  eks         3.7.0
language  go          3.145.0
resource  kubernetes  4.9.1

Host     
OS       darwin
Version  14.4
Arch     arm64

This project is written in go: executable='/opt/homebrew/bin/go' version='go version go1.23.1 darwin/arm64'

...

Found no resources associated with dev

Found no pending operations associated with dev

Backend        
...

Dependencies:
NAME                                 VERSION
github.com/pulumi/pulumi/sdk/v3      v3.145.0
github.com/pulumi/pulumi-awsx/sdk    v1.0.6
github.com/pulumi/pulumi-eks/sdk/v3  v3.7.0

Pulumi locates its logs in /var/folders/68/1bv_wkxd4fgf81z7l3r37yy40000gn/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). 
@jdavredbeard jdavredbeard added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jan 8, 2025
@flostadler
Copy link
Contributor

@jdavredbeard @t0yv0 explained in #1579 (comment) that passing Cluster: cluster.EksCluster.Name() is not a legitimate way to pass the cluster to NodeGroupV2 but our Go projection is not type-safe enough to reject that. This causes null pointers in later parts of the code that expect to operate on defined props.
Can you try passing the cluster component instead? This should work.

In in lieu of type-safety for Unions in the Go SDK we should add early null checks for the cluster argument wherever it's used to throw a better error message here.

@flostadler flostadler removed the needs-triage Needs attention from the triage team label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants