pulumi / pulumi-pulumiservice

https://pulumi.com
Apache License 2.0
13 stars 7 forks source link

Environment: panic #423

Closed jkodroff closed 1 month ago

jkodroff commented 1 month ago

What happened?

Creating an environment with a (possibly invalid) way of creating a string asset throws a panic:

Diagnostics:
  pulumi:pulumi:Stack (esc-ex-02-aws-secrets-setup-dev):
    panic: interface conversion: interface {} is resource.Computed, not string
    goroutine 103 [running]:
    github.com/pulumi/pulumi/sdk/v3/go/common/resource.PropertyValue.StringValue(...)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.131.0/go/common/resource/properties.go:450
    github.com/pulumi/pulumi-pulumiservice/provider/pkg/provider.(*PulumiServiceEnvironmentResource).Check(0x105c5afe8?, 0x140004bede0?)
        /home/runner/work/pulumi-pulumiservice/pulumi-pulumiservice/provider/pkg/provider/environment.go:233 +0x718
    github.com/pulumi/pulumi-pulumiservice/provider/pkg/provider.(*pulumiserviceProvider).Check(0x140004be6c0, {0x1055599c4?, 0x40?}, 0x105a6f6e0?)
        /home/runner/work/pulumi-pulumiservice/pulumi-pulumiservice/provider/pkg/provider/provider.go:217 +0xe4
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Check_Handler.func1({0x105c69f98, 0x1400050e6c0}, {0x105ba9c20?, 0x140004bede0})
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.131.0/proto/go/provider_grpc.pb.go:615 +0x74
    github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x105c69f98, 0x14000323f20}, {0x105ba9c20, 0x140004bede0}, 0x140006a66a0, 0x1400054a810)
        /home/runner/go/pkg/mod/github.com/grpc-ecosystem/grpc-opentracing@v0.0.0-20180507213350-8e809c8a8645/go/otgrpc/server.go:57 +0x2e8
    github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Check_Handler({0x105c0dce0?, 0x140004be6c0}, {0x105c69f98, 0x14000323f20}, 0x140004cce80, 0x140005fa140)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.131.0/proto/go/provider_grpc.pb.go:617 +0x12c
    google.golang.org/grpc.(*Server).processUnaryRPC(0x140004c8000, {0x105c69f98, 0x14000323e90}, {0x105c72de0, 0x140002c6780}, 0x140004ad680, 0x14000323200, 0x10642b988, 0x0)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1369 +0xba0
    google.golang.org/grpc.(*Server).handleStream(0x140004c8000, {0x105c72de0, 0x140002c6780}, 0x140004ad680)
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1780 +0xc80
    google.golang.org/grpc.(*Server).serveStreams.func2.1()
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1019 +0x8c
    created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 101
        /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1030 +0x150

  pulumiservice:index:Environment (aws-secrets):
    error: error reading from server: read tcp 127.0.0.1:49554->127.0.0.1:49551: read: connection reset by peer

Example

This example is not minimal. Apologies - I'm in a time crunch as I write this.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as random from "@pulumi/random";
import * as pcloud from "@pulumi/pulumiservice";

const config = new pulumi.Config();

const gitHubToken = config.requireSecret("githubToken");

const secret = new aws.secretsmanager.Secret("github-token", {
  description: "GitHub token for ESC.",
  recoveryWindowInDays: 0
});

new aws.secretsmanager.SecretVersion("github-token", {
  secretId: secret.id,
  secretString: gitHubToken
});

const envYaml = secret.name.apply(name => `
imports:
  - aws/aws-oidc-admin
values:
  aws:
    secrets:
      fn::open::aws-secrets:
        region: us-west-2
        login: \${aws.login}
        get:
          github-token:
            secretId: ${name}
  pulumiConfig:
    githubToken: \${aws.secrets.github-token-name}
`);

// NOTE: This can be removed once environments have autonaming:
const suffix = new random.RandomString("env-name-suffix", {
  length: 6
});

const org = pulumi.getOrganization();

const env = new pcloud.Environment("aws-secrets", {
  organization: org,
  project: "foundational-training",
  name: pulumi.interpolate`aws-secrets-${suffix.result}`,
  yaml: envYaml.apply(yaml => new pulumi.asset.StringAsset(yaml))
});

export const envName = env.name;

Output of pulumi about

CLI          
Version      3.135.1
Go Version   go1.23.2
Go Compiler  gc

Plugins
KIND      NAME           VERSION
resource  aws            6.54.2
language  nodejs         3.135.1-dev.0
resource  pulumiservice  0.26.2
resource  random         4.16.6

Host     
OS       darwin
Version  14.6.1
Arch     arm64

This project is written in nodejs: executable='/opt/homebrew/bin/node' version='v22.5.1'

Current Stack: jkodrofftest/esc-ex-02-aws-secrets-setup/dev

TYPE                                            URN
pulumi:pulumi:Stack                             urn:pulumi:dev::esc-ex-02-aws-secrets-setup::pulumi:pulumi:Stack::esc-ex-02-aws-secrets-setup-dev
pulumi:providers:aws                            urn:pulumi:dev::esc-ex-02-aws-secrets-setup::pulumi:providers:aws::default_6_54_2
aws:secretsmanager/secret:Secret                urn:pulumi:dev::esc-ex-02-aws-secrets-setup::aws:secretsmanager/secret:Secret::github-token
aws:secretsmanager/secretVersion:SecretVersion  urn:pulumi:dev::esc-ex-02-aws-secrets-setup::aws:secretsmanager/secretVersion:SecretVersion::github-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, jkodrofftest, aws-partnership, zephyr, jkodroff-team, pulumi
Token type     personal

Dependencies:
NAME                   VERSION
@pulumi/pulumi         3.135.1
@pulumi/pulumiservice  0.26.2
@pulumi/random         4.16.6
@types/node            18.19.54
typescript             5.6.2
@pulumi/aws            6.54.2

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 commented 1 month ago

There's a good chance this is fixed in #421, but is not yet in the latest released version. I can work around it for now.