{Alibaba ROS} Resource Orchestration Service

 

https://shiojojo.hatenablog.com/entry/2020/05/01/115609
https://www.alibabacloud.com/help/en/ros/getting-started

 

 

-- 1. バケットの作成

aliyun oss mb oss://backet123 \
--storage-class Standard \
--redundancy-type LRS \
--acl private


aliyun oss ls 
aliyun oss ls -s
aliyun oss stat oss://backet123

-- 2. テンプレートファイル作成

cat <<-'EOF' > ros01.yml

---
ROSTemplateFormatVersion: '2015-09-01'
Description: "ROSTemplate"

Parameters:
  SourceCidrIp:
    Type: String
    Description: "SourceCidrIp"
    Default: 100.104.0.0/16
    Label: SourceCidrIp
  KeyPairName:
    Type: String
    Description: "KeyPairName"
    Default: alibabakey01
    Label: KeyPairName


Resources:
  vpc01:
    Type: ALIYUN::ECS::VPC
    Properties:
      VpcName: vpc01
      CidrBlock: 10.2.0.0/16
      Description: vpc01
  sw01:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      VpcId:
        Ref: vpc01
      ZoneId: ap-northeast-1a
      VSwitchName: sw01
      CidrBlock: 10.2.1.0/24
      Description: sw01
  sg01:
    Type: ALIYUN::ECS::SecurityGroup
    Properties:
      VpcId:
        Ref: vpc01
      Description: sg01
      SecurityGroupName: sg01
      SecurityGroupIngress:
      - IpProtocol: tcp
        PortRange: 22/22
        NicType: intranet
        Priority: 10
        SourceCidrIp:
          Ref: SourceCidrIp
  ecs01:
    Type: ALIYUN::ECS::Instance
    Properties:
      ImageId: aliyun_2_1903_x64_20G_alibase_20231221.vhd
      InstanceType: ecs.t5-lc2m1.nano
      SecurityGroupId:
        Ref: sg01
      Description: ecs01
      InstanceName: ecs01
      HostName: ecs01
      AllocatePublicIP: false
      InternetChargeType: PayByBandwidth
      InternetMaxBandwidthIn: 1
      InternetMaxBandwidthOut: 0
      SystemDiskCategory: cloud_ssd
      SystemDiskSize: 20
      ZoneId: ap-northeast-1a
      VpcId:
        Ref: vpc01
      VSwitchId:
        Ref: sw01
      InstanceChargeType: PostPaid
      KeyPairName:
        Ref: KeyPairName


Outputs:
  vpc01_id:
    Value:
      Fn::GetAtt:
      - vpc01
      - VpcId
    Description: vpc01_id
  sw01_id:
    Value:
      Fn::GetAtt:
      - sw01
      - VSwitchId
    Description: sw01_id
  sg01_id:
    Value:
      Fn::GetAtt:
      - sg01
      - SecurityGroupId
    Description: sg01_id
    
  ecs01_id:
    Value:
      Fn::GetAtt:
        - ecs01
        - InstanceId
    Description: ecs01_id

 

EOF


-- 3. テンプレートファイルをOSSに格納しURLを取得する

aliyun oss cp ros01.yml oss://backet123/ros01.yml

aliyun oss ls oss://backet123 
aliyun oss ls oss://backet123 -s 

aliyun oss sign oss://backet123/ros01.yml --timeout 3600

URL=$(aliyun oss sign oss://backet123/ros01.yml --timeout 3600  | head -n 1 )

echo $URL

 

-- 4. テンプレート作成

aliyun ros ValidateTemplate \
--TemplateURL $URL

 

aliyun ros CreateTemplate \
--TemplateName template01 \
--TemplateURL $URL


aliyun ros ListTemplates 

 

 

 

-- 5. スタック作成


aliyun ros CreateStack \
--StackName stack01 \
--DeletionProtection Disabled \
--TemplateId 11111111-1111-1111-1111-111111111111 


aliyun ros ListStacks 

 


-- 6. クリーンアップ

スタックの削除
aliyun ros ListStacks 

aliyun ros DeleteStack \
--StackId 11111111-1111-1111-1111-111111111111 


テンプレートの削除
aliyun ros ListTemplates 

aliyun ros DeleteTemplate \
--TemplateId 11111111-1111-1111-1111-111111111111 

 

バケットの削除

※最初にバケットを空にする必要がある

aliyun oss rm oss://backet123 --recursive --force 
aliyun oss ls oss://backet123 -s 
aliyun oss rm oss://backet123 --bucket --force 
aliyun oss ls -s