0.4.5 • Published 6 months ago

@wangyjhh/msgr v0.4.5

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@wangyjhh/msgr

A security group rule management tool for Alibaba Cloud ESC implemented based on the official SDK.

Install

# npm
npm i @wangyjhh/msgr -g

# pnpm
pnpm add @wangyjhh/msgr -g

Usage

CLI

Usage: msgr [options] [command]

Alibaba Cloud security group rule management tool.

Options:
  -v, --version                      Output version number.
  -h, --help                         display help for command

Commands:
  config <tpye>                      Configuration
  list|ls                            Review the security group rules.
  add|ad                             Add the security group rules.
  remove|rm                          Remove the security group rules.
  modify|mo                          Modify the security group rules.
  help [command]                     display help for command

API

import MSGR from '@wangyjhh/msgr'

const region_msgr = new MSGR({
    regionId: 'your regionId',
    accessKeyId: 'your accessKeyId',
    accessKeySecret: 'your accessKeySecret',
})

regionId Supports values. For details, see regionIdMap

Example

Cli

Enter the command and fill in the necessary information according to the command line instructions

Get config

msgr config get

Set config

msgr config set

Default config

msgr config default

Remove config

msgr config remove

Clear config

msgr config clear

Get Security group rules list

msgr list
# The following commands will also work
msgr ls

Add Security group rules

msgr add
# The following commands will also work
msgr ad
msgr insert

Remove Security group rules

msgr remove
# The following commands will also work
msgr rm
msgr delete

Modify Security group rules

msgr modify
# The following commands will also work
msgr mo
msgr edit

API

import MSGR from '@wangyjhh/msgr'

const region_msgr = new MSGR({
    regionId: 'your regionId',
    accessKeyId: 'your accessKeyId',
    accessKeySecret: 'your accessKeySecret',
})

const main = async () => {
    // get security group id
    const security_group_id = (await region_msgr.getSecurityGroupId())[0]

    // get security group rules
    const security_group_test_rule_ifno = await region_msgr.getSecurityGroup(security_group_id, (item) => {
        return item.portRange === '80/80'
    })

    // get security group rule id
    const security_group_test_rule_id = security_group_test_rule_ifno[0].securityGroupRuleId

    // add security group rules
    await region_msgr.addSecurityGroup(security_group_id, {
        policy: 'accept',
        priority: '2',
        ipProtocol: 'TCP',
        portRange: '80/80',
        sourceCidrIp: '0.0.0.0/0',
        description: 'test',
    })

    // modify security group rules
    await region_msgr.modifySecurityGroup(security_group_id, security_group_test_rule_id, {
        policy: 'drop',
        priority: '2',
        ipProtocol: 'TCP',
        portRange: '80/80',
        sourceCidrIp: '0.0.0.0/0',
        description: 'test',
    })

    // delete security group rules
    await msgr.deleteSecurityGroup(security_group_id, security_group_test_rule_id)
}

main()
0.4.5

6 months ago

0.4.4

7 months ago

0.4.1

7 months ago

0.4.0

7 months ago

0.3.2

9 months ago

0.3.1

9 months ago

0.2.0

10 months ago

0.1.1

10 months ago

0.1.0

10 months ago