Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

providerCredentialOpts option not working as expected. #1508

Open
sanketg86 opened this issue Nov 29, 2024 · 1 comment
Open

providerCredentialOpts option not working as expected. #1508

sanketg86 opened this issue Nov 29, 2024 · 1 comment
Labels
awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec

Comments

@sanketg86
Copy link

What happened?

I am using latest nodejs @pulumi/eks version 3.3.0 and try to create eks cluster but getting below error

error: Unhandled exception: Error: failed to register new resource eks-test [eks:index:Cluster]: 2 UNKNOWN: Default provider for 'eks' disabled. 'eks:index:Cluster' must use an explicit provider.

I disable default provider and pass the providerCredentialOpts to eks.cluster resource.

Example

Code

create AWS provider

const awsProvider = new aws.Provider('aws', {
      region: 'eu-north-1' as aws.Region,
      assumeRole: {
        roleArn: `arn:aws:iam::xxxxxxxxx:role/pulumi-admin`, // This role has full admin access 
      },
    }

Creating EKS cluster

    this.cluster = new eks.Cluster('eks-test',  {
        name: 'eks-test',
        providerCredentialOpts: {
          roleArn: `arn:aws:iam::xxxxxxxxx:role/pulumi-admin`, // This role has full admin access 
        },
      },
      { provider: awsProvider, parent: this }
    );

This configuration working in @pulumi/eks version "2.7.3"

Output of pulumi about

package version

"@pulumi/aws": "^6.61.0",
"@pulumi/eks": "^3.3.0",
"@pulumi/kubernetes": "^4.18.3",
"@pulumi/pulumi": "^3.142.0",
"@types/node": "^22.10.1",

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@sanketg86 sanketg86 added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Nov 29, 2024
@flostadler
Copy link
Contributor

flostadler commented Dec 2, 2024

Hey @sanketg86, sorry you're running into these issues!

The issue is not related to default providers. Components have two resource options related to providers. One is called provider and that configures the provider for the component itself (e.g. pulumi-eks), the other one is called providers and it configures the underlying providers the component requires (e.g. aws in this case).

Because you disabled default providers you'll need to pass an eks.Provider for the provider option and aws.Provider in the providers option.

The reason it worked before is that pulumi-eks was not implemented as a provider in nodejs until version 3. So there was no need to configure an explicit provider for it. More details about changes in v3 can be found here.

Here's an example of how that could look like for you:

import * as awsx from "@pulumi/awsx";
import * as eks from "@pulumi/eks";
import * as aws from "@pulumi/aws";

const awsProvider = new aws.Provider("aws-provider", {
    region: "us-west-2",
});
const awsxProvider = new awsx.Provider("awsx-provider", {});

const eksVpc = new awsx.ec2.Vpc("eks-vpc", {
    enableDnsHostnames: true,
    cidrBlock: "10.0.0.0/16",
}, { provider: awsxProvider, providers: [awsProvider] });

const eksProvider = new eks.Provider("eks-provider", {});

const eksCluster = new eks.Cluster("eks-cluster", {
    vpcId: eksVpc.vpcId,
    authenticationMode: eks.AuthenticationMode.Api,
    publicSubnetIds: eksVpc.publicSubnetIds,
    privateSubnetIds: eksVpc.privateSubnetIds,
    instanceType: "t3.medium",
    desiredCapacity: 3,
    minSize: 3,
    maxSize: 6,
    nodeAssociatePublicIpAddress: false,
}, { provider: eksProvider, providers: [awsProvider] });

Let me know if this works for you!

@flostadler flostadler added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

2 participants