Create multiple ECS with ROS, specify names and add them to multiple SLB s

Keywords: Operation & Maintenance VPC network

This template example supports adding all created ECS to a single/multiple (up to three) SLB s as multiple back-end servers

Sketch:

ECS instances in the template support specifying different instance names and host names, and can choose network type as VPC or CLASSIC. When choosing not to create VPC, ECS instance specifications need to be changed. The reason is that ECS instance specifications can be created, which are different from those of VPC network types. The default is to create a new SLB instance. If the ID of the SLB instance is passed in, the number of SLB instances needs to be changed. The reason is that the number of SLB instances added to the back-end server needs to be identical according to the number of SLBs in the template and the ID of the SLB (e.g., with the ID of the two SLBs that have been created as parameters, the number of SLBs should be changed to 2).
This template currently supports attaching back-end servers to up to three SLB instances.

Involving resources:

ALIYUN::ECS::VPC (Virtual Private Network)
ALIYUN::ECS::VSwitch (Virtual Switch)
ALIYUN:: ECS:: Security Group
ALIYUN:: ECS:: Instance Group (Cloud Server Group)
ALIYUN:: SLB:: Load Balancer (Load Balancer)
ALIYUN:: SLB:: Backend Server Attachment (adding back-end servers for load balancing)

1. Create ECS Instance Group

The following is an example of creating an ECS Instance code of VPC type, in which batch ECS creation specifies different instance names and host names.

e.g. 

HostName[1,4]Test
 HostName: is the prefix of the ECS Instance Group host naming rules;
[1,4]:1 is the starting number and 4 is the number of digits. 
Test: The suffix for naming rules;
Results The hostnames of the ECS created were HostName 0001, HostName 002, HostName 0003, and...
{
  "Type": "ALIYUN::ECS::InstanceGroup",
  "Condition": "IsCreateVpc",
  "Properties": {
    "IoOptimized": "optimized",
    "ImageId": {
      "Ref": "EcsGroupImageId"
    },
    "SecurityGroupId": {
      "Fn::If": [
        "IsCreateVpc",
        {
          "Fn::GetAtt": [
            "SG",
            "SecurityGroupId"
          ]
        },
        {
          "Ref": "ALIYUN::NoValue"
        }
      ]
    },
    "Password": {
      "Ref": "EcsPassword"
    },
    "MinAmount": {
      "Ref": "MaxAmount"
    },
    "SystemDiskCategory": {
      "Ref": "EcsSystemDiskCategory"
    },
    "MaxAmount": {
      "Ref": "MaxAmount"
    },
    "VSwitchId": {
      "Fn::If": [
        "IsCreateVpc",
        {
          "Fn::GetAtt": [
            "VSwitch",
            "VSwitchId"
          ]
        },
        {
          "Ref": "ALIYUN::NoValue"
        }
      ]
    },
    "VpcId": {
      "Fn::If": [
        "IsCreateVpc",
        {
          "Fn::GetAtt": [
            "Vpc",
            "VpcId"
          ]
        },
        {
          "Ref": "ALIYUN::NoValue"
        }
      ]
    },
    "InstanceType": {
      "Ref": "EcsGroupInstanceType"
    },
    "InstanceName": {
      "Fn::Join": [
        "",
        [
          {
            "Ref": "InstanceNamePrefix"
          },
          "[",
          {
            "Ref": "InstanceNameBeginNumber"
          },
          ",4]",
          {
            "Ref": "InstanceNameSuffix"
          }
        ]
      ]
    },
    "HostName": {
      "Fn::Join": [
        "",
        [
          "HostNameTest",
          "[1,4]",
          {
            "Ref": "InstanceNameSuffix"
          }
        ]
      ]
    },
    "AllocatePublicIP": {
      "Fn::If": [
        "IsCreateVpc",
        false,
        true
      ]
    },
    "UserData": {
      "Fn::Join": [
        "",
        [
          "#!/bin/sh\n",
          "echo \"hello , create ecs group test\" > /tmp/create_test.log\n"
        ]
      ]
    }
  }
}

2. Adding back-end servers for SLB instances

The following example code creates additional back-end server functions, some ROS function functions used, and some logic judgments defined by itself, which can be consulted according to the schema template.
Considering the need to add back-end servers for multiple SLB instances, the scheme uses Conditions and functions to add back-end servers for single/multiple SLBs.

