Class: Formatron::CloudFormation::Template
- Inherits:
-
Object
- Object
- Formatron::CloudFormation::Template
- Defined in:
- lib/formatron/cloud_formation/template.rb,
lib/formatron/cloud_formation/template/vpc.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/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
generates a CloudFormation template
Defined Under Namespace
Classes: Parameters, VPC
Constant Summary collapse
- REGION_MAP =
'regionMap'
Class Method Summary collapse
- .base_64(value) ⇒ Object
- .find_in_map(map, key, property) ⇒ Object
- .get_attribute(resource, attribute) ⇒ Object
- .join(*items) ⇒ Object
- .output(value) ⇒ Object
-
.ref(logical_id) ⇒ Object
rubocop:enable Metrics/MethodLength.
Instance Method Summary collapse
-
#hash ⇒ Object
rubocop:disable Metrics/MethodLength.
-
#initialize(formatron:, external:, hosted_zone_name:, key_pair:, administrator_name:, administrator_password:, kms_key:, hosted_zone_id:, target:) ⇒ Template
constructor
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/ParameterLists.
Constructor Details
#initialize(formatron:, external:, hosted_zone_name:, key_pair:, administrator_name:, administrator_password:, kms_key:, hosted_zone_id:, target:) ⇒ Template
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/ParameterLists
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/formatron/cloud_formation/template.rb', line 13 def initialize( formatron:, external:, hosted_zone_name:, key_pair:, administrator_name:, administrator_password:, kms_key:, hosted_zone_id:, target: ) @formatron = formatron @external = external @external_formatron = external.formatron @external_outputs = external.outputs @hosted_zone_name = hosted_zone_name @key_pair = key_pair @administrator_name = administrator_name @administrator_password = administrator_password @kms_key = kms_key @hosted_zone_id = hosted_zone_id @bucket = formatron.bucket @name = formatron.name @target = target end |
Class Method Details
.base_64(value) ⇒ Object
101 102 103 104 105 |
# File 'lib/formatron/cloud_formation/template.rb', line 101 def self.base_64(value) { 'Fn::Base64' => value } end |
.find_in_map(map, key, property) ⇒ Object
91 92 93 94 95 96 97 98 99 |
# File 'lib/formatron/cloud_formation/template.rb', line 91 def self.find_in_map(map, key, property) { 'Fn::FindInMap' => [ map, key, property ] } end |
.get_attribute(resource, attribute) ⇒ Object
107 108 109 110 111 |
# File 'lib/formatron/cloud_formation/template.rb', line 107 def self.get_attribute(resource, attribute) { 'Fn::GetAtt' => [resource, attribute] } end |
.join(*items) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/formatron/cloud_formation/template.rb', line 83 def self.join(*items) { 'Fn::Join' => [ '', items ] } end |
.output(value) ⇒ Object
113 114 115 116 117 |
# File 'lib/formatron/cloud_formation/template.rb', line 113 def self.output(value) { Value: value } end |
.ref(logical_id) ⇒ Object
rubocop:enable Metrics/MethodLength
77 78 79 80 81 |
# File 'lib/formatron/cloud_formation/template.rb', line 77 def self.ref(logical_id) { Ref: logical_id } end |
Instance Method Details
#hash ⇒ Object
rubocop:disable Metrics/MethodLength
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/formatron/cloud_formation/template.rb', line 42 def hash resources = {} outputs = {} parameters = {} @formatron.vpc.each do |key, vpc| template_vpc = VPC.new( vpc: vpc, external: @external_formatron.vpc[key], hosted_zone_name: @hosted_zone_name, key_pair: @key_pair, administrator_name: @administrator_name, administrator_password: @administrator_password, kms_key: @kms_key, hosted_zone_id: @hosted_zone_id, bucket: @bucket, name: @name, target: @target ) template_vpc.merge resources: resources, outputs: outputs end template_parameters = Parameters.new keys: @external_outputs.hash.keys template_parameters.merge parameters: parameters { AWSTemplateFormatVersion: '2010-09-09', Description: "Formatron stack: #{@formatron.name}", Mappings: { REGION_MAP => AWS::REGIONS }, Parameters: parameters, Resources: resources, Outputs: outputs } end |