{"action":"created","issue":{"url":"https://api.github.com/repos/pulumi/pulumi/issues/2012","repository_url":"https://api.github.com/repos/pulumi/pulumi","labels_url":"https://api.github.com/repos/pulumi/pulumi/issues/2012/labels{/name}","comments_url":"https://api.github.com/repos/pulumi/pulumi/issues/2012/comments","events_url":"https://api.github.com/repos/pulumi/pulumi/issues/2012/events","html_url":"https://github.com/pulumi/pulumi/issues/2012","id":366073408,"node_id":"MDU6SXNzdWUzNjYwNzM0MDg=","number":2012,"title":"Changes to 1st class provider inputs forcing recreation of provider and all dependent resources","user":{"login":"lukehoban","id":223467,"node_id":"MDQ6VXNlcjIyMzQ2Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/223467?v=4","gravatar_id":"","url":"https://api.github.com/users/lukehoban","html_url":"https://github.com/lukehoban","followers_url":"https://api.github.com/users/lukehoban/followers","following_url":"https://api.github.com/users/lukehoban/following{/other_user}","gists_url":"https://api.github.com/users/lukehoban/gists{/gist_id}","starred_url":"https://api.github.com/users/lukehoban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukehoban/subscriptions","organizations_url":"https://api.github.com/users/lukehoban/orgs","repos_url":"https://api.github.com/users/lukehoban/repos","events_url":"https://api.github.com/users/lukehoban/events{/privacy}","received_events_url":"https://api.github.com/users/lukehoban/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"lukehoban","id":223467,"node_id":"MDQ6VXNlcjIyMzQ2Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/223467?v=4","gravatar_id":"","url":"https://api.github.com/users/lukehoban","html_url":"https://github.com/lukehoban","followers_url":"https://api.github.com/users/lukehoban/followers","following_url":"https://api.github.com/users/lukehoban/following{/other_user}","gists_url":"https://api.github.com/users/lukehoban/gists{/gist_id}","starred_url":"https://api.github.com/users/lukehoban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukehoban/subscriptions","organizations_url":"https://api.github.com/users/lukehoban/orgs","repos_url":"https://api.github.com/users/lukehoban/repos","events_url":"https://api.github.com/users/lukehoban/events{/privacy}","received_events_url":"https://api.github.com/users/lukehoban/received_events","type":"User","site_admin":false},"assignees":[{"login":"lukehoban","id":223467,"node_id":"MDQ6VXNlcjIyMzQ2Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/223467?v=4","gravatar_id":"","url":"https://api.github.com/users/lukehoban","html_url":"https://github.com/lukehoban","followers_url":"https://api.github.com/users/lukehoban/followers","following_url":"https://api.github.com/users/lukehoban/following{/other_user}","gists_url":"https://api.github.com/users/lukehoban/gists{/gist_id}","starred_url":"https://api.github.com/users/lukehoban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukehoban/subscriptions","organizations_url":"https://api.github.com/users/lukehoban/orgs","repos_url":"https://api.github.com/users/lukehoban/repos","events_url":"https://api.github.com/users/lukehoban/events{/privacy}","received_events_url":"https://api.github.com/users/lukehoban/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/pulumi/pulumi/milestones/32","html_url":"https://github.com/pulumi/pulumi/milestone/32","labels_url":"https://api.github.com/repos/pulumi/pulumi/milestones/32/labels","id":3434037,"node_id":"MDk6TWlsZXN0b25lMzQzNDAzNw==","number":32,"title":"0.18","description":"","creator":{"login":"joeduffy","id":3953235,"node_id":"MDQ6VXNlcjM5NTMyMzU=","avatar_url":"https://avatars3.githubusercontent.com/u/3953235?v=4","gravatar_id":"","url":"https://api.github.com/users/joeduffy","html_url":"https://github.com/joeduffy","followers_url":"https://api.github.com/users/joeduffy/followers","following_url":"https://api.github.com/users/joeduffy/following{/other_user}","gists_url":"https://api.github.com/users/joeduffy/gists{/gist_id}","starred_url":"https://api.github.com/users/joeduffy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeduffy/subscriptions","organizations_url":"https://api.github.com/users/joeduffy/orgs","repos_url":"https://api.github.com/users/joeduffy/repos","events_url":"https://api.github.com/users/joeduffy/events{/privacy}","received_events_url":"https://api.github.com/users/joeduffy/received_events","type":"User","site_admin":false},"open_issues":23,"closed_issues":44,"state":"open","created_at":"2018-06-18T22:42:38Z","updated_at":"2018-10-05T04:00:08Z","due_on":"2018-10-14T07:00:00Z","closed_at":null},"comments":2,"created_at":"2018-10-02T20:48:02Z","updated_at":"2018-10-05T14:34:27Z","closed_at":null,"author_association":"MEMBER","body":"From @geekflyer on Slack:\r\n\r\n> The problem I’m suddenly facing is that when anything non-substantial in the cluster changes, pulumi also wants to recreate (replace) the k8s provider and ALL the resources that have been previously created by that provider. Non-substantial changes in my case for example is that one of the node-pools scaled down by 1 instance. \r\n\r\nHe is creating a `new new k8s.Provider` using code like below which `.get`s the kubeconfig off a GKE resource.  This is causing even small changes to the GKE instance to trigger the K8s provider to get replaced, and in turn all the Kubernetes resources.\r\n\r\n```typescript\r\nimport * as gcp from '@pulumi/gcp';\r\nimport * as pulumi from '@pulumi/pulumi';\r\nimport * as k8s from '@pulumi/kubernetes';\r\nimport { Cluster } from '@pulumi/gcp/container';\r\nimport { defaultZone, defaultProject } from './gcp-constants';\r\nimport { memoize } from 'ramda';\r\nimport { packageConfig } from './misc';\r\n\r\nconst gcpConfig = new pulumi.Config('gcp');\r\n\r\n// most of the functions in this module are memoized. This is to improve lookup speed in bigger pulumi programs like solvvy-apis and\r\n// to avoid resource id conflicts in pulumi when importing the same cluster / resource multiple times.\r\n\r\nexport const lookupClusterByName = memoize(\r\n  (clusterName: string): Cluster => {\r\n    return Cluster.get(clusterName, clusterName, {\r\n      name: clusterName,\r\n      zone: gcpConfig.get('zone') || defaultZone,\r\n      project: gcpConfig.get('project') || defaultProject\r\n    });\r\n  }\r\n);\r\n\r\nexport function kubectlConfigFromGkeCluster(cluster: Cluster) {\r\n  return pulumi.all([cluster.name, cluster.endpoint, cluster.masterAuth]).apply(([name, endpoint, auth]) => {\r\n    const context = `${gcp.config.project}_${gcp.config.zone}_${name}`;\r\n    return `apiVersion: v1\r\nclusters:\r\n- cluster:\r\n    certificate-authority-data: ${auth.clusterCaCertificate}\r\n    server: https://${endpoint}\r\n  name: ${context}\r\ncontexts:\r\n- context:\r\n    cluster: ${context}\r\n    user: ${context}\r\n  name: ${context}\r\ncurrent-context: ${context}\r\nkind: Config\r\npreferences: {}\r\nusers:\r\n- name: ${context}\r\n  user:\r\n    auth-provider:\r\n      config:\r\n        cmd-args: config config-helper --format=json\r\n        cmd-path: gcloud\r\n        expiry-key: '{.credential.token_expiry}'\r\n        token-key: '{.credential.access_token}'\r\n      name: gcp\r\n`;\r\n  });\r\n}\r\n\r\nexport const getK8sProviderByClusterName: (clusterName: string) => k8s.Provider = memoize((clusterName: string) => {\r\n  return new k8s.Provider(clusterName, {\r\n    kubeconfig: kubectlConfigFromGkeCluster(lookupClusterByName(clusterName))\r\n  });\r\n});\r\n\r\nexport const getK8sProviderByCluster = memoize((providerInstanceName: string, cluster: Cluster) => {\r\n  return new k8s.Provider(providerInstanceName, {\r\n    kubeconfig: kubectlConfigFromGkeCluster(cluster)\r\n  });\r\n});\r\n\r\nexport const getK8sProviderFromInferredCluster = memoize(() => {\r\n  const clusterName = packageConfig.require('cluster');\r\n  return new k8s.Provider(clusterName, {\r\n    kubeconfig: kubectlConfigFromGkeCluster(lookupClusterByName(clusterName))\r\n  });\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/pulumi/pulumi/issues/comments/427387020","html_url":"https://github.com/pulumi/pulumi/issues/2012#issuecomment-427387020","issue_url":"https://api.github.com/repos/pulumi/pulumi/issues/2012","id":427387020,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNzM4NzAyMA==","user":{"login":"hazsetata","id":2191583,"node_id":"MDQ6VXNlcjIxOTE1ODM=","avatar_url":"https://avatars3.githubusercontent.com/u/2191583?v=4","gravatar_id":"","url":"https://api.github.com/users/hazsetata","html_url":"https://github.com/hazsetata","followers_url":"https://api.github.com/users/hazsetata/followers","following_url":"https://api.github.com/users/hazsetata/following{/other_user}","gists_url":"https://api.github.com/users/hazsetata/gists{/gist_id}","starred_url":"https://api.github.com/users/hazsetata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hazsetata/subscriptions","organizations_url":"https://api.github.com/users/hazsetata/orgs","repos_url":"https://api.github.com/users/hazsetata/repos","events_url":"https://api.github.com/users/hazsetata/events{/privacy}","received_events_url":"https://api.github.com/users/hazsetata/received_events","type":"User","site_admin":false},"created_at":"2018-10-05T14:34:27Z","updated_at":"2018-10-05T14:34:27Z","author_association":"NONE","body":"I had a very similar experience today with an Azure AKS cluster. The main difference is that I create the cluster itself also in Pulumi code.\r\n\r\nHere are the parts that create the cluster and the provider:\r\n\r\n```typescript\r\nconst adApplication = new azure.ad.Application(\"BZV2\");\r\nexport const adServicePrincipal = new azure.ad.ServicePrincipal(\"BZV2-SP\", { applicationId: adApplication.applicationId });\r\n\r\nconst adServicePrincipalPassword = new azure.ad.ServicePrincipalPassword(\"BZV2-SP-Password\", {\r\n    servicePrincipalId: adServicePrincipal.id,\r\n    value: config.servicePrincipalPassword,\r\n    endDate: \"2099-01-01T00:00:00Z\",\r\n});\r\n\r\nexport const k8sResourceGroup = new azure.core.ResourceGroup(\"BZV2-RG\", {\r\n    location: config.location,\r\n});\r\n\r\nexport const k8sCluster = new azure.containerservice.KubernetesCluster(\"BZV2-K8S\", {\r\n    resourceGroupName: k8sResourceGroup.name,\r\n    location: config.location,\r\n    kubernetesVersion: config.kubernetesVersion,\r\n    agentPoolProfile: {\r\n        name: \"bzagentpool\",\r\n        count: config.nodeCount,\r\n        vmSize: config.nodeSize,\r\n    },\r\n    dnsPrefix: `${pulumi.getStack()}-bzcluster`,\r\n    linuxProfile: {\r\n        adminUsername: \"adminuser\",\r\n        sshKeys: [{\r\n            keyData: config.sshPublicKey,\r\n        }],\r\n    },\r\n    servicePrincipal: {\r\n        clientId: adApplication.applicationId,\r\n        clientSecret: adServicePrincipalPassword.value,\r\n    },\r\n});\r\n\r\n// Expose a K8s provider instance using our custom cluster instance.\r\nexport const k8sProvider = new k8s.Provider(\"BZV2-K8S-Provider\", {\r\n    kubeconfig: k8sCluster.kubeConfigRaw,\r\n});\r\n```\r\nThen I use this provider to deploy all kinds of Kubernetes resources (cert-manager, heptio-contour, argo and own apps). I updated many things in the cluster (I'm on update 39) without any trouble.\r\n\r\nNow once I changed the node count (`pulumi config set nodeCount 6`) and tried to run the update,\r\nI get this kind of output (this is the only change in the code / config):\r\n\r\n```\r\ninfo: 50 changes previewed:\r\n    ~ 3 resources to update\r\n    +-47 resources to replace\r\n      29 resources unchanged\r\n\r\nDo you want to perform this update? details\r\n* pulumi:pulumi:Stack: (same)\r\n    [urn=urn:pulumi:bzdev::beyondzen::pulumi:pulumi:Stack::beyondzen-bzdev]\r\n    ~ azure:containerservice/kubernetesCluster:KubernetesCluster: (update)\r\n        [id=/subscriptions/<SUBSCRIPTION_ID>/resourcegroups/BZV2-rgb1b9bc11/providers/Microsoft.ContainerService/managedClusters/BZV2-k8s9032af03]\r\n        [urn=urn:pulumi:bzdev::beyondzen::azure:containerservice/kubernetesCluster:KubernetesCluster::BZV2-K8S]\r\n      ~ agentPoolProfile : {\r\n          ~ count : 2 => 6\r\n        }\r\n    ++pulumi:providers:kubernetes: (create-replacement)\r\n        [id=a9e97d3f-33a5-4618-9db6-a4e22821f00c]\r\n        [urn=urn:pulumi:bzdev::beyondzen::pulumi:providers:kubernetes::BZV2-K8S-Provider]\r\n      ~ kubeconfig: \"apiVersion: v1\\nclusters:\\n- cluster:\\n    certificate-authority-data: LS...\\n\" => computed<string>\r\n    +-pulumi:providers:kubernetes: (replace)\r\n        [id=a9e97d3f-33a5-4618-9db6-a4e22821f00c]\r\n        [urn=urn:pulumi:bzdev::beyondzen::pulumi:providers:kubernetes::BZV2-K8S-Provider]\r\n      ~ kubeconfig: \"apiVersion: v1\\nclusters:\\n- cluster:\\n    certificate-authority-data: LS...\\n\" => computed<string>\r\n        ++kubernetes:core/v1:Namespace: (create-replacement)\r\n            [id=cert-manager]\r\n            [urn=urn:pulumi:bzdev::beyondzen::vtt:k8s:CertManagerDeployment$kubernetes:core/v1:Namespace::cert-manager-ns]\r\n            [provider: urn:pulumi:bzdev::beyondzen::pulumi:providers:kubernetes::BZV2-K8S-Provider::a9e97d3f-33a5-4618-9db6-a4e22821f00c => urn:pulumi:bzdev::beyondzen::pulumi:providers:kubernetes::BZV2-K8S-Provider::computed<string>]\r\n          * apiVersion: \"v1\"\r\n          * kind      : \"Namespace\"\r\n          * metadata  : {\r\n              * name: \"cert-manager\"\r\n            }\r\n        +-kubernetes:core/v1:Namespace: (replace)\r\n            [id=cert-manager]\r\n            [urn=urn:pulumi:bzdev::beyondzen::vtt:k8s:CertManagerDeployment$kubernetes:core/v1:Namespace::cert-manager-ns]\r\n            [provider: urn:pulumi:bzdev::beyondzen::pulumi:providers:kubernetes::BZV2-K8S-Provider::a9e97d3f-33a5-4618-9db6-a4e22821f00c => urn:pulumi:bzdev::beyondzen::pulumi:providers:kubernetes::BZV2-K8S-Provider::computed<string>]\r\n          * apiVersion: \"v1\"\r\n          * kind      : \"Namespace\"\r\n          * metadata  : {\r\n              * name: \"cert-manager\"\r\n            }\r\n```\r\n\r\nAnd it continues on. The indicated change for the provider is the `kubeconfig` property. In all the other resources it is the `provider` property. The 3 resources it wants to only update are the Cluster itself, and two DNS records (all Azure components and not Kubernetes ones).\r\n\r\nPulumi CLI version: v0.15.4, @pulumi/pulumi: 0.15.4, @pulumi/azure: 0.15.2, @pulumi/kubernetes: 0.17.0"}}
{"actor":{"display_login":"hazsetata"}}