To perform operations on an Elastic Compute Service (ECS) instance in an environment, you can only run the ssh command to log on to the ECS instance through Secure Shell (SSH), and then run the exec command on the ECS instance.

  • wpctl ssh: You need to specify a jump server in the security group where the environment resides. You can select an ECS instance or create a broker.
    $ wpctl configure
    Configuring profile 'default' in '' authenticate mode...
    Access Key Id [*************zGQ]:
    Access Key Secret [***************************N91]:
    Default Region Id [cn-shenzhen]:
    Default Output Format [json]: json (Only support json))
    Default Language [zh|en] zh:
    
    Configuring broker options...
    Broker Address [120.79.86.15]: 47.112.30.3
    Broker Port [22]:
    Broker User [root]:
    Broker Password [********4]:
    Broker Identity File []:
    
    Saving profile[default] ...Done.
    Configure Done!!!
    
    $ webxctl ssh demo-test-1
    [\] Finding servers of demo-test-1] (1s)
    [OK] Finding servers of demo-test-1 (2s)
    Found 2 servers:
    +----+------------------------+----------------+---------------+---------------+---------+
    | NO |           ID           |   PRIVATE IP   |   HOSTNAME    |   PUBLIC IP   | STATUS  |
    +----+------------------------+----------------+---------------+---------------+---------+
    |  1 | i-wz9i4zv4ov7fktngxefv | 172.18.207.215 | document-test | 47.112.30.3   | Running |
    |  2 | i-wz9i6yrcr8jgkurozbzi | 172.18.207.217 | document-test | 39.108.254.90 | Running |
    +----+------------------------+----------------+---------------+---------------+---------+
    Please choose server to operate [1]: 2
    
    
    [OK] Testing connection bewteen broker and server (0s)
    [OK] Adding auth key to 172.18.207.217 through CA (4s)
    [OK] Start forwarding on: [ 127.0.0.1:58424 -> 172.18.207.217:22 ] (0s)
    
    
    
    ****************************************
    * Logged on 172.18.207.217 as root     *
    ****************************************
    Last login: Tue Apr 23 15:14:52 2019 from 106.11.235.191
    
    Welcome to Alibaba Cloud Elastic Compute Service !
    
    [root@iZwz9i6yrcr8jgkurozbziZ ~]#
  • wpctl exec: After logging on to the target ECS instance in the deployment environment, you can run commands on the ECS instance. In this case, you need to install Cloud Assistant on the ECS instance.
    $ wpctl env:exec demo-test-1 'echo hello'
    [OK] (1s)ng servers of demo-test-1
    [OK] Finding servers of demo-test-1 (2s)
    Found 2 servers:
    +----+------------------------+----------------+---------------+---------------+---------+
    | NO |           ID           |   PRIVATE IP   |   HOSTNAME    |   PUBLIC IP   | STATUS  |
    +----+------------------------+----------------+---------------+---------------+---------+
    |  1 | i-wz9i4zv4ov7fktngxefv | 172.18.207.215 | document-test | 47.112.30.3   | Running |
    |  2 | i-wz9i6yrcr8jgkurozbzi | 172.18.207.217 | document-test | 39.108.254.90 | Running |
    +----+------------------------+----------------+---------------+---------------+---------+
    Please choose server to operate [default:1] [0 for all instances]:
    [OK] Checking Cloud Assistant status of 1 servers (1s)
    [OK] Executing Commands on 1 servers (3s)
    >>>>> 172.18.207.215 [i-wz9i4zv4ov7fktngxefv] status:Finished >>>>>
    hello
    
    <<<<< -----