https://pulumi.com logo
Docs
Join the conversationJoin Slack
Channels
announcements
automation-api
aws
azure
blog-posts
built-with-pulumi
cloudengineering
cloudengineering-support
content-share
contribex
contribute
docs
dotnet
finops
general
getting-started
gitlab
golang
google-cloud
hackathon-03-19-2020
hacktoberfest
install
java
jobs
kubernetes
learn-pulumi-events
linen
localstack
multi-language-hackathon
office-hours
oracle-cloud-infrastructure
plugin-framework
pulumi-cdk
pulumi-crosscode
pulumi-deployments
pulumi-kubernetes-operator
pulumi-service
pulumiverse
python
registry
status
testingtesting123
testingtesting321
typescript
welcome
workshops
yaml
Powered by Linen
general
  • w

    worried-painting-67291

    03/13/2020, 11:29 PM
    @fast-dinner-32080 - that almost works.. That works, but then when I attempt to run pulumi up I get
    error: It looks like the Pulumi SDK has not been installed. Have you run npm install or yarn install?
  • f

    fast-dinner-32080

    03/13/2020, 11:30 PM
    Were you able to run pulumi new and then up before and then this is happening when you created another stack in the same project?
  • w

    worried-painting-67291

    03/13/2020, 11:30 PM
    yes.. I think so.
  • w

    worried-painting-67291

    03/13/2020, 11:30 PM
    is there a way to initialize the stack files for a directory when selecting a stack to use?
  • w

    worried-painting-67291

    03/13/2020, 11:31 PM
    e.g. re-create the package.json and friends..
  • w

    worried-painting-67291

    03/13/2020, 11:32 PM
    or maybe I can run
    pulumi new
    to create the directory without (re)creating the stack
  • f

    fast-dinner-32080

    03/13/2020, 11:32 PM
    Well a stack it part of an existing project. You shouldn't need to re-init it. You would create a project, develop against the default stack, then create new stacks (pulumi stack init) using the same index.
  • w

    worried-painting-67291

    03/13/2020, 11:33 PM
    so how are these laid out exactly?
  • w

    worried-painting-67291

    03/13/2020, 11:34 PM
    my aim is to have one root directory for the project, and then subdirectories for
    admin
    dev
    and
    prod
  • w

    worried-painting-67291

    03/13/2020, 11:34 PM
    so the thought was that Pulumi.yaml would go into the project directory..
  • w

    worried-painting-67291

    03/13/2020, 11:34 PM
    and then I could cd into
    admin
    and rnu either
    pulumi stack init
    or
    pulumi stack select
  • w

    worried-painting-67291

    03/13/2020, 11:35 PM
    at least that's how I would assume this should work...
  • w

    worried-painting-67291

    03/13/2020, 11:40 PM
    since pulumi up uses index.ts... I assume that I have to have 1 directory per stack
  • f

    fast-dinner-32080

    03/13/2020, 11:42 PM
    So think of a stack as an isolated environment/context with different configuration with the same underlying program/infra*. If you want different infra without a lot of dynamic then you would want different projects. Basically can have projects/admin, projects/dev, projects/prod and can just have a single stack. Then if they need to reference each other you can using stack references. Now if the infra is similar or you want to have a single program with more dynamic infra you can have a single project with the same program (maybe more if's/loops for dynamic stuff) and the environment is split using stacks (admin, dev, and prod). Then you would select the stack and it would run just for that stacks config. You can still reference each stack as well if necessary from others.
  • w

    worried-painting-67291

    03/13/2020, 11:42 PM
    hmm
  • w

    worried-painting-67291

    03/13/2020, 11:42 PM
    ok... the infra is pretty different between the three environments
  • f

    fast-dinner-32080

    03/13/2020, 11:43 PM
    Then you can probably have different projects for each. Basically a stack can be used to have multiple configurations and state using the same program.
  • w

    worried-painting-67291

    03/13/2020, 11:43 PM
    gotcha..
  • f

    fast-dinner-32080

    03/13/2020, 11:44 PM
    There is no right way to mix projects and stacks. It just depends on the use case. 😄
  • f

    fast-dinner-32080

    03/13/2020, 11:45 PM
    and how you want to organize it
  • w

    worried-painting-67291

    03/13/2020, 11:45 PM
    so I will try to just destroy and re-create the project and then copy my index.ts
  • g

    green-school-95910

    03/13/2020, 11:45 PM
    Multi-tenant deployments are a good example of stacks right @fast-dinner-32080? Same code, with different configs for each tenant
  • f

    fast-dinner-32080

    03/13/2020, 11:47 PM
    Yea that is a good example. Another is if you deploy to multiple regions the same infra.
  • f

    fast-dinner-32080

    03/13/2020, 11:47 PM
    and need to split up the deployments
  • w

    worried-painting-67291

    03/13/2020, 11:48 PM
    I see.. so the
    index.ts
    stays the same, and just the
    Pulumi.stack.yaml
    changes
    f
    • 2
    • 1
  • n

    nutritious-pager-34892

    03/13/2020, 11:48 PM
    @gentle-diamond-70147 Do you have a working version of that typescript example? I tried it and it has type issues because of package scp2 and seems there are more errors too as I tried to remove just that part and still get them.
    g
    • 2
    • 10
  • w

    worried-painting-67291

    03/13/2020, 11:54 PM
    is there a way to debug the Pulumi.config() loading process? I am getting an error with undefined config values and I think it's looking at the wrong file/keys
    w
    • 2
    • 1
  • a

    alert-artist-66265

    03/13/2020, 11:59 PM
    hello, im trying to create a secret with new k8s.core.v1.Secret()... do i need to pass the strings in base64 (as in regular k8s secrets) or just plain strings?
    w
    b
    g
    • 4
    • 5
  • w

    worried-painting-67291

    03/14/2020, 12:06 AM
    thanks all
  • p

    polite-motherboard-78438

    03/14/2020, 6:15 PM
    hello. how can i convert an Ouput<String> to a simple string? I need it in th following example. The "members" array is a []string but the interpolate function always returns an Output<String>.
    const member = pulumi.interpolate`serviceAccount:${serviceAccount.email}`;
    const policyData = gcp.organizations.getIAMPolicy({
      bindings: [
        {
          role: "roles/storage.admin",
          members: [member]
        }
      ]
    });
    f
    • 2
    • 9
Powered by Linen
Title
p

polite-motherboard-78438

03/14/2020, 6:15 PM
hello. how can i convert an Ouput<String> to a simple string? I need it in th following example. The "members" array is a []string but the interpolate function always returns an Output<String>.
const member = pulumi.interpolate`serviceAccount:${serviceAccount.email}`;
const policyData = gcp.organizations.getIAMPolicy({
  bindings: [
    {
      role: "roles/storage.admin",
      members: [member]
    }
  ]
});
f

faint-table-42725

03/14/2020, 8:09 PM
You should be able to wrap the
get
itself within an apply, e.g.
policyData = serviceAccount.email.apply(email =>
    gcp.organizations.getIAMPolicy(...))
(policyData will now be an
Output<GetIAMPolicyResult>
which you can use elsewhere
p

polite-motherboard-78438

03/15/2020, 10:20 AM
cool. it works 👍
well, I need to add another service account from another property. How can I do it with this solution?
const policyData = serviceAccount.email.apply(email =>
  gcp.organizations.getIAMPolicy({
    bindings: [
      {
        role: "roles/storage.admin",
        members: [
          "serviceAccount:" + email,
          "serviceAccount:" + gcpServiceAccount
        ]
      }
    ]
  })
);

const bucketPolicy = new gcp.storage.BucketIAMPolicy("velero", {
  bucket: bucket.id,
  policyData: policyData.policyData
});
f

faint-table-42725

03/15/2020, 4:53 PM
You can use
pulumi.all
— you might want to take a look at https://www.pulumi.com/docs/intro/concepts/programming-model/#outputs if you haven’t already
p

polite-motherboard-78438

03/21/2020, 3:54 PM
I stumbled upon
pulumi.all
in the unit tests documentation today Will try
Not sure if I am using correctly:
const policyData = pulumi
  .all([serviceAccount.email, gcpServiceAccount])
  .apply(([veleroServiceAccount, gcpServiceAccount]) => {
    gcp.organizations.getIAMPolicy({
      bindings: [
        {
          role: "roles/storage.admin",
          members: [
            "serviceAccount:" + veleroServiceAccount,
            "serviceAccount:" + gcpServiceAccount
          ]
        }
      ]
    });
  });
But now policyData is an instance of
pulumi.OutputInstance<void>
and not
Output<GetIAMPolicyResult>
f

faint-table-42725

03/23/2020, 3:12 AM
The compiler sees
=> { … }
as a void function. You should remove that extra set of braces and it should give you back what you want.
p

polite-motherboard-78438

04/18/2020, 10:23 AM
Thanks. it works now
View count: 1