Hello. Does anyone know how to implement the sugge...
# general
b
Hello. Does anyone know how to implement the suggested approach from the error message below in golang ?
Copy code
./main.go:123:3: cannot use arn (type pulumi.StringOutput) as type pulumi.StringMapInput in field value:
    	pulumi.StringOutput does not implement pulumi.StringMapInput (missing ToStringMapOutput method)

    error: an unhandled error occurred: program exited with non-zero exit code: 2
I am trying to create a Kubernetes secret from a secret stored in AWS Secrets Manager. I can lookup the secret in SecretsManager but I don;t know how I can pass the secret data in to the kubernetes secret pulumi module.
Copy code
func CreateK8sSecret(ctx *pulumi.Context, arn pulumi.StringOutput, label pulumi.StringMap, provider *kubernetes.Provider) error {
	found_secret := secretsmanager.LookupSecretOutput(ctx, secretsmanager.LookupSecretOutputArgs{
		Arn: arn, # Don't know how I could pass the secret data in
	}, nil)

	ctx.Export("kubernetes_secret", found_secret)

	corev1.NewSecret(ctx, "pulumi-secret", &corev1.SecretArgs{
		// Data: pulumi.StringMap{"pulumi": pulumi.String("new environment")},
		Data: arn,
		Metadata: &metav1.ObjectMetaArgs{
			Labels: label,
		},
	}, pulumi.Provider(provider))

	return nil
}
s
You may need to use
apply
to use a regular string to create the
pulumi.StringMap
. Here's a sorta-similar example of using the ARN of a secret to formulate an IAM policy doc. There may be a better way, but I think this will get you un-stuck: https://github.com/pulumi/github-issue-automation/blob/main/pulumi/main.go#L108-L139
👍 1
👀 1
b
@stocky-restaurant-98004 That is pretty close to what I am trying to do. But I want to be able to pass in the secrets data to the pulumi kubernetes secret module
data
parameter. https://github.com/pulumi/pulumi-kubernetes/blob/master/sdk/go/kubernetes/core/v1/secret.go#L31
I have something like this as the secrets arn
arn:aws:secretsmanager:us-east-1:678129227502:secret:pulumisecret-7s7QC6
And I would like to extract its data and pass it to the pulumi kubernetes secrets module
The end goal is to create a Kubernetes secret object from a secret stored in AAWS Secrets Manager
All my attempts to convert the secret data output which is a key value pair have failed.
Copy code
data := secretData.ApplyT(func(v pulumi.Map) string {
			return fmt.Sprintf("%v", v)
		}).(pulumi.MapOutput)
		// Create new kubernetes secretes object
		corev1.NewSecret(ctx, "pulumi-secret", &corev1.SecretArgs{
			StringData: data,
			Metadata: &metav1.ObjectMetaArgs{
				Namespace: namespace.Metadata.Elem().Name(),
				Labels:    appLabels,
			},
		})
The above code is getting me the following error
Copy code
Diagnostics:
  pulumi:pulumi:Stack (kubernetes-ccmx/kubernetes/dev):
    # kubernetes
    ./main.go:108:22: cannot use fmt.Sprintf("%v", v) (type string) as type pulumi.StringMapOutput in return argument
    ./main.go:112:4: cannot use data (type pulumi.Output) as type pulumi.StringMapInput in field value:
    	pulumi.Output does not implement pulumi.StringMapInput (missing ToStringMapOutput method)

    error: an unhandled error occurred: program exited with non-zero exit code: 2
123 Views