src/bastion.js
function buildBastionAutoScalingGroup(numZones = 0, { name = 'BastionAutoScalingGroup' } = {}) {
  if (numZones < 1) {
    return {};
  }

  const zones = [];
  for (let i = 1; i <= numZones; i += 1) {
    zones.push({ Ref: `${PUBLIC_SUBNET}Subnet${i}` });
  }

  return {
    [name]: {
      Type: 'AWS::AutoScaling::AutoScalingGroup',
      CreationPolicy: {
        ResourceSignal: {
          Count: 1,
          Timeout: 'PT10M',
        },
      },
      Properties: {
        LaunchConfigurationName: {
          Ref: 'BastionLaunchConfiguration',
        },
        VPCZoneIdentifier: zones,
        MinSize: 1,
        MaxSize: 1,
        Cooldown: '300',
        DesiredCapacity: 1,
        Tags: [
          {
            Key: 'Name',
            Value: {
              'Fn::Join': [
                '-',
                [
                  {
                    Ref: 'AWS::StackName',
                  },
                  'bastion',
                ],
              ],
            },
            PropagateAtLaunch: true,
          },
        ],
      },
    },
  };
}
function buildBastionAutoScalingGroup(numZones = 0, { name = 'BastionAutoScalingGroup' } = {}) {
  if (numZones < 1) {
    return {};
  }

  const zones = [];
  for (let i = 1; i <= numZones; i += 1) {
    zones.push({ Ref: `${PUBLIC_SUBNET}Subnet${i}` });
  }

  return {
    [name]: {
      Type: 'AWS::AutoScaling::AutoScalingGroup',
      CreationPolicy: {
        ResourceSignal: {
          Count: 1,
          Timeout: 'PT10M',
        },
      },
      Properties: {
        LaunchConfigurationName: {
          Ref: 'BastionLaunchConfiguration',
        },
        VPCZoneIdentifier: zones,
        MinSize: 1,
        MaxSize: 1,
        Cooldown: '300',
        DesiredCapacity: 1,
        Tags: [
          {
            Key: 'Name',
            Value: {
              'Fn::Join': [
                '-',
                [
                  {
                    Ref: 'AWS::StackName',
                  },
                  'bastion',
                ],
              ],
            },
            PropagateAtLaunch: true,
          },
        ],
      },
    },
  };
}
function buildBastionAutoScalingGroup ( numZones = 0 , { name = 'BastionAutoScalingGroup' } = { } ) { if ( numZones < 1 ) { return { } ; } const zones = [ ] ; for ( let i = 1 ; i <= numZones ; i += 1 ) { zones . push ( { Ref : ` ${ PUBLIC_SUBNET } ${ i } ` } ) ; } return { [ name ] : { Type : 'AWS::AutoScaling::AutoScalingGroup' , CreationPolicy : { ResourceSignal : { Count : 1 , Timeout : 'PT10M' , } , } , Properties : { LaunchConfigurationName : { Ref : 'BastionLaunchConfiguration' , } , VPCZoneIdentifier : zones , MinSize : 1 , MaxSize : 1 , Cooldown : '300' , DesiredCapacity : 1 , Tags : [ { Key : 'Name' , Value : { 'Fn::Join' : [ '-' , [ { Ref : 'AWS::StackName' , } , 'bastion' , ] , ] , } , PropagateAtLaunch : true , } , ] , } , } , } ; }
Build the bastion host auto-scaling group

@param {Number} numZones Number of availability zones
@param {Object} params
@return {Object}
Build the bastion host auto - scaling group