bright-needle-80161
03/16/2022, 10:47 PM./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.
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
}
stocky-restaurant-98004
03/17/2022, 3:38 PMapply
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-L139bright-needle-80161
03/17/2022, 4:06 PMdata
parameter. https://github.com/pulumi/pulumi-kubernetes/blob/master/sdk/go/kubernetes/core/v1/secret.go#L31arn:aws:secretsmanager:us-east-1:678129227502:secret:pulumisecret-7s7QC6
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,
},
})
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