Is there any chance there's a golang version of th...
# golang
f
Is there any chance there's a golang version of this example: https://github.com/pulumi/pulumi-eks/blob/f60263061a85d2817ecd0fd4c3dbc6505e4a8df9/examples/oidc-iam-sa/index.ts#L37-L51 I'm struggling to translate this functionality to my code.
I managed to figure this out, but not with using Pulumi.All - that still eludes me
n
Untested code, but should look like that more or less. 🙂
Copy code
pulumi.All(clusterOidcProviderUrl, clusterOidcProvider.ARN, appsNamespaceName).ApplyT(func(all []interface{}) (*iam.GetPolicyDocumentResult, error) {
	doc, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
		Statements: []iam.GetPolicyDocumentStatement{
			iam.GetPolicyDocumentStatement{
				Actions: []string{
					"sts:AssumeRoleWithWebIdentity",
				},
				Conditions: []iam.GetPolicyDocumentStatementCondition{
					iam.GetPolicyDocumentStatementCondition{
						Test:     "StringEquals",
						Variable: strings.Replace(all[0].(string), "https://", "") + ":sub",
						Values: []string{
							fmt.Sprintf("system:serviceaccount:%s:%s", all[2].(string), "s3"),
						},
					},
				},
				Effect: "Allow",
				Principals: []iam.GetPolicyDocumentStatementPrincipal{
					iam.GetPolicyDocumentStatementPrincipal{
						Identifiers: []string{all[1].(pulumi.URN)}
					},
				},
			},
		},
	}, nil)

	if err != nil {
		return nil, err
	}

	return doc, nil
})
Hope it helps 😉
f
Thanks!
For some reason I didn't think to use an []interface as the parameter in the applyT function. I just kept getting errors about what I was trying. This should help a lot.
🙏 1