Sha256: ada46725867e9a23ad4bc929546e1da6341b3f61aa2f4e533f1512cb0289ac00

Contents?: true

Size: 1.94 KB

Versions: 15

Compression:

Stored size: 1.94 KB

Contents

CloudFormation do
  TEST ||= 'no value set'.freeze
  puts TEST

  Description 'Test'

  Parameter('One') do
    String
    Default 'Test'
    MaxLength 15
  end

  Parameter('Two') do
    String
    Default 'Test'
    MaxLength 15
  end

  # Condition Function examples
  Condition('OneIsTest', FnEquals(Ref('One'), 'Test'))
  Condition('OneIsNotTest', FnNot(FnEquals(Ref('One'), 'Test')))
  Condition('OneIsTestAndTwoIsTest',
            FnAnd(
              [
                FnEquals(Ref('One'), 'Test'),
                FnNot(FnEquals(Ref('Two'), 'Test'))
              ]))

  Condition('OneIsTestOrTwoIsTest',
            FnOr(
              [
                FnEquals(Ref('One'), 'Test'),
                FnEquals(Ref('Two'), 'Test')
              ]))

  Output(:One, FnBase64(Ref('One')))

  Resource('MyInstance') do
    Condition 'OneIsNotTest'
    Type 'AWS::EC2::Instance'
    Property('ImageId', 'ami-14341342')
  end

  LaunchConfiguration('Second') do
    Condition 'OneIsNotTest'
    BlockDeviceMapping do
      DeviceName '/dev/sda'
      VirtualName 'stuff'
      Ebs do
        SnapshotId 'asdasdfasdf'
        VolumeSize Ref('MyInstance')
      end
    end
  end

  Parameter('ElbSubnets') do
    Type 'CommaDelimitedList'
    Default 'subnet-12345, subnet-54321'
  end

  Resource('ElasticLoadBalancer') do
    Type 'AWS::ElasticLoadBalancing::LoadBalancer'
    Property('Subnets', [FnSelect('0', Ref('ElbSubnets')), FnSelect('1', Ref('ElbSubnets'))])
  end

  AutoScalingGroup('ASG') do
    UpdatePolicy('AutoScalingRollingUpdate',
                 'MinInstancesInService' => '1',
                 'MaxBatchSize'          => '1',
                 'PauseTime'             => 'PT15M'
                )
    AvailabilityZones FnGetAZs('')
    LaunchConfigurationName Ref('LaunchConfig')
    MinSize 1
    MaxSize FnIf('OneIsTest', 1, 3)
    LoadBalancerNames Ref('ElasticLoadBalancer')
  end

  LaunchConfiguration('LaunchConfig')

  # UndefinedResource('asddfasdf')
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
cfndsl-0.8.6 spec/fixtures/test.rb
cfndsl-0.8.5 spec/fixtures/test.rb
cfndsl-0.8.4 spec/fixtures/test.rb
cfndsl-0.8.3 spec/fixtures/test.rb
cfndsl-0.8.2 spec/fixtures/test.rb
cfndsl-0.8.1 spec/fixtures/test.rb
cfndsl-0.7.0 spec/fixtures/test.rb
cfndsl-0.6.2 spec/fixtures/test.rb
cfndsl-0.6.1 spec/fixtures/test.rb
cfndsl-0.6.0 spec/fixtures/test.rb
cfndsl-0.5.2 spec/fixtures/test.rb
cfndsl-0.5.1 spec/fixtures/test.rb
cfndsl-0.5.0 spec/fixtures/test.rb
cfndsl-0.5.1.pre spec/fixtures/test.rb
cfndsl-0.5.0.pre spec/fixtures/test.rb