Module: Formatron::CloudFormation

Defined in:
lib/formatron/cloud_formation.rb,
lib/formatron/cloud_formation/scripts.rb,
lib/formatron/cloud_formation/template.rb,
lib/formatron/cloud_formation/template/vpc.rb,
lib/formatron/cloud_formation/resources/ec2.rb,
lib/formatron/cloud_formation/resources/iam.rb,
lib/formatron/cloud_formation/resources/route53.rb,
lib/formatron/cloud_formation/template/parameters.rb,
lib/formatron/cloud_formation/template/vpc/subnet.rb,
lib/formatron/cloud_formation/template/vpc/subnet/acl.rb,
lib/formatron/cloud_formation/template/vpc/subnet/nat.rb,
lib/formatron/cloud_formation/resources/cloud_formation.rb,
lib/formatron/cloud_formation/template/vpc/subnet/bastion.rb,
lib/formatron/cloud_formation/template/vpc/subnet/instance.rb,
lib/formatron/cloud_formation/template/vpc/subnet/chef_server.rb,
lib/formatron/cloud_formation/template/vpc/subnet/instance/setup.rb,
lib/formatron/cloud_formation/template/vpc/subnet/instance/policy.rb,
lib/formatron/cloud_formation/template/vpc/subnet/instance/block_devices.rb,
lib/formatron/cloud_formation/template/vpc/subnet/instance/security_group.rb

Overview

manage the CloudFormation stack

Defined Under Namespace

Modules: Resources, Scripts Classes: Template

Class Method Summary collapse

Class Method Details

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

rubocop:disable Metrics/MethodLength



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/formatron/cloud_formation.rb', line 8

def self.deploy(aws:, bucket:, name:, target:, parameters:)
  stack_name = _stack_name name, target
  Formatron::LOG.info do
    "Deploy CloudFormation stack: #{stack_name}"
  end
  aws.deploy_stack(
    stack_name: stack_name,
    template_url: S3::CloudFormationTemplate.url(
      region: aws.region,
      bucket: bucket,
      name: name,
      target: target
    ),
    parameters: parameters
  )
end

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

rubocop:enable Metrics/MethodLength



26
27
28
29
30
31
32
# File 'lib/formatron/cloud_formation.rb', line 26

def self.destroy(aws:, name:, target:)
  stack_name = _stack_name name, target
  Formatron::LOG.info do
    "Destroy CloudFormation stack: #{stack_name}"
  end
  aws.delete_stack stack_name: stack_name
end

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

rubocop:disable Metrics/MethodLength



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/formatron/cloud_formation.rb', line 35

def self.outputs(aws:, bucket:, name:, target:)
  if S3::CloudFormationTemplate.exists?(
    aws: aws,
    bucket: bucket,
    name: name,
    target: target
  )
    stack_name = _stack_name name, target
    Formatron::LOG.info do
      "Query CloudFormation stack outputs: #{stack_name}"
    end
    aws.stack_outputs stack_name: stack_name
  else
    {}
  end
end

.stack_ready!(aws:, name:, target:) ⇒ Object

rubocop:enable Metrics/MethodLength



53
54
55
# File 'lib/formatron/cloud_formation.rb', line 53

def self.stack_ready!(aws:, name:, target:)
  aws.stack_ready! stack_name: _stack_name(name, target)
end