{
  "Type": "ALIYUN::SLB::BackendServerAttachment",
  "Condition": "IsAttachment1",
  "Properties": {
    "LoadBalancerId": {
      "Fn::If": [
        "IsCreateSlb",
        {
          "Fn::GetAtt": [
            "LoadBalancer",
            "LoadBalancerId"
          ]
        },
        {
          "Fn::Select": [
            "0",
            {
              "Fn::Split": [
                ",",
                {
                  "Ref": "LoadBalancerIds"
                }
              ]
            }
          ]
        }
      ]
    },
    "BackendServerList": {
      "Fn::If": [
        "IsCreateVpc",
        {
          "Fn::GetAtt": [
            "EcsInstanceGroupWithVpc",
            "InstanceIds"
          ]
        },
        {
          "Fn::GetAtt": [
            "EcsInstanceGroupNoVpc",
            "InstanceIds"
          ]
        }
      ]
    },
    "BackendServerWeightList": {
      "Fn::Split": [
        ",",
        {
          "Ref": "BackendServerWeightList"
        }
      ]
    }
  }
}

3. Conditional Code Example

Please combine Paramters in the template.

{
  "IsAttachment1": {
    "Fn::And": [
      {
        "Fn::Equals": [
          1,
          {
            "Ref": "SlbCount"
          }
        ]
      },
      {
        "Fn::Or": [
          "IsCreateSlb",
          {
            "Fn::Not": "IsCreateSlb"
          }
        ]
      }
    ]
  },
  "IsAttachment2": {
    "Fn::And": [
      {
        "Fn::Equals": [
          2,
          {
            "Ref": "SlbCount"
          }
        ]
      },
      {
        "Fn::Not": "IsCreateSlb"
      }
    ]
  },
  "IsAttachment3": {
    "Fn::And": [
      {
        "Fn::Equals": [
          3,
          {
            "Ref": "SlbCount"
          }
        ]
      },
      {
        "Fn::Not": "IsCreateSlb"
      }
    ]
  },
  "IsCreateSlb": {
    "Fn::Equals": [
      "None",
      {
        "Ref": "LoadBalancerIds"
      }
    ]
  },
  "IsCreateVpc": {
    "Fn::Equals": [
      "Yes",
      {
        "Ref": "IsCreateVpc"
      }
    ]
  },
  "NotUseVpc": {
    "Fn::Equals": [
      "No",
      {
        "Ref": "IsCreateVpc"
      }
    ]
  }
}

