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

Can't import ActionsRepositoryAccessLevel object #642

Open
pylaligand opened this issue Apr 19, 2024 · 4 comments
Open

Can't import ActionsRepositoryAccessLevel object #642

pylaligand opened this issue Apr 19, 2024 · 4 comments
Labels
area/import An issue related to `pulumi import` or the import resource option. kind/bug Some behavior is incorrect or out of spec

Comments

@pylaligand
Copy link

What happened?

I am trying to import ActionsRepositoryAccessLevel resources for some already existing repositories. Even if the access level matches what's currently in GitHub, imports will fail because of a repository attribute that's allegedly missing from the "remote" state.

Example

  1. Create a new repository.
  2. Add a new resource:
github.ActionsRepositoryAccessLevel(
    f"actions-access-{repo_name}",
    repository=repo_name,
    access_level="none",
)
  1. Run a preview:
$ pulumi preview
Previewing update (<my org>/<my project>)

View in Browser (Ctrl+O): https://app.pulumi.com/<my org>/<my project>/<my stack>/previews/<some long id>

    Type                                          Name                                    Plan       Info
     pulumi:pulumi:Stack                           <stack name>                    
 =   ├─ github:index:ActionsRepositoryAccessLevel  actions-access-<repo name>          import     [diff: +repository]; 1 warning

Diagnostics:
  github:index:ActionsRepositoryAccessLevel (actions-access-<repo name>):
    warning: inputs to import do not match the existing resource; importing this resource will fail
  1. Observe in the "Diff" section of the update:
= github:index/actionsRepositoryAccessLevel:ActionsRepositoryAccessLevel: (import)
        [id=<repo name>]
        [urn=urn:pulumi:github-repos::github-repo-config::github:index/actionsRepositoryAccessLevel:ActionsRepositoryAccessLevel::actions-access-<repo name>]
        [provider=urn:pulumi:github-repos::github-repo-config::pulumi:providers:github::default_5_26_0::f836b71c-df2d-4455-860c-893fa312f3c1]
      + repository: "<repo name>"

Output of pulumi about

$ pulumi about
CLI          
Version      3.112.0
Go Version   go1.22.1
Go Compiler  gc

Plugins
NAME    VERSION
github  5.26.0
python  unknown

Host     
OS       ubuntu
Version  22.04
Arch     x86_64

This project is written in python: executable='/workspaces/.github-private/github-repo-config/venv/bin/python3' version='3.9.19'

<some details about my stack>

Found no pending operations associated with flexai/github-repos

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/pylaligand-flexai
User           pylaligand-flexai
Organizations  pylaligand-flexai, flexai
Token type     personal

Dependencies:
NAME           VERSION
cryptography   42.0.5
pip            24.0
pulumi_github  5.26.0
pulumi-policy  1.10.0
PyGithub       2.3.0
setuptools     69.2.0
wheel          0.43.0

Pulumi locates its logs in /tmp by default

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

@pylaligand pylaligand added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Apr 19, 2024
@iwahbe iwahbe added area/import An issue related to `pulumi import` or the import resource option. and removed needs-triage Needs attention from the triage team labels Apr 22, 2024
@iwahbe
Copy link
Member

iwahbe commented Apr 22, 2024

Hey @pylaligand. Thanks for reporting this issue. It looks like this bug is from a combination of two behaviors:

  1. A bug in the upstream provider: [FEAT]: github_actions_repository_access_level should set repository value integrations/terraform-provider-github#1599
  2. That Pulumi has stricter correctness requirements than terraform.

We will take a look at getting this working for you as soon as we have the time.

@mikhailshilkov
Copy link
Member

@pylaligand As a workaround, you should be able to import this resource with a pulumi import command.

@t0yv0
Copy link
Member

t0yv0 commented Jun 13, 2024

I can reproduce the original issue as stated. Unfortunately that workaround does not work smoothly either, we might need to take further action to fix this.

PULUMI_DEBUG_GRPC=$PWD/import.json pulumi import github:index/actionsRepositoryAccessLevel:ActionsRepositoryAccessLevel test41 t0yv0-nixos

Results in:

Previewing import (dev)

View in Browser (Ctrl+O): https://app.pulumi.com/anton-pulumi-corp/github-642/dev/previews/ef81aeb2-c306-49b8-a364-8cd98072d6db

     Type                                          Name            Plan       Info
     pulumi:pulumi:Stack                           github-642-dev             
 =   └─ github:index:ActionsRepositoryAccessLevel  test41          import     2 warnings

Diagnostics:
  github:index:ActionsRepositoryAccessLevel (test41):
    warning: One or more imported inputs failed to validate. This is almost certainly a bug in the `github` provider. The import will still proceed, but you will need to edit the generated code after copying it into your program.
    warning: github:index/actionsRepositoryAccessLevel:ActionsRepositoryAccessLevel resource 'test41' has a problem: Missing required argument. The argument "repository" is required, but no definition was found.. Examine values at 'test41.repository'.

Resources:
    = 1 to import
    2 unchanged

The read method is not populating the required field:

{
  "method": "/pulumirpc.ResourceProvider/Read",
  "request": {
    "id": "t0yv0-nixos",
    "urn": "urn:pulumi:dev::github-642::github:index/actionsRepositoryAccessLevel:ActionsRepositoryAccessLevel::test41",
    "properties": {}
  },
  "response": {
    "id": "t0yv0-nixos",
    "properties": {
      "accessLevel": "none",
      "id": "t0yv0-nixos"
    },
    "inputs": {
      "__defaults": [],
      "accessLevel": "none"
    }
  },
  "metadata": {
    "kind": "resource",
    "mode": "client",
    "name": "github"
  }
}

You can ignore the warning and proceed, generating:

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 test41 = new github.ActionsRepositoryAccessLevel("test41", {
    accessLevel: "none",
    repository: "",
}, {
    protect: true,
});

But then need to edit repository to the desired repository.

@t0yv0
Copy link
Member

t0yv0 commented Jun 13, 2024

Version      3.117.0
Go Version   go1.22.3
Go Compiler  gc

Plugins
KIND      NAME    VERSION
resource  github  6.2.1
language  nodejs  unknown

Host     
OS       darwin
Version  14.5
Arch     arm64

This project is written in nodejs: executable='/Users/anton/bin/node' version='v18.18.2'

Current Stack: anton-pulumi-corp/github-642/dev

TYPE                                                                    URN
pulumi:pulumi:Stack                                                     urn:pulumi:dev::github-642::pulumi:pulumi:Stack::github-642-dev
pulumi:providers:github                                                 urn:pulumi:dev::github-642::pulumi:providers:github::default_6_2_1
github:index/repository:Repository                                      urn:pulumi:dev::github-642::github:index/repository:Repository::r
github:index/actionsRepositoryAccessLevel:ActionsRepositoryAccessLevel  urn:pulumi:dev::github-642::github:index/actionsRepositoryAccessLevel:ActionsRepositoryAccessLevel::test41


Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/anton-pulumi-corp
User           anton-pulumi-corp
Organizations  anton-pulumi-corp, moolumi, pulumi
Token type     personal

Dependencies:
NAME            VERSION
@pulumi/github  6.2.1
@pulumi/pulumi  3.120.0
@types/node     18.19.34
typescript      5.4.5

Pulumi locates its logs in /var/folders/gd/3ncjb1lj5ljgk8xl5ssn_gvc0000gn/T/com.apple.shortcuts.mac-helper// by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/import An issue related to `pulumi import` or the import resource option. kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

4 participants