salmon-raincoat-19475
11/02/2021, 7:02 PMOutput
class in Python - which seems to suggest that it needs to stay in the Output
type so that Pulumi objects are realized....
Is there a different approach I should be taking? Thanks!billowy-army-68599
apply
I thinksalmon-raincoat-19475
11/02/2021, 7:05 PMapply
kubeconfig = open('kubeconfig', 'w')
kjson = self.cluster.kubeconfig.apply(json.dumps)
kubeconfig.write(kjson)
pulumi.export('kubeconfig', self.cluster.kubeconfig)
billowy-army-68599
BucketObject
resource to write the file, you're trying to write locally at the moment?salmon-raincoat-19475
11/02/2021, 7:06 PMkubeconfig.write(kjson)
TypeError: write() argument must be str, not Output
billowy-army-68599
def write_to_file(kubeconfig):
f = open("kubeconfig.json", "a")
f.write(kubeconfig)
f.close()
json = self.cluster.kubeconfig.apply(lambda k: write_to_file(kubeconfig=k))
apply
needs to take a function to operate on, so simply doing json.dumps
won't get it, and you need to actually do the write inside the applysalmon-raincoat-19475
11/02/2021, 7:43 PMbucket = pulumi_aws.s3.get_bucket("my_bucket_name")
source = self.cluster.kubeconfig.apply(lambda s: pulumi.asset.StringAsset(json.dumps(s)))
filename = f'{self.env_stack}-kubeconfig'
pulumi_aws.s3.BucketObject(resource_name=filename,
bucket=bucket.id,
key=f'some/sub_dir/{filename}',
source=source
)