sparse-intern-71089
11/02/2021, 7:02 PMbillowy-army-68599
apply
I thinkbillowy-army-68599
salmon-raincoat-19475
11/02/2021, 7:05 PMapply
kubeconfig = open('kubeconfig', 'w')
kjson = self.cluster.kubeconfig.apply(json.dumps)
kubeconfig.write(kjson)
salmon-raincoat-19475
11/02/2021, 7:05 PMpulumi.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 PMsalmon-raincoat-19475
11/02/2021, 7:07 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))
billowy-army-68599
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 applybillowy-army-68599
salmon-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
)