Module: Formatron::S3::CloudFormationTemplate

Defined in:
lib/formatron/s3/cloud_formation_template.rb

Overview

manage the CloudFormation template stored on S3

Constant Summary collapse

FILE_NAME =
'cloud_formation_template.json'

Class Method Summary collapse

Class Method Details

.deploy(aws:, kms_key:, bucket:, name:, target:, cloud_formation_template:) ⇒ Object

rubocop:disable Metrics/ParameterLists rubocop:disable Metrics/MethodLength



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/formatron/s3/cloud_formation_template.rb', line 12

def self.deploy(
  aws:, kms_key:, bucket:, name:, target:, cloud_formation_template:
)
  key = Path.key(
    name: name,
    target: target,
    sub_key: FILE_NAME
  )
  Formatron::LOG.info do
    "Upload CloudFormation template to #{bucket}/#{key}"
  end
  aws.upload_file(
    kms_key: kms_key,
    bucket: bucket,
    key: key,
    content: cloud_formation_template
  )
end

.destroy(aws:, bucket:, name:, target:) ⇒ Object

rubocop:disable Metrics/MethodLength



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/formatron/s3/cloud_formation_template.rb', line 46

def self.destroy(aws:, bucket:, name:, target:)
  key = Path.key(
    name: name,
    target: target,
    sub_key: FILE_NAME
  )
  Formatron::LOG.info do
    "Delete CloudFormation template from #{bucket}/#{key}"
  end
  aws.delete_file(
    bucket: bucket,
    key: key
  )
end

.exists?(aws:, bucket:, name:, target:) ⇒ Boolean

rubocop:enable Metrics/MethodLength rubocop:enable Metrics/ParameterLists

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
42
43
# File 'lib/formatron/s3/cloud_formation_template.rb', line 33

def self.exists?(aws:, bucket:, name:, target:)
  key = Path.key(
    name: name,
    target: target,
    sub_key: FILE_NAME
  )
  aws.file_exists?(
    bucket: bucket,
    key: key
  )
end

.url(region:, bucket:, name:, target:) ⇒ Object

rubocop:enable Metrics/MethodLength



62
63
64
65
66
67
68
69
70
# File 'lib/formatron/s3/cloud_formation_template.rb', line 62

def self.url(region:, bucket:, name:, target:)
  Path.url(
    region: region,
    bucket: bucket,
    name: name,
    target: target,
    sub_key: FILE_NAME
  )
end