Class: Jets::CLI::Concurrency::Set

Inherits:
Get
  • Object
show all
Defined in:
lib/jets/cli/concurrency/set.rb

Direct Known Subclasses

Unset

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Get

#initialize, #provisioned_concurrency, #reserved_concurrency

Methods inherited from Base

#initialize, #paginate, #paging_params, rescue_api_error

Methods included from Util::Logging

#log

Methods included from AwsServices

#apigateway, #aws_options, #cfn, #codebuild, #dynamodb, #lambda_client, #logs, #s3, #s3_resource, #sns, #sqs, #ssm, #sts, #wafv2

Methods included from AwsServices::StackStatus

#output_value, #stack_exists?

Methods included from AwsServices::GlobalMemoist

included, #reset_cache!

Methods included from Api

#api, #api_key

Constructor Details

This class inherits a constructor from Jets::CLI::Concurrency::Get

Instance Method Details

#runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jets/cli/concurrency/set.rb', line 3

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

#set_provisioned_concurrency(value) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/jets/cli/concurrency/set.rb', line 20

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