src/natgw.js
function buildNatGateway(position, zone) {
  const cfName = `NatGateway${position}`;
  return {
    [cfName]: {
      Type: 'AWS::EC2::NatGateway',
      Properties: {
        AllocationId: {
          'Fn::GetAtt': [`EIP${position}`, 'AllocationId'],
        },
        SubnetId: {
          Ref: `${PUBLIC_SUBNET}Subnet${position}`,
        },
        Tags: [
          {
            Key: 'Name',
            Value: {
              'Fn::Join': [
                '-',
                [
                  {
                    Ref: 'AWS::StackName',
                  },
                  zone,
                ],
              ],
            },
          },
        ],
      },
    },
  };
}
function buildNatGateway(position, zone) {
  const cfName = `NatGateway${position}`;
  return {
    [cfName]: {
      Type: 'AWS::EC2::NatGateway',
      Properties: {
        AllocationId: {
          'Fn::GetAtt': [`EIP${position}`, 'AllocationId'],
        },
        SubnetId: {
          Ref: `${PUBLIC_SUBNET}Subnet${position}`,
        },
        Tags: [
          {
            Key: 'Name',
            Value: {
              'Fn::Join': [
                '-',
                [
                  {
                    Ref: 'AWS::StackName',
                  },
                  zone,
                ],
              ],
            },
          },
        ],
      },
    },
  };
}
function buildNatGateway ( position , zone ) { const cfName = ` ${ position } ` ; return { [ cfName ] : { Type : 'AWS::EC2::NatGateway' , Properties : { AllocationId : { 'Fn::GetAtt' : [ ` ${ position } ` , 'AllocationId' ] , } , SubnetId : { Ref : ` ${ PUBLIC_SUBNET } ${ position } ` , } , Tags : [ { Key : 'Name' , Value : { 'Fn::Join' : [ '-' , [ { Ref : 'AWS::StackName' , } , zone , ] , ] , } , } , ] , } , } , } ; }
Build a NatGateway in a given AZ

@param {Number} position
@param {String} zone
@return {Object}
Build a NatGateway in a given AZ