pulumi / pulumi-github

A Pulumi package to facilitate interacting with GitHub
Apache License 2.0
56 stars 10 forks source link

Running `pulumi import` for github team members misses out the `role` key for members. #690

Open seaerchin opened 2 weeks ago

seaerchin commented 2 weeks ago

What happened?

import of existing github team members causes the role key to be omitted for members of the github team. this leads to erroneous code output for the import command, where the code snippet to be placed in code omits the role key.

Example

  1. first, create a github team outside of pulumi.
  2. next, add team members into said team with role: member.
  3. lastly, run pulumi import github:index/teamMembers:TeamMembers <team name> <team_id>

Sample output attached below

Please copy the following code into your Pulumi application. Not doing so
will cause Pulumi to report that an update will happen on the next update command.

Please note that the imported resources are marked as protected. To destroy them
you will need to remove the `protect` option and run `pulumi update` *before*
the destroy will take effect.

import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";

const core_team_members = new github.TeamMembers("core-team-members", {
    members: [
        {
            username: "xyz",
        },
        {
            username: "abc",
        }
    ],
    teamId: "123",
}, {
    protect: true,
});

Output of pulumi about

CLI
Version      3.105.0
Go Version   go1.21.6
Go Compiler  gc

Plugins
NAME    VERSION
nodejs  unknown

Host
OS       darwin
Version  13.5
Arch     arm64

This project is written in nodejs: executable='/usr/local/bin/node' version='v20.5.1'

Additional context

the output should have role: member, as the updated pulumi state has that set. this causes the next pulumi up with the output above to delete and recreate the team member resource.

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).

tgummerer commented 2 weeks ago

Thanks for reporting this. I believe this is an issue with the GitHub provider. I'll move the issue over to that repo.

iwahbe commented 2 weeks ago

Hi @seaerchin. Thanks for reporting this problem. I'll take a look at reproducing the issue and get back to you. As a work-around, have you tried manually adding role: "member" to each membership?

seaerchin commented 2 weeks ago

Yeap @iwahbe, I examined pulumi's internal state and realised it got imported with member. Updated the code and it fixed the issue

iwahbe commented 2 weeks ago

Hey @seaerchin. I'm glad you have a work-around.

iwahbe commented 2 weeks ago

Hey @seaerchin, what version of pulumi-github are you using? I just tried to repo on pulumi-github@v6.2.1, with pulumi at v3.119.0 and the output I got was:

import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";

const some_team = new github.TeamMembers("some_team", {
    members: [
        {
            role: "member",
            username: "PulumiTestUser02",
        },
        {
            role: "maintainer",
            username: "PulumiTestUser01",
        },
    ],
    teamId: "123",
}, {
    protect: true,
});

Copying the code into my program works works as expected: pulumi preview shows no changes.