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



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

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

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

rubocop:enable Metrics/MethodLength



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

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