Alibaba CLI(VPC)

 

https://qiita.com/nago3/items/f3a9aca5193ae3edbccb
https://www.alibabacloud.com/help/ja/ecs/product-overview/regions-and-zones
https://www.alibabacloud.com/help/ja/vpc/user-guide/ipv4-gateway-overview
https://www.softbank.jp/biz/blog/cloud-technology/articles/202211/ipv4gateway/
https://www.alibabacloud.com/help/ja/vpc/user-guide/overview-7
https://www.alibabacloud.com/help/en/nat-gateway/security-and-compliance/service-linked-role-1

 

VPC内の静的パブリックIPアドレスまたはEIPアドレス (EIP) が割り当てられているECSインスタンスは、
VPCのルートテーブルの影響を受けずにインターネットにアクセスできます。
(IPv4ゲートウェイ有効化していない場合)

 

-- リソースグループ


aliyun resourcemanager ListResourceGroups \
--endpoint resourcemanager.cn-qingdao.aliyuncs.com

aliyun resourcemanager ListResourceGroups \
--endpoint resourcemanager.cn-qingdao.aliyuncs.com \
| jq -c '.ResourceGroups.ResourceGroup | [ .Id, .Name ]' 

 

aliyun resourcemanager CreateResourceGroup \
--DisplayName rg123 \
--Name rg123 \
--endpoint resourcemanager.cn-qingdao.aliyuncs.com


aliyun resourcemanager DeleteResourceGroup \
--ResourceGroupId rg-111111111111111 \
--endpoint resourcemanager.cn-qingdao.aliyuncs.com 


-- VPC

aliyun vpc DescribeVpcs 


aliyun vpc CreateVpc \
--VpcName vpc01 \
--Description vpc01 \
--CidrBlock 10.1.0.0/16 

 

aliyun vpc DeleteVpc \
--VpcId vpc-111111111111111111111 \
--ForceDelete true 

 

-- リージョン一覧

aliyun ecs DescribeRegions 

 


-- ゾーン一覧


aliyun ecs DescribeZones 

aliyun ecs DescribeZones \
| jq -r '.Zones.Zone.ZoneId' 

 


-- VSwitch

aliyun vpc DescribeVSwitches

 

aliyun vpc CreateVSwitch \
--CidrBlock 10.1.1.0/24 \
--VpcId vpc-111111111111111111111 \
--ZoneId ap-northeast-1a \
--VSwitchName sw01 \
--Description sw01 

 

aliyun vpc DeleteVSwitch \
--VSwitchId vsw-111111111111111111111 

 


-- IPv4ゲートウェイ

 

aliyun vpc ListIpv4Gateways 


aliyun vpc CreateIpv4Gateway \
--VpcId vpc-111111111111111111111 \
--Ipv4GatewayName gw01 

 

aliyun vpc DeleteIpv4Gateway \
--Ipv4GatewayId ipv4gw-111111111111111111111 


IPv4ゲートウェイ有効化

aliyun vpc EnableVpcIpv4Gateway \
--Ipv4GatewayId ipv4gw-111111111111111111111 

 


-- VRouter

VPCを作成すると自動で作成される

aliyun vpc DescribeVRouters 

 

 

-- ルートテーブル

VPCを作成すると自動で作成される


aliyun vpc DescribeRouteTables \
--RouterId vrt-111111111111111111111 

 

aliyun vpc CreateRouteTable \
--VpcId vpc-111111111111111111111 \
--RouteTableName rt01 \
--AssociateType VSwitch 

aliyun vpc  DeleteRouteTable \
--RouteTableId vtb-111111111111111111111 

 

vSwitchの関連付け
aliyun vpc AssociateRouteTable \
--RouteTableId vtb-111111111111111111111 \
--VSwitchId vsw-111111111111111111111 


vSwitchの関連解除
aliyun vpc UnassociateRouteTable \
--RouteTableId vtb-111111111111111111111 \
--VSwitchId vsw-111111111111111111111 


カスタムルート追加

aliyun vpc DescribeRouteEntryList \
--RouteTableId vtb-111111111111111111111 


aliyun vpc CreateRouteEntries \
--RouteEntries.1.RouteTableId vtb-111111111111111111111 \
--RouteEntries.1.DstCidrBlock 0.0.0.0/0 \
--RouteEntries.1.NextHop ipv4gw-111111111111111111111 \
--RouteEntries.1.NextHopType Ipv4Gateway \
--RouteEntries.1.Name rte01


カスタムルート削除

