Hey guys, I'm working on a new stack (involding Az...
# azure
f
Hey guys, I'm working on a new stack (involding Azure AKS) and keep getting these error messages when trying to
pulumi up
. I'm logged in successfully to Azure via
az login
still the
pulumi up
command keeps asking for interactive sign-in via web page:
Copy code
To sign in, use a web browser to open the page <https://microsoft.com/devicelogin> and enter the code {code here} to authenticate.
    E1208 08:11:52.773315   15608 azure.go:154] Failed to acquire a token: failed acquiring new token: waiting for device code authentication to complete: autorest/adal/devicetoken: Error while retrieving OAuth token: Code Expired
Eventually the command times out. I'm on Pulumi version 2.15.3 and latest npm packages Additional details: I can get a correct preview of the stack:
i
you need to get admin provider kubeconfig
Copy code
containerservice.listManagedClusterAdminCredentials({
          resourceGroupName,
          resourceName
        });
or you should enter
devicelogin
every single time
Copy code
public static getKubeconfig(
    clusterName: pulumi.Input<string>,
    resourceGroupName: pulumi.Input<string>
  ): pulumi.Output<string> {
    const creds = pulumi
      .all([clusterName, resourceGroupName])
      .apply(([resourceName, resourceGroupName]) => {
        return containerservice.listManagedClusterAdminCredentials({
          resourceGroupName,
          resourceName
        });
      });

    const encoded = creds.kubeconfigs[0].value;
    return encoded.apply(enc => Buffer.from(enc, 'base64').toString());
  }

  public static getProvider(
    name: pulumi.Input<string>,
    kubeconfig: pulumi.Input<string>,
    opts?: pulumi.ResourceOptions
  ): k8s.Provider {
    return new k8s.Provider(
      `${name}-k8s`,
      {
        kubeconfig,
        suppressDeprecationWarnings: true
      },
      opts
    );
  }
then use output from getProvider inside each k8s resource
f
Thanks! 👑