Module: Enscalator::Core::CfParameters
- Included in:
- RichTemplateDSL
- Defined in:
- lib/enscalator/core/cf_parameters.rb
Overview
Parameters for cloudformation template dsl
Instance Method Summary collapse
-
#parameter_allocated_storage(instance_name, default: 5, min: 5, max: 1024) ⇒ Object
Allocated storage parameter.
-
#parameter_ami(name, ami_id) ⇒ String
Ami image parameter.
-
#parameter_ec2_instance_type(instance_name, type: InstanceType.ec2_instance_type.current_generation[:general_purpose].first) ⇒ Object
EC2 Instance type parameter.
-
#parameter_instance_type(instance_name, type, allowed_values: []) ⇒ Object
Instance type parameter.
-
#parameter_key_name(instance_name) ⇒ Object
Key name parameter.
-
#parameter_name(instance_name, default: nil, min_length: 1, max_length: 64) ⇒ Object
Name parameter.
-
#parameter_password(instance_name, default: 'password', min_length: 8, max_length: 41) ⇒ Object
Password parameter.
-
#parameter_rds_instance_type(instance_name, type: InstanceType.rds_instance_type.current_generation[:general_purpose].first) ⇒ Object
RDS Instance type parameter.
-
#parameter_username(instance_name, default: 'root', min_length: 1, max_length: 16) ⇒ Object
Username parameter.
Instance Method Details
#parameter_allocated_storage(instance_name, default: 5, min: 5, max: 1024) ⇒ Object
Allocated storage parameter
77 78 79 80 81 82 83 84 85 |
# File 'lib/enscalator/core/cf_parameters.rb', line 77 def parameter_allocated_storage(instance_name, default: 5, min: 5, max: 1024) parameter "#{instance_name}AllocatedStorage", Default: default.to_s, Description: "The size of the #{instance_name} (Gb)", Type: 'Number', MinValue: min.to_s, MaxValue: max.to_s, ConstraintDescription: "must be between #{min} and #{max}Gb." end |
#parameter_ami(name, ami_id) ⇒ String
Ami image parameter
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/enscalator/core/cf_parameters.rb', line 92 def parameter_ami(name, ami_id) parameter_name = "#{name}AMIId" parameter parameter_name, Default: ami_id, Description: "The #{name} AMI id", Type: 'String', AllowedPattern: 'ami-[a-zA-Z0-9]*', ConstraintDescription: 'must be valid AMI id (ami-*).' parameter_name end |
#parameter_ec2_instance_type(instance_name, type: InstanceType.ec2_instance_type.current_generation[:general_purpose].first) ⇒ Object
EC2 Instance type parameter
127 128 129 130 131 132 |
# File 'lib/enscalator/core/cf_parameters.rb', line 127 def parameter_ec2_instance_type(instance_name, type: InstanceType.ec2_instance_type.current_generation[:general_purpose].first) fail("Not supported instance type: #{type}") unless InstanceType.ec2_instance_type.supported?(type) warn("Using obsolete instance type: #{type}") if InstanceType.ec2_instance_type.obsolete?(type) parameter_instance_type(instance_name, type, allowed_values: InstanceType.ec2_instance_type.allowed_values(type)) end |
#parameter_instance_type(instance_name, type, allowed_values: []) ⇒ Object
Instance type parameter
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/enscalator/core/cf_parameters.rb', line 108 def parameter_instance_type(instance_name, type, allowed_values: []) # check if given type is included in allowed_values and fails if none matched unless allowed_values.any? { |v| v == type } fail("Instance type \"#{type}\" is not in allowed values: #{allowed_values.join(' ')}") end name = "#{instance_name}InstanceType" parameter name, Default: type, Description: "The #{instance_name} instance type", Type: 'String', AllowedValues: allowed_values, ConstraintDescription: 'must be valid EC2 instance type.' name end |
#parameter_key_name(instance_name) ⇒ Object
Key name parameter
8 9 10 11 12 13 14 15 16 |
# File 'lib/enscalator/core/cf_parameters.rb', line 8 def parameter_key_name(instance_name) parameter "#{instance_name}KeyName", Description: "Name of the #{instance_name} ssh key pair", Type: 'String', MinLength: '1', MaxLength: '64', AllowedPattern: '[a-zA-Z][-_a-zA-Z0-9]*', ConstraintDescription: 'can contain only alphanumeric characters, dashes and underscores.' end |
#parameter_name(instance_name, default: nil, min_length: 1, max_length: 64) ⇒ Object
Name parameter
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/enscalator/core/cf_parameters.rb', line 24 def parameter_name(instance_name, default: nil, min_length: 1, max_length: 64) parameter "#{instance_name}Name", Default: default ? default.to_s : "#{instance_name}", Description: "#{instance_name} name", Type: 'String', MinLength: min_length, MaxLength: max_length, AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*', ConstraintDescription: 'must begin with a letter and contain only alphanumeric characters.' end |
#parameter_password(instance_name, default: 'password', min_length: 8, max_length: 41) ⇒ Object
Password parameter
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/enscalator/core/cf_parameters.rb', line 59 def parameter_password(instance_name, default: 'password', min_length: 8, max_length: 41) parameter "#{instance_name}Password", Default: default, NoEcho: 'true', Description: "Password for #{instance_name} access", Type: 'String', MinLength: min_length, MaxLength: max_length, AllowedPattern: '[a-zA-Z0-9]*', ConstraintDescription: 'must contain only alphanumeric characters.' end |
#parameter_rds_instance_type(instance_name, type: InstanceType.rds_instance_type.current_generation[:general_purpose].first) ⇒ Object
RDS Instance type parameter
138 139 140 141 142 143 |
# File 'lib/enscalator/core/cf_parameters.rb', line 138 def parameter_rds_instance_type(instance_name, type: InstanceType.rds_instance_type.current_generation[:general_purpose].first) fail("Not supported instance type: #{type}") unless InstanceType.rds_instance_type.supported?(type) warn("Using obsolete instance type: #{type}") if InstanceType.rds_instance_type.obsolete?(type) parameter_instance_type(instance_name, type, allowed_values: InstanceType.rds_instance_type.allowed_values(type)) end |
#parameter_username(instance_name, default: 'root', min_length: 1, max_length: 16) ⇒ Object
Username parameter
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/enscalator/core/cf_parameters.rb', line 41 def parameter_username(instance_name, default: 'root', min_length: 1, max_length: 16) parameter "#{instance_name}Username", Default: default, NoEcho: 'true', Description: "Username for #{instance_name} access", Type: 'String', MinLength: min_length, MaxLength: max_length, AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*', ConstraintDescription: 'must begin with a letter and contain only alphanumeric characters.' end |