but it seems the same thing in Go would require me...
# golang
i
but it seems the same thing in Go would require me to build the policy string
w
Currently, you need to build the string. Supporting a strongly typed way to build these JSON objects in Go, .net and Python is tracked in https://github.com/pulumi/pulumi-terraform-bridge/issues/132 which is partly complete - and hopefully will be completed soon!
i
great thanks - For now i wrote a little helper for Go’s template library that makes it easy to use outputs with templates
my current hack, if you’re curious:
Copy code
Policy: pulutil.Template(map[string]interface{}{
                                "BucketARN": bucket.Arn,
                                "KeyARN":    key.Arn,
                        }, `{
                                        "Version": "2012-10-17",
                                        "Statement": [
                                                {
                                                        "Effect": "Allow",
                                                        "Action": [
                                                                "s3:ListBucket"
                                                        ],
                                                        "Resource": [
                                                                "{{ .BucketARN }}"
                                                        ]
                                                },{
                                                        "Sid": "S3PutAndGetAccess",
                                                        "Effect": "Allow",
                                                        "Action": [
                                                                "s3:PutObject",
                                                                "s3:GetObject"
                                                        ],
                                                        "Resource": [
                                                                "{{ .BucketARN }}/*"
                                                        ]
                                                }, {
                                                        "Sid": "KMSDecryptAndEncryptAccess",
                                                        "Effect": "Allow",
                                                        "Action": [
                                                                "kms:Decrypt",
                                                                "kms:Encrypt"
                                                        ],
                                                        "Resource": "{{ .KeyARN }}"
                                                }
                                        ]
                                }`),
👍 1