aliyun vpc DescribeRouteEntryList \
--RouteTableId vtb-111111111111111111111 

aliyun vpc DeleteRouteEntries \
--RouteEntries.1.RouteTableId vtb-111111111111111111111 \
--RouteEntries.1.RouteEntryId rte-111111111111111111111 

 

 


-- ネットワーク ACL


aliyun vpc DescribeNetworkAcls 

aliyun vpc CreateNetworkAcl \
--VpcId vpc-111111111111111111111 \
--NetworkAclName acl01 

aliyun vpc DeleteNetworkAcl \
--NetworkAclId nacl-111111111111111111111 

 


vSwitchの関連付け
aliyun vpc AssociateNetworkAcl \
--NetworkAclId nacl-111111111111111111111 \
--Resource.1.ResourceId vsw-111111111111111111111 \
--Resource.1.ResourceType VSwitch 

vSwitchの関連解除

aliyun vpc UnassociateNetworkAcl \
--NetworkAclId nacl-111111111111111111111 \
--Resource.1.ResourceId vsw-111111111111111111111 \
--Resource.1.ResourceType VSwitch 

 

 

-- Elastic IP アドレス

InternetChargeType String  Optional

  *   **PayByBandwidth** (default): pay-by-bandwidth → 日毎の課金★
  *   **PayByTraffic**: pay-by-data-transfer → 時間毎の課金


aliyun vpc DescribeEipAddresses 

 

aliyun vpc AllocateEipAddress \
--Bandwidth 1 \
--InstanceChargeType PostPaid \
--InternetChargeType PayByTraffic \
--Name eip01 

 

aliyun vpc ReleaseEipAddress \
--AllocationId eip-111111111111111111111 


EIP割り当て
aliyun vpc AssociateEipAddress \
--AllocationId eip-111111111111111111111 \
--InstanceId i-11111111111111111111 \
--InstanceType EcsInstance
 
EIP割り当て解除
aliyun vpc UnassociateEipAddress \
--AllocationId eip-111111111111111111111 \
--InstanceId i-11111111111111111111 \
--InstanceType EcsInstance 

 

 


-- インターネット NAT ゲートウェイ


When you create an enhanced NAT gateway that does not have a service-linked role, 
the system automatically creates the service-linked role AliyunServiceRoleForNatgw for the NAT gateway

 

aliyun vpc DescribeNatGateways 

aliyun vpc CreateNatGateway \
--VpcId vpc-111111111111111111111 \
--InstanceChargeType PostPaid \
--Name natgw01 \
--NetworkType internet \
--VSwitchId vsw-111111111111111111111 \
--NatType Enhanced 

 

aliyun vpc DeleteNatGateway \
--NatGatewayId ngw-111111111111111111111 


EIP割り当て
aliyun vpc AssociateEipAddress \
--AllocationId eip-111111111111111111111 \
--InstanceId ngw-111111111111111111111 \
--InstanceType Nat
 
EIP割り当て解除
aliyun vpc UnassociateEipAddress \
--AllocationId eip-111111111111111111111 \
--InstanceId ngw-111111111111111111111 \
--InstanceType Nat 

 


SNATエントリ作成

aliyun vpc DescribeSnatTableEntries \
--NatGatewayId ngw-111111111111111111111


aliyun vpc CreateSnatEntry \
--SnatIp 192.0.2.1 \
--SnatTableId stb-111111111111111111111 \
--SnatEntryName snat01 \
--SourceCIDR 10.1.1.0/24 


SNATエントリ削除

aliyun vpc DescribeSnatTableEntries \
--NatGatewayId ngw-111111111111111111111


aliyun vpc DeleteSnatEntry \
--SnatEntryId snat-111111111111111111111 \
--SnatTableId stb-111111111111111111111

 


ルートテーブルエントリ追加
aliyun vpc DescribeRouteEntryList \
--RouteTableId vtb-111111111111111111111 

aliyun vpc CreateRouteEntries \
--RouteEntries.1.RouteTableId vtb-111111111111111111111 \
--RouteEntries.1.DstCidrBlock 0.0.0.0/0 \
--RouteEntries.1.NextHop ngw-111111111111111111111 \
--RouteEntries.1.NextHopType NatGateway \
--RouteEntries.1.Name rte01


ルートテーブルエントリ削除

aliyun vpc DescribeRouteEntryList \
--RouteTableId vtb-111111111111111111111 

aliyun vpc DeleteRouteEntries \
--RouteEntries.1.RouteTableId vtb-111111111111111111111 \
--RouteEntries.1.RouteEntryId rte-111111111111111111111