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

pulumicloud.OrgAccessToken.value output is not required #187

Closed
jkodroff opened this issue Nov 5, 2023 · 0 comments · Fixed by #190
Closed

pulumicloud.OrgAccessToken.value output is not required #187

jkodroff opened this issue Nov 5, 2023 · 0 comments · Fixed by #190
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Milestone

Comments

@jkodroff
Copy link
Member

jkodroff commented Nov 5, 2023

What happened?

The value of pulumicloud.OrgAccessToken.value can be undefined, probably because it is not marked as required in the schema. Therefore, this code does not work:

const pulumiOrg = config.get("pulumiOrg") ?? pulumi.getOrganization();
const pulumiOrgToken = new pulumicloud.OrgAccessToken("pulumi-org-token", {
  name: "GitLab CI/CD",
  organizationName: pulumiOrg,
  admin: false,
});

new gitlab.ProjectVariable("pulumi-access-token", {
  project: project.id,
  key: "PULUMI_ACCESS_TOKEN",
  value: pulumiOrgToken.value,
  masked: true,
});

And I get this error:

Type 'Output<string | undefined>' is not assignable to type 'Input<string>'.
  Type 'OutputInstance<string | undefined>' is not assignable to type 'Input<string>'.
    Type 'OutputInstance<string | undefined>' is not assignable to type 'OutputInstance<string>'.
      Type 'string | undefined' is not assignable to type 'string'.
        Type 'undefined' is not assignable to type 'string'.ts(2322)

Code like the following works as a workaround:

const pulumiOrg = config.get("pulumiOrg") ?? pulumi.getOrganization();
const pulumiOrgToken = new pulumicloud.OrgAccessToken("pulumi-org-token", {
  name: "GitLab CI/CD",
  organizationName: pulumiOrg,
  admin: false,
});

pulumiOrgToken.value.apply(x => {
  new gitlab.ProjectVariable("pulumi-access-token", {
    project: project.id,
    key: "PULUMI_ACCESS_TOKEN",
    value: x!,
    masked: true,
  });
});

Example

n/a

Output of pulumi about

CLI          
Version      3.92.0
Go Version   go1.21.3
Go Compiler  gc

Plugins
NAME           VERSION
aws            6.6.1
gitlab         6.4.0
nodejs         unknown
pulumiservice  0.14.0

Host     
OS       darwin
Version  14.0
Arch     arm64

This project is written in nodejs: executable='/Users/jkodroff/.nvm/versions/node/v20.8.0/bin/node' version='v20.8.0'

Current Stack: jkodrofftest/pulumi-cloud-gitlab-integration/dev

TYPE                                                 URN
pulumi:pulumi:Stack                                  urn:pulumi:dev::pulumi-cloud-gitlab-integration::pulumi:pulumi:Stack::pulumi-cloud-gitlab-integration-dev
pulumi:providers:gitlab                              urn:pulumi:dev::pulumi-cloud-gitlab-integration::pulumi:providers:gitlab::default_6_4_0
pulumi:providers:aws                                 urn:pulumi:dev::pulumi-cloud-gitlab-integration::pulumi:providers:aws::default_6_6_1
aws:iam/openIdConnectProvider:OpenIdConnectProvider  urn:pulumi:dev::pulumi-cloud-gitlab-integration::aws:iam/openIdConnectProvider:OpenIdConnectProvider::gitlab-oidc-provider
pulumi:providers:pulumiservice                       urn:pulumi:dev::pulumi-cloud-gitlab-integration::pulumi:providers:pulumiservice::default_0_14_0
gitlab:index/project:Project                         urn:pulumi:dev::pulumi-cloud-gitlab-integration::gitlab:index/project:Project::pulumi-gitlab-demo
gitlab:index/projectVariable:ProjectVariable         urn:pulumi:dev::pulumi-cloud-gitlab-integration::gitlab:index/projectVariable:ProjectVariable::pulumi-org
gitlab:index/repositoryFile:RepositoryFile           urn:pulumi:dev::pulumi-cloud-gitlab-integration::gitlab:index/repositoryFile:RepositoryFile::scripts/pulumi-up.sh
pulumiservice:index:OrgAccessToken                   urn:pulumi:dev::pulumi-cloud-gitlab-integration::pulumiservice:index:OrgAccessToken::pulumi-org-token
gitlab:index/repositoryFile:RepositoryFile           urn:pulumi:dev::pulumi-cloud-gitlab-integration::gitlab:index/repositoryFile:RepositoryFile::scripts/aws-auth.sh
gitlab:index/repositoryFile:RepositoryFile           urn:pulumi:dev::pulumi-cloud-gitlab-integration::gitlab:index/repositoryFile:RepositoryFile::scripts/pulumi-preview.sh
gitlab:index/repositoryFile:RepositoryFile           urn:pulumi:dev::pulumi-cloud-gitlab-integration::gitlab:index/repositoryFile:RepositoryFile::.gitlab-ci.yml
gitlab:index/repositoryFile:RepositoryFile           urn:pulumi:dev::pulumi-cloud-gitlab-integration::gitlab:index/repositoryFile:RepositoryFile::scripts/setup.sh
aws:iam/role:Role                                    urn:pulumi:dev::pulumi-cloud-gitlab-integration::aws:iam/role:Role::gitlabAdminRole
gitlab:index/projectHook:ProjectHook                 urn:pulumi:dev::pulumi-cloud-gitlab-integration::gitlab:index/projectHook:ProjectHook::project-hook
gitlab:index/projectVariable:ProjectVariable         urn:pulumi:dev::pulumi-cloud-gitlab-integration::gitlab:index/projectVariable:ProjectVariable::role-arn
aws:iam/rolePolicyAttachment:RolePolicyAttachment    urn:pulumi:dev::pulumi-cloud-gitlab-integration::aws:iam/rolePolicyAttachment:RolePolicyAttachment::gitlabAdminRolePolicy
gitlab:index/projectVariable:ProjectVariable         urn:pulumi:dev::pulumi-cloud-gitlab-integration::gitlab:index/projectVariable:ProjectVariable::pulumi-access-token


Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/josh-pulumi-corp
User           josh-pulumi-corp
Organizations  josh-pulumi-corp, jkodroff-gitlab-demo, jkodrofftest, zephyr, pulumi
Token type     personal

Dependencies:
NAME                   VERSION
@pulumi/aws            6.6.1
@pulumi/gitlab         6.4.0
@pulumi/pulumi         3.91.0
@pulumi/pulumiservice  0.14.0
@types/node            16.18.59

Pulumi locates its logs in /var/folders/5m/4n1x3f8151s35wc80w06z5k80000gn/T/ 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).

@jkodroff jkodroff added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Nov 5, 2023
@komalali komalali removed the needs-triage Needs attention from the triage team label Nov 16, 2023
@komalali komalali self-assigned this Nov 16, 2023
komalali added a commit that referenced this issue Nov 16, 2023
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Nov 16, 2023
@cleverguy25 cleverguy25 added this to the 0.96 milestone Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants