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
  • s

    stocky-spoon-28903

    06/04/2019, 11:16 AM
    how about:
  • s

    stocky-spoon-28903

    06/04/2019, 11:17 AM
    namespaces.map(namespace => {
        // all your code from inside the loop
    })
  • p

    powerful-london-34081

    06/04/2019, 11:23 AM
    @stocky-spoon-28903: similar issue, all service accounts are created, but the email from line 26 is the email from the first service account created
  • p

    powerful-london-34081

    06/04/2019, 11:24 AM
    (iow, the IAMBinding is not created properly)
  • s

    stocky-spoon-28903

    06/04/2019, 11:25 AM
    That is quite strange.
  • s

    stocky-spoon-28903

    06/04/2019, 11:25 AM
    I literally just boarded a flight and the door is about to close, but I am interested in figuring out what is going on here
  • p

    powerful-london-34081

    06/04/2019, 11:26 AM
    me too, I'll be around later if I can help in any way
  • p

    powerful-london-34081

    06/04/2019, 11:26 AM
    have a good flight 🙂
  • s

    stocky-spoon-28903

    06/04/2019, 11:26 AM
    Could you open an issue in
    pulumi-gcp
    with your code? If someone else is online before I land they can pick it up too that way
  • p

    powerful-london-34081

    06/04/2019, 11:26 AM
    sure thing
  • s

    stocky-spoon-28903

    06/04/2019, 11:27 AM
    I assume
    namespaces
    is an array of prompt strings?
  • s

    stocky-spoon-28903

    06/04/2019, 11:28 AM
    (i.e. not a
    pulumi.Output<string[]>
    or similar)?
  • p

    powerful-london-34081

    06/04/2019, 11:29 AM
    yeah it's a json array via config.requireObject()
  • p

    powerful-london-34081

    06/04/2019, 11:30 AM
    correction; it uses the value from the last iteration. Doing a console.log displays the correct output value for each iteration
  • p

    powerful-london-34081

    06/04/2019, 11:51 AM
    @stocky-spoon-28903 https://github.com/pulumi/pulumi-gcp/issues/158
  • t

    tall-librarian-49374

    06/04/2019, 12:08 PM
    @powerful-london-34081 Am I wrong or should there be just one
    IAMBinding
    ?
  • t

    tall-librarian-49374

    06/04/2019, 12:10 PM
    See the code in my comment in the issue
  • s

    stocky-spoon-28903

    06/04/2019, 12:12 PM
    Yes, I think you’re right @powerful-london-34081
  • s

    stocky-spoon-28903

    06/04/2019, 12:12 PM
    Try this, @powerful-london-34081 :
  • s

    stocky-spoon-28903

    06/04/2019, 12:13 PM
    const members = namespaces,map(namespace => {
      const bucket = new gcp.storage.Bucket(`${namespace.name}-tmp-bucket`, {
        lifecycleRules: [
          {
            action: {type: 'Delete'},
            condition: {
              age: 1,
            },
          },
        ],
        forceDestroy: true,
      })
    
      const namespaceSa = new gcp.serviceAccount.Account(`${namespace.name}-sa`, {
        accountId: `${namespace.name}-sa`,
        displayName: `tmp bucket sa for ${namespace.name} namespace`,
        project: gcp.config.project!,
      })
    
      const namespaceSaKey = new gcp.serviceAccount.Key(`${namespace.name}-sa`, {
        serviceAccountId: namespaceSa.name,
      })
    
      return namespaceSa.email;
    });
    
    new gcp.projects.IAMBinding(`${namespace.name}-sa`, {
      project: gcp.config.project!,
      members: members,
      role: 'roles/storage.admin',
    })
  • t

    tall-librarian-49374

    06/04/2019, 12:13 PM
    @stocky-spoon-28903 https://github.com/pulumi/pulumi-gcp/issues/158#issuecomment-498644482 🙂
  • p

    powerful-london-34081

    06/04/2019, 12:14 PM
    is that really a GCP restriction?
  • p

    powerful-london-34081

    06/04/2019, 12:14 PM
    if so, I have missed it completely
  • t

    tall-librarian-49374

    06/04/2019, 12:14 PM
    It kind of makes sense: you give an array of members, so probably one assignment overrides the other
  • t

    tall-librarian-49374

    06/04/2019, 12:15 PM
    The API doesn't stop you from doing so, which isn't that great
  • s

    stocky-spoon-28903

    06/04/2019, 12:15 PM
    Yes - that’s correct. The docs are not particularly clear about it though!
  • s

    stocky-spoon-28903

    06/04/2019, 12:16 PM
    If you try either the code that @tall-librarian-49374 put in the issue (or the basically identical code I just posted above) you should have more luck there.
  • p

    powerful-london-34081

    06/04/2019, 12:16 PM
    damn.. GCPs console UI makes it seem like the bindings are distinct objects that you can manage individually
  • s

    stocky-spoon-28903

    06/04/2019, 12:16 PM
    @tall-librarian-49374’s is better.
  • p

    powerful-london-34081

    06/04/2019, 12:16 PM
    so that means to have code that does not break other stuff in the same project, you have to look up existing bindings and amend them?
Powered by Linen
Title
p

powerful-london-34081

06/04/2019, 12:16 PM
so that means to have code that does not break other stuff in the same project, you have to look up existing bindings and amend them?
View count: 1