@here Has anyone written a transformation like thi...
# golang
g
@here Has anyone written a transformation like this within golang? I'm having a heck of a time figuring it out. I need to transform the args to the underlying calls because the partitions are different on aws GovCloud for this security policies. I submitted and had accepted a PR to solve the underlying issue, but it's not released yet and I'd really like to get my test within Govcloud completed so I can work on some efforts in paralell while I wait for the plugin to be updated. https://github.com/pulumi/pulumi-eks/issues/570#issuecomment-829343861 ref: https://github.com/pulumi/pulumi-eks/pull/788 < This will remove the need for the transformation, but generally I will find another case where I have to transform again while getting this POC on govCloud working
b
I’m not sure it’s exactly the same, but here is one I’ve done with `yaml.NewConfigFile`:
Copy code
Transformations: []yaml.Transformation{
			// Use an NLB instead of an ELB
			func(state map[string]interface{}, opts ...pulumi.ResourceOption) {
				metadata := state["metadata"].(map[string]interface{})
				name := metadata["name"]
				if state["kind"] == "Service" && name == "envoy" {
					annotations := metadata["annotations"].(map[string]interface{})
					delete(annotations, "<http://service.beta.kubernetes.io/aws-load-balancer-backend-protocol|service.beta.kubernetes.io/aws-load-balancer-backend-protocol>")
					annotations["<http://service.beta.kubernetes.io/aws-load-balancer-type|service.beta.kubernetes.io/aws-load-balancer-type>"] = "nlb"
				}

				// We need to handle the fact we're using a wildcard cert,
				// and for certain browsers (Safari), this is an issue with
				// HTTP/2. As such, we only enable HTTP/1.
				// Read more here: <https://projectcontour.io/resources/faq/#q-when-i-load-my-site-in-safari-it-shows-me-an-empty-page-developer-tools-show-that-the-http-response-was-421-why-does-this-happen>
				if state["kind"] == "ConfigMap" && name == "contour" {
					data := state["data"].(map[string]interface{})
					contourConfig := data["contour.yaml"].(string)
					defaultHttpVersion := "default-http-versions:\n" + "- HTTP/1.1"
					contourConfig = contourConfig + "\n" + defaultHttpVersion
					data["contour.yaml"] = contourConfig
				}
			},
		},
g
This helps some. It's just difficult to determine the type Args is in golang
b
Yeah, the way I usually do it is I just print it out or get a compilation error by casting it to something nonsensical
and iterating
g
My struggles really begin because Args is just a pulumi.Output which I have to resolve in an Apply. Which I can't get to print out at all.
b
Ah yes, that makes it much more difficult.