Sha256: 5e9ada298a3c72d5d12f0e8485b188c727963ae54ecca82538392c8b61c133cc

Contents?: true

Size: 1.5 KB

Versions: 15

Compression:

Stored size: 1.5 KB

Contents

module Souls
  module Gcloud
    class << self
      def create_service_account service_account: "souls-app"
        `gcloud iam service-accounts create #{service_account} \
        --description="Souls Service Account" \
        --display-name="#{service_account}"`
      end

      def create_service_account_key service_account: "souls-app"
        project_id = Souls.configuration.project_id
        `gcloud iam service-accounts keys create ./config/keyfile.json \
          --iam-account #{service_account}@#{project_id}.iam.gserviceaccount.com`
      end

      def add_service_account_role service_account: "souls-app", role: "roles/firebase.admin"
        project_id = Souls.configuration.project_id
        `gcloud projects add-iam-policy-binding #{project_id} \
        --member="serviceAccount:#{service_account}@#{project_id}.iam.gserviceaccount.com" \
        --role="#{role}"`
      end

      def add_permissions service_account: "souls-app"
        self.add_service_account_role service_account: service_account, role: "roles/cloudsql.serviceAgent"
        self.add_service_account_role service_account: service_account, role: "roles/containerregistry.ServiceAgent"
        self.add_service_account_role service_account: service_account, role: "roles/pubsub.serviceAgent"
        self.add_service_account_role service_account: service_account, role: "roles/firestore.serviceAgent"
        self.add_service_account_role service_account: service_account, role: "roles/iam.serviceAccountUser"
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
souls-0.23.5 lib/souls/gcloud/iam.rb
souls-0.23.4 lib/souls/gcloud/iam.rb
souls-0.23.3 lib/souls/gcloud/iam.rb
souls-0.23.2 lib/souls/gcloud/iam.rb
souls-0.23.1 lib/souls/gcloud/iam.rb
souls-0.23.0 lib/souls/gcloud/iam.rb
souls-0.22.9 lib/souls/gcloud/iam.rb
souls-0.22.8 lib/souls/gcloud/iam.rb
souls-0.22.7 lib/souls/gcloud/iam.rb
souls-0.22.6 lib/souls/gcloud/iam.rb
souls-0.22.5 lib/souls/gcloud/iam.rb
souls-0.22.4 lib/souls/gcloud/iam.rb
souls-0.22.3 lib/souls/gcloud/iam.rb
souls-0.22.2 lib/souls/gcloud/iam.rb
souls-0.22.1 lib/souls/gcloud/iam.rb