Sha256: bdea3db80d5b6bd10f819d8821621f622b9be75c1ac14c4dacba17e462e1be9e

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

class Jets::CLI::Concurrency
  class Set < Get
    def run
      sure? "Will update the concurrency settings for #{@lambda_function.name}"
      puts "Updating concurrency settings for #{@lambda_function.name}"

      if @options[:reserved]
        @lambda_function.reserved_concurrency = @options[:reserved]
        puts "Set reserved concurrency to #{@options[:reserved]}"
      end

      if @options[:provisioned]
        success = set_provisioned_concurrency(@options[:provisioned])
        puts "Set provisioned concurrency to #{@options[:provisioned]}" if success
      end

      Jets::CLI::Tip.show(:concurrency_change)
    end

    def set_provisioned_concurrency(value)
      @lambda_function.provisioned_concurrency = value
      true # success
    rescue Aws::Lambda::Errors::ResourceNotFoundException => e
      # Can happen for Events Lambda Lambda Functions where Wersion and Alias resources are only created when specified in config/jets
      # For controller Lambda Function the Alias and Version resource is always created.
      if e.message.include?("Cannot find alias")
        puts "ERROR: The live alias does not exist for the function. Please deploy the function an initial provisioned concurrency first.".color(:red)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jets-6.0.5 lib/jets/cli/concurrency/set.rb
jets-6.0.4 lib/jets/cli/concurrency/set.rb
jets-6.0.3 lib/jets/cli/concurrency/set.rb
jets-6.0.2 lib/jets/cli/concurrency/set.rb