I'm writing IaC to deploy Amazon EKS in Pulumi + typescript. I am using GitHub Actions as my CI/CD.
Currently I can create the EKS cluster via my pipeline with pulumi without issue but I have not figured out a clean way to acquire the resulting kubeconfig.
I can get the kubeconfig via the frequently documented example by exporting the cluster.kubeconfig value and then executing the stack output kubeconfig subcommand
# code snippet
export const kubeconfig = cluster.kubeconfig;
# command
pulumi stack output kubeconfig > kubeconfig.yml
As a current workaround, I am using this method to create the kubeconfig file in github actions, and then using an aws s3
cli command to upload the file to s3.
I have already created a private s3 bucket with kms encryption in my pulumi iac and defined the kubeconfig output in my iac. Is there a way to write my pulumi typescript code to push the output directly to my s3 bucket without these intermediary steps?
UPDATE1: Current best effort brings me to:
const keksAdminBucket = new aws.s3.Bucket("keksAdminBucket", {acl: "private"});
const keksAdminBucketObject = new aws.s3.BucketObject("keksAdminBucketObject", {
key: "kubeconfig",
bucket: keksAdminBucket.id,
source: new pulumi.asset.StringAsset(String(cluster.kubeconfig)),
serverSideEncryption: "aws:kms",
});
This and variations on the theme result in errors like:
index.ts(45,42): error TS2345: Argument of type 'Output<any>' is not assignable to parameter of type 'string | Promise<string>'.
Type 'OutputInstance<any>' is not assignable to type 'string | Promise<string>'.
Type 'OutputInstance<any>' is missing the following properties from type 'Promise<string>': then, catch, [Symbol.toStringTag], finally