Class: RenderCFN::LaunchConfiguration
- Defined in:
- lib/renderCFN/launchConfiguration.rb
Instance Method Summary collapse
- #addBlockDevice(deviceName, volumeSize, volumeType, iops = false, snapShotID = false) ⇒ Object
- #addInstanceProfile(name) ⇒ Object
- #addSecGroup(name) ⇒ Object
-
#initialize(arguments) ⇒ LaunchConfiguration
constructor
A new instance of LaunchConfiguration.
- #userData(file, common) ⇒ Object
Methods inherited from AwsObject
Constructor Details
#initialize(arguments) ⇒ LaunchConfiguration
Returns a new instance of LaunchConfiguration.
7 8 9 10 11 12 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 38 39 40 |
# File 'lib/renderCFN/launchConfiguration.rb', line 7 def initialize( arguments) @serviceName = arguments[:serviceName] @serviceTitle = arguments[:serviceTitle] @name = "#{arguments[:name]}LaunchConfiguration" @startServices = arguments[:startServices] @deployments = arguments[:deployments] @pmData = arguments[:pmData] @hostname = arguments[:hostname] @cfnEBSVolume = arguments[:cfnEBSVolume] @userDataOnBeforeStart = arguments[:userDataOnBeforeStart] || '' @userDataOnAfterEnd = arguments[:userDataOnAfterEnd] || '' @awsObject = { @name => { 'Type' => 'AWS::AutoScaling::LaunchConfiguration', 'Properties' => { 'ImageId' => arguments[:ami], 'InstanceType' => arguments[:instanceType], 'KeyName' => arguments[:keyName], 'InstanceMonitoring' => false, 'BlockDeviceMappings' => [], 'SecurityGroups' => [ #{'Ref' => 'AdminSecurityGroup'}, #{'Ref' => 'AppServerSecurityGroup'} ] }, 'DependsOn' => [] } } if arguments[:publicIP] @awsObject[@name]['Properties']['AssociatePublicIpAddress'] = true end end |
Instance Method Details
#addBlockDevice(deviceName, volumeSize, volumeType, iops = false, snapShotID = false) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/renderCFN/launchConfiguration.rb', line 46 def addBlockDevice( deviceName, volumeSize, volumeType, iops = false, snapShotID = false) ebs = Hash.new ebs['DeleteOnTermination'] = true ebs['Encrypted'] = false ebs['VolumeSize'] = volumeSize.to_s ebs['VolumeType'] = volumeType if iops ebs['Iops'] = iops end if snapShotID ebs['SnapshotId'] = snapShotID end blockDevice = Hash.new blockDevice['DeviceName'] = deviceName blockDevice['Ebs'] = ebs @awsObject[@name]['Properties']['BlockDeviceMappings'].push( blockDevice) end |
#addInstanceProfile(name) ⇒ Object
68 69 70 71 |
# File 'lib/renderCFN/launchConfiguration.rb', line 68 def addInstanceProfile( name) @awsObject[@name]['Properties']['IamInstanceProfile'] = { 'Ref' => name } @awsObject[@name]['DependsOn'].push( name) end |
#addSecGroup(name) ⇒ Object
42 43 44 |
# File 'lib/renderCFN/launchConfiguration.rb', line 42 def addSecGroup( name) @awsObject[@name]['Properties']['SecurityGroups'].push( name) end |
#userData(file, common) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/renderCFN/launchConfiguration.rb', line 73 def userData( file, common) erbUserData = String.new if File.exist?( "#{common}/UserData-start") erbUserData = File.read( "#{common}/UserData-start") end if File.exist?( file) erbUserData += File.read( file) end if File.exist?( "#{common}/UserData-end") erbUserData += File.read( "#{common}/UserData-end") end userData = ERB.new( erbUserData) @awsObject[@name]['Properties']['UserData'] = Base64.encode64(userData.result(binding)) end |