https://pulumi.com logo
#general
Title
# general
s

stocky-spoon-28903

06/04/2019, 12:13 PM
Copy code
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',
})