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] yaml.NewConfigGroup() duplicate resource URN error when managed with multiple provider #3490

Closed
abbshr opened this issue Feb 13, 2025 · 1 comment
Labels
kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team

Comments

@abbshr
Copy link

abbshr commented Feb 13, 2025

What happened?

I have a infra stack with multiple clusters need to manage, each cluster should apply the same yaml files.

i already assigned unique resource name, but got the error from pulumi cli:
Image

it seems yaml.NewConfigGroup() doesn't add the prefix of ConfigGroup name or something else to the child resources name.

Example

sample code goes here:

package main

import (
	"os"
	"path/filepath"

	"github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes"
	"github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/yaml"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		clusters := []string{
			"cluster-1",
			"cluster-2",
		}
		for _, cluster := range clusters {
			kubeconfigContent, err := GetKubeConfigContent(cluster)
			if err != nil {
				return err
			}

			// k8s provider
			k8sProvider, err := kubernetes.NewProvider(ctx, cluster+"-k8sprovider", &kubernetes.ProviderArgs{
				Kubeconfig: pulumi.String(kubeconfigContent),
			})
			if err != nil {
				return err
			}

			// apply yaml
			if _, err = yaml.NewConfigGroup(ctx, cluster+"-namespace", &yaml.ConfigGroupArgs{
				Files: []string{
					"monitoring.yaml",
				},
			}, pulumi.Provider(k8sProvider)); err != nil {
				return err
			}
		}

		return nil
	})
}

func GetKubeConfigContent(cluster string) ([]byte, error) {
	home := os.Getenv("HOME")
	return os.ReadFile(filepath.Join(home, "/.kube", cluster))
}

Output of pulumi about

CLI          
Version      3.146.0
Go Version   go1.23.4
Go Compiler  gc

Plugins
KIND      NAME        VERSION
language  go          3.146.0
resource  kubernetes  4.21.1

Host     
OS       debian
Version  11.4
Arch     x86_64

This project is written in go: executable='/usr/local/go-versions/1.22/go/bin/go' version='go version go1.22.4 linux/amd64'

Current Stack: organization/vke_test/dev

Found no resources associated with dev

Found no pending operations associated with dev

Backend        
Name           ws08db001bae9cd582-678f7b8566-xm2mm
URL            file://~
User           byteide
Organizations  
Token type     personal

Dependencies:
NAME                             VERSION
github.com/pulumi/pulumi/sdk/v3  v3.146.0

Pulumi locates its logs in /tmp 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).

@abbshr abbshr added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Feb 13, 2025
@abbshr abbshr changed the title yaml.NewConfigGroup does not support multiple provider yaml.NewConfigGroup() duplicate resource URN error when managed with multiple provider Feb 13, 2025
@abbshr abbshr changed the title yaml.NewConfigGroup() duplicate resource URN error when managed with multiple provider [go sdk] yaml.NewConfigGroup() duplicate resource URN error when managed with multiple provider Feb 13, 2025
@abbshr
Copy link
Author

abbshr commented Feb 14, 2025

i found that using yaml/v2 package could solve this problem

@abbshr abbshr closed this as completed Feb 14, 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 needs-triage Needs attention from the triage team
Projects
None yet
Development

No branches or pull requests

1 participant