Module: Jets::Commands::StackInfo

Includes:
AwsServices
Included in:
Build, Deploy
Defined in:
lib/jets/commands/stack_info.rb

Overview

The important methods in this class are stack_type, s3_bucket and first_run? We use stack_type and s3_bucket to get info for both the build and deploy CLI commands. first_run? will always make an API call.

Instance Method Summary collapse

Methods included from AwsServices

#apigateway, #aws_lambda, #aws_options, #cfn, #dynamodb, #logs, #s3, #s3_resource, #sns, #sqs, #sts

Methods included from AwsServices::StackStatus

#lookup, #stack_exists?, #stack_in_progress?

Methods included from AwsServices::GlobalMemoist

included

Instance Method Details

#first_run?Boolean

Always call API

Returns:

  • (Boolean)


23
24
25
# File 'lib/jets/commands/stack_info.rb', line 23

def first_run?
  !stack_exists?(parent_stack_name)
end

#parent_stack_nameObject



27
28
29
# File 'lib/jets/commands/stack_info.rb', line 27

def parent_stack_name
  Jets::Naming.parent_stack_name
end

#s3_bucketObject



12
13
14
15
16
17
18
19
20
# File 'lib/jets/commands/stack_info.rb', line 12

def s3_bucket
  return @s3_bucket if @s3_bucket
  return nil if first_run?
  return "fake-bucket" if ENV['JETS_BUILD_NO_INTERNET']

  resp = cfn.describe_stacks(stack_name: parent_stack_name)
  output = resp.stacks[0].outputs.find {|o| o.output_key == 'S3Bucket'}
  @s3_bucket = output.output_value # once an s3 bucket is found, cache it
end

#stack_typeObject



8
9
10
# File 'lib/jets/commands/stack_info.rb', line 8

def stack_type
  first_run? ? :minimal : :full
end