The scheme template is as follows:

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Conditions": {
    "IsAttachment1": {
      "Fn::And": [
        {
          "Fn::Equals": [
            1,
            {
              "Ref": "SlbCount"
            }
          ]
        },
        {
          "Fn::Or": [
            "IsCreateSlb",
            {
              "Fn::Not": "IsCreateSlb"
            }
          ]
        }
      ]
    },
    "IsAttachment2": {
      "Fn::And": [
        {
          "Fn::Equals": [
            2,
            {
              "Ref": "SlbCount"
            }
          ]
        },
        {
          "Fn::Not": "IsCreateSlb"
        }
      ]
    },
    "IsAttachment3": {
      "Fn::And": [
        {
          "Fn::Equals": [
            3,
            {
              "Ref": "SlbCount"
            }
          ]
        },
        {
          "Fn::Not": "IsCreateSlb"
        }
      ]
    },
    "IsCreateSlb": {
      "Fn::Equals": [
        "None",
        {
          "Ref": "LoadBalancerIds"
        }
      ]
    },
    "IsCreateVpc": {
      "Fn::Equals": [
        "Yes",
        {
          "Ref": "IsCreateVpc"
        }
      ]
    },
    "NotUseVpc": {
      "Fn::Equals": [
        "No",
        {
          "Ref": "IsCreateVpc"
        }
      ]
    }
  },
  "Parameters": {
    "SlbCount": {
      "Type": "Number",
      "Label": "Slb Quantity(confirm SLB Number)",
      "Description": "What needs to be added Slb Number of instances, Fill in quantities< Slb Example Id>. ",
      "Default": 1,
      "AllowedValues": [
        1,
        2,
        3
      ]
    },
    "BackendServerWeightList": {
      "Type": "String",
      "Label": "Slb Backend server weight",
      "Description": "Slb Backend server weight,Allow single or multiple;If one is specified, Be-all Ecs The weights are all of this value.;Multipurpose','(English comma)Separate, Multiple quantities need to correspond to "Need to add" Slb Medium Ecs Backend Server, The sequence of numbers corresponds one by one. e.g. 20,30,100 ",
      "Default": "100"
    },
    "LoadBalancerIds": {
      "Type": "String",
      "Label": "Slb Example Id",
      "Description": "Provide up to three slb,Multiple slb Necessity exists in one region within, Allow single or multiple, Multipurpose','(English comma)Separate, \ne.g. lb-bp183j4sfd02j02csd,lb-bid839fjn2j78bl,lb-sl39f8fvp6cbd4;\n If default values are used( None)Not specified, create one by default Slb Example.",
      "Default": "None"
    },
    "IsCreateVpc": {
      "Type": "String",
      "Description": "Whether to create Vpc,Not created by default.",
      "Label": "Whether to create Vpc",
      "Default": "Yes",
      "AllowedValues": [
        "No",
        "Yes"
      ]
    },
    "EcsGroupInstanceType": {
      "Type": "String",
      "Description": "Establish ECS The specification of the instance, by default, is ecs.n1.large, Network is classic Types are optional ecs.n1.large or ecs.n1.xlarge, Network is Vpc Types are optional ecs.c5.large or ecs.g5.large",
      "Label": "ECS Example Specification",
      "Default": "ecs.c5.large",
      "AllowedValues": [
        "ecs.n1.large",
        "ecs.n1.xlarge",
        "ecs.c5.large",
        "ecs.g5.large"
      ]
    },
    "MaxAmount": {
      "Type": "Number",
      "Description": "Once you need to create ECS Number of instances, and< ECS The starting number of the instance name corresponds to the available value.",
      "Label": "Establish ECS Number of instances",
      "Default": 2
    },
    "EcsGroupImageId": {
      "Type": "String",
      "Description": "Used for startup ECS Mirror of an instance ID. ",
      "Label": "ECS Instance Mirror",
      "Default": "centos_7_06_64_20G_alibase_20190218.vhd",
      "AssociationProperty": "ALIYUN::ECS::Instance:ImageId"
    },
    "EcsPassword": {
      "Type": "String",
      "Description": "Land ECS The password of the instance.",
      "ConstraintDescription": "8-30 A character,Characters, including three types of capital letters, lowercase letters, numbers or special characters.",
      "Label": "ECS Instance password",
      "AllowedPattern": "[a-zA-Z0-9-\\(\\)\\`\\~\\!@\\#\\$%\\^&\\*-+=\\|\\{\\}\\[\\]\\:\\;\\'\\,\\.\\?\\/]*",
      "MaxLength": 30,
      "MinLength": 8,
      "NoEcho": true,
      "Confirm": true
    },
    "EcsSystemDiskCategory": {
      "Type": "String",
      "Description": "System disk type: Effective Cloud Disk(cloud_efficiency) or Ordinary Cloud Disk(cloud_ssd)",
      "Label": "ECS Instance system disk type",
      "Default": "cloud_ssd",
      "AllowedValues": [
        "cloud_efficiency",
        "cloud_ssd"
      ]
    },
    "InstanceNamePrefix": {
      "Type": "String",
      "Description": "ECS Instance name prefix, Must be specified, It can't be empty. A maximum of 128 characters, including English, Chinese, numerals, etc.(_),(.),(-). ",
      "Label": "ECS Instance name prefix",
      "Default": "EcsGroup"
    },
    "InstanceNameBeginNumber": {
      "Type": "String",
      "Description": "ECS Starting number of instance name,The default is 0000, and the available values are 0000, 0005, 0010, 0015, 0020, respectively., The number of digits has been fixed to a maximum of 4 digits.",
      "Label": "ECS Starting number of instance name",
      "Default": "0"
    },
    "InstanceNameSuffix": {
      "Type": "String",
      "Description": "Appoint ECS Instance name suffix (optional),The default is empty.",
      "Label": "ECS Instance name suffix",
      "Default": "Test"
    }
  },
  "Resources": {
    "Vpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Condition": "IsCreateVpc",
      "Properties": {
        "VpcName": {
          "Fn::Join": [
            "-",
            [
              {
                "Ref": "ALIYUN::StackName"
              },
              "Vpc"
            ]
          ]
        },
        "CidrBlock": "192.168.0.0/16",
        "Description": {
          "Fn::Join": [
            " ",
            [
              "Vpc of the",
              {
                "Ref": "ALIYUN::StackName"
              }
            ]
          ]
        }
      }
    },
    "VSwitch": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Condition": "IsCreateVpc",
      "Properties": {
        "VSwitchName": {
          "Fn::Join": [
            "-",
            [
              {
                "Ref": "ALIYUN::StackName"
              },
              "VSwitch"
            ]
          ]
        },
        "VpcId": {
          "Fn::GetAtt": [
            "Vpc",
            "VpcId"
          ]
        },
        "CidrBlock": "192.168.0.0/16",
        "Description": {
          "Fn::Join": [
            " ",
            [
              "VSwitch of the",
              {
                "Ref": "ALIYUN::StackName"
              }
            ]
          ]
        },
        "ZoneId": {
          "Fn::Select": [
            "0",
            {
              "Fn::GetAZs": {
                "Ref": "ALIYUN::Region"
              }
            }
          ]
        }
      }
    },
    "SG": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Condition": "IsCreateVpc",
      "Properties": {
        "VpcId": {
          "Fn::GetAtt": [
            "Vpc",
            "VpcId"
          ]
        },
        "SecurityGroupName": {
          "Fn::Join": [
            "-",
            [
              {
                "Ref": "ALIYUN::StackName"
              },
              "SG"
            ]
          ]
        },
        "SecurityGroupIngress": [
          {
            "PortRange": "-1/-1",
            "Priority": 1,
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "all",
            "NicType": "intranet"
          }
        ],
        "SecurityGroupEgress": [
          {
            "PortRange": "-1/-1",
            "Priority": 1,
            "IpProtocol": "all",
            "DestCidrIp": "0.0.0.0/0",
            "NicType": "intranet"
          }
        ]
      }
    },
    "EcsInstanceGroupWithVpc": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Condition": "IsCreateVpc",
      "Properties": {
        "IoOptimized": "optimized",
        "ImageId": {
          "Ref": "EcsGroupImageId"
        },
        "SecurityGroupId": {
          "Fn::If": [
            "IsCreateVpc",
            {
              "Fn::GetAtt": [
                "SG",
                "SecurityGroupId"
              ]
            },
            {
              "Ref": "ALIYUN::NoValue"
            }
          ]
        },
        "Password": {
          "Ref": "EcsPassword"
        },
        "MinAmount": {
          "Ref": "MaxAmount"
        },
        "SystemDiskCategory": {
          "Ref": "EcsSystemDiskCategory"
        },
        "MaxAmount": {
          "Ref": "MaxAmount"
        },
        "VSwitchId": {
          "Fn::If": [
            "IsCreateVpc",
            {
              "Fn::GetAtt": [
                "VSwitch",
                "VSwitchId"
              ]
            },
            {
              "Ref": "ALIYUN::NoValue"
            }
          ]
        },
        "VpcId": {
          "Fn::If": [
            "IsCreateVpc",
            {
              "Fn::GetAtt": [
                "Vpc",
                "VpcId"
              ]
            },
            {
              "Ref": "ALIYUN::NoValue"
            }
          ]
        },
        "InstanceType": {
          "Ref": "EcsGroupInstanceType"
        },
        "InstanceName": {
          "Fn::Join": [
            "",
            [
              {
                "Ref": "InstanceNamePrefix"
              },
              "[",
              {
                "Ref": "InstanceNameBeginNumber"
              },
              ",4]",
              {
                "Ref": "InstanceNameSuffix"
              }
            ]
          ]
        },
        "HostName": {
          "Fn::Join": [
            "",
            [
              "HostNameTest",
              "[1,4]",
              {
                "Ref": "InstanceNameSuffix"
              }
            ]
          ]
        },
        "AllocatePublicIP": {
          "Fn::If": [
            "IsCreateVpc",
            false,
            true
          ]
        },
        "UserData": {
          "Fn::Join": [
            "",
            [
              "#!/bin/sh\n",
              "echo \"hello , create ecs group test\" > /tmp/create_test.log\n"
            ]
          ]
        }
      }
    },
    "EcsInstanceGroupNoVpc": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Condition": "NotUseVpc",
      "Properties": {
        "IoOptimized": "optimized",
        "ImageId": {
          "Ref": "EcsGroupImageId"
        },
        "Password": {
          "Ref": "EcsPassword"
        },
        "MinAmount": {
          "Ref": "MaxAmount"
        },
        "SystemDiskCategory": {
          "Ref": "EcsSystemDiskCategory"
        },
        "MaxAmount": {
          "Ref": "MaxAmount"
        },
        "InstanceType": {
          "Ref": "EcsGroupInstanceType"
        },
        "InstanceName": {
          "Fn::Join": [
            "",
            [
              {
                "Ref": "InstanceNamePrefix"
              },
              "[",
              {
                "Ref": "InstanceNameBeginNumber"
              },
              ",",
              "4",
              "]",
              {
                "Ref": "InstanceNameSuffix"
              }
            ]
          ]
        }
      }
    },
    "LoadBalancer": {
      "Condition": "IsCreateSlb",
      "Type": "ALIYUN::SLB::LoadBalancer",
      "Properties": {
        "AddressType": "internet"
      }
    },
    "BackendServerAttachment1": {
      "Type": "ALIYUN::SLB::BackendServerAttachment",
      "Condition": "IsAttachment1",
      "Properties": {
        "LoadBalancerId": {
          "Fn::If": [
            "IsCreateSlb",
            {
              "Fn::GetAtt": [
                "LoadBalancer",
                "LoadBalancerId"
              ]
            },
            {
              "Fn::Select": [
                "0",
                {
                  "Fn::Split": [
                    ",",
                    {
                      "Ref": "LoadBalancerIds"
                    }
                  ]
                }
              ]
            }
          ]
        },
        "BackendServerList": {
          "Fn::If": [
            "IsCreateVpc",
            {
              "Fn::GetAtt": [
                "EcsInstanceGroupWithVpc",
                "InstanceIds"
              ]
            },
            {
              "Fn::GetAtt": [
                "EcsInstanceGroupNoVpc",
                "InstanceIds"
              ]
            }
          ]
        },
        "BackendServerWeightList": {
          "Fn::Split": [
            ",",
            {
              "Ref": "BackendServerWeightList"
            }
          ]
        }
      }
    },
    "BackendServerAttachment2-1": {
      "Type": "ALIYUN::SLB::BackendServerAttachment",
      "Condition": "IsAttachment2",
      "Properties": {
        "LoadBalancerId": {
          "Fn::Select": [
            "0",
            {
              "Fn::Split": [
                ",",
                {
                  "Ref": "LoadBalancerIds"
                }
              ]
            }
          ]
        },
        "BackendServerList": {
          "Fn::If": [
            "IsCreateVpc",
            {
              "Fn::GetAtt": [
                "EcsInstanceGroupWithVpc",
                "InstanceIds"
              ]
            },
            {
              "Fn::GetAtt": [
                "EcsInstanceGroupNoVpc",
                "InstanceIds"
              ]
            }
          ]
        },
        "BackendServerWeightList": {
          "Fn::Split": [
            ",",
            {
              "Ref": "BackendServerWeightList"
            }
          ]
        }
      }
    },
    "BackendServerAttachment2-2": {
      "Type": "ALIYUN::SLB::BackendServerAttachment",
      "Condition": "IsAttachment2",
      "Properties": {
        "LoadBalancerId": {
          "Fn::Select": [
            "1",
            {
              "Fn::Split": [
                ",",
                {
                  "Ref": "LoadBalancerIds"
                }
              ]
            }
          ]
        },
        "BackendServerList": {
          "Fn::If": [
            "IsCreateVpc",
            {
              "Fn::GetAtt": [
                "EcsInstanceGroupWithVpc",
                "InstanceIds"
              ]
            },
            {
              "Fn::GetAtt": [
                "EcsInstanceGroupNoVpc",
                "InstanceIds"
              ]
            }
          ]
        },
        "BackendServerWeightList": {
          "Fn::Split": [
            ",",
            {
              "Ref": "BackendServerWeightList"
            }
          ]
        }
      }
    },
    "BackendServerAttachment3-1": {
      "Type": "ALIYUN::SLB::BackendServerAttachment",
      "Condition": "IsAttachment3",
      "Properties": {
        "LoadBalancerId": {
          "Fn::Select": [
            "0",
            {
              "Fn::Split": [
                ",",
                {
                  "Ref": "LoadBalancerIds"
                }
              ]
            }
          ]
        },
        "BackendServerList": {
          "Fn::If": [
            "IsCreateVpc",
            {
              "Fn::GetAtt": [
                "EcsInstanceGroupWithVpc",
                "InstanceIds"
              ]
            },
            {
              "Fn::GetAtt": [
                "EcsInstanceGroupNoVpc",
                "InstanceIds"
              ]
            }
          ]
        },
        "BackendServerWeightList": {
          "Fn::Split": [
            ",",
            {
              "Ref": "BackendServerWeightList"
            }
          ]
        }
      }
    },
    "BackendServerAttachment3-2": {
      "Type": "ALIYUN::SLB::BackendServerAttachment",
      "Condition": "IsAttachment3",
      "Properties": {
        "LoadBalancerId": {
          "Fn::Select": [
            "1",
            {
              "Fn::Split": [
                ",",
                {
                  "Ref": "LoadBalancerIds"
                }
              ]
            }
          ]
        },
        "BackendServerList": {
          "Fn::If": [
            "IsCreateVpc",
            {
              "Fn::GetAtt": [
                "EcsInstanceGroupWithVpc",
                "InstanceIds"
              ]
            },
            {
              "Fn::GetAtt": [
                "EcsInstanceGroupNoVpc",
                "InstanceIds"
              ]
            }
          ]
        },
        "BackendServerWeightList": {
          "Fn::Split": [
            ",",
            {
              "Ref": "BackendServerWeightList"
            }
          ]
        }
      }
    },
    "BackendServerAttachment3-3": {
      "Type": "ALIYUN::SLB::BackendServerAttachment",
      "Condition": "IsAttachment3",
      "Properties": {
        "LoadBalancerId": {
          "Fn::Select": [
            "2",
            {
              "Fn::Split": [
                ",",
                {
                  "Ref": "LoadBalancerIds"
                }
              ]
            }
          ]
        },
        "BackendServerList": {
          "Fn::If": [
            "IsCreateVpc",
            {
              "Fn::GetAtt": [
                "EcsInstanceGroupWithVpc",
                "InstanceIds"
              ]
            },
            {
              "Fn::GetAtt": [
                "EcsInstanceGroupNoVpc",
                "InstanceIds"
              ]
            }
          ]
        },
        "BackendServerWeightList": {
          "Fn::Split": [
            ",",
            {
              "Ref": "BackendServerWeightList"
            }
          ]
        }
      }
    }
  },
  "Outputs": {
    "EcsInstanceIds": {
      "Description": "All ECS Instance ID. ",
      "Value": {
        "Fn::If": [
          "IsCreateVpc",
          {
            "Fn::GetAtt": [
              "EcsInstanceGroupWithVpc",
              "InstanceIds"
            ]
          },
          {
            "Fn::GetAtt": [
              "EcsInstanceGroupNoVpc",
              "InstanceIds"
            ]
          }
        ]
      }
    },
    "LoadBalancerIp": {
      "Condition": "IsCreateSlb",
      "Description": "SLB Instance IP. ",
      "Value": {
        "Fn::GetAtt": [
          "LoadBalancer",
          "IpAddress"
        ]
      }
    },
    "EcsPublicIps": {
      "DependsOn": "NotUseVpc",
      "Description": "All ECS Examples of public networks IP list",
      "Value": {
        "Fn::If": [
          "IsCreateVpc",
          "Vpc Type ECS Example has no public network IP",
          {
            "Fn::GetAtt": [
              "EcsInstanceGroupNoVpc",
              "PublicIps"
            ]
          }
        ]
      }
    },
    "EcsPrivateIps": {
      "Description": "All ECS Instance Private Network IP List.",
      "Value": {
        "Fn::If": [
          "IsCreateVpc",
          {
            "Fn::GetAtt": [
              "EcsInstanceGroupWithVpc",
              "PrivateIps"
            ]
          },
          {
            "Fn::GetAtt": [
              "EcsInstanceGroupNoVpc",
              "InnerIps"
            ]
          }
        ]
      }
    },
    "EcsHostNames": {
      "Description": "All ECS List of host names for instances.",
      "Value": {
        "Fn::If": [
          "IsCreateVpc",
          {
            "Fn::GetAtt": [
              "EcsInstanceGroupWithVpc",
              "HostNames"
            ]
          },
          {
            "Fn::GetAtt": [
              "EcsInstanceGroupNoVpc",
              "HostNames"
            ]
          }
        ]
      }
    }
  }
}

Posted by kaupp on Mon, 09 Sep 2019 03:35:49 -0700