Sha256: 00c114caa005862a7c75ed3817cc9ca6065b2890531ae7ae7dc2842dd83c2c65

Contents?: true

Size: 1.35 KB

Versions: 25

Compression:

Stored size: 1.35 KB

Contents

module Souls
  module Gcloud
    class << self
      def create_service_account(service_account: "souls-app")
        system(
          "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-app")
        system(
          "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", project_id: "souls-app", role: "roles/firebase.admin")
        system(
          "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")
        roles = [
          "roles/cloudsql.serviceAgent",
          "roles/containerregistry.ServiceAgent",
          "roles/pubsub.serviceAgent",
          "roles/firestore.serviceAgent",
          "roles/iam.serviceAccountUser"
        ]
        roles.each do |role|
          add_service_account_role(service_account: service_account, role: role)
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
souls-0.26.10 lib/souls/gcloud/iam.rb
souls-0.26.9 lib/souls/gcloud/iam.rb
souls-0.26.8 lib/souls/gcloud/iam.rb
souls-0.26.7 lib/souls/gcloud/iam.rb
souls-0.26.6 lib/souls/gcloud/iam.rb
souls-0.26.5 lib/souls/gcloud/iam.rb
souls-0.26.4 lib/souls/gcloud/iam.rb
souls-0.26.3 lib/souls/gcloud/iam.rb
souls-0.26.2 lib/souls/gcloud/iam.rb
souls-0.26.1 lib/souls/gcloud/iam.rb
souls-0.26.0 lib/souls/gcloud/iam.rb
souls-0.25.21 lib/souls/gcloud/iam.rb
souls-0.25.20 lib/souls/gcloud/iam.rb
souls-0.25.19 lib/souls/gcloud/iam.rb
souls-0.25.18 lib/souls/gcloud/iam.rb
souls-0.25.17 lib/souls/gcloud/iam.rb
souls-0.25.16 lib/souls/gcloud/iam.rb
souls-0.25.15 lib/souls/gcloud/iam.rb
souls-0.25.14 lib/souls/gcloud/iam.rb
souls-0.25.13 lib/souls/gcloud/iam.rb