资源编排服务 RFS-get_attribute:示例

时间:2024-04-18 10:02:52

示例

  • 获取参数并赋值给output的参数。

    示例:获取my-first-vpc创建后的id,并赋值给资源栈的输出参数vpc_id。

    tosca_definitions_version: huaweicloud_tosca_version_1_0
    inputs:
      name:
        default: test-vpc
      cidr:
        default: 10.0.0.0/8  
    node_templates:
      my-first-vpc:
        type: HuaweiCloud.VPC.VPC
        properties:
          name: {get_input: name}
          ciddr: {get_input: cidr}
    outputs:
      vpc_id:
        value: {get_attribute: [my-first-vpc,refID]}
  • 获取参数并作为其他资源创建的输入参数

    示例:获取my-second-vpc创建后的id,并赋值给subnet资源,作为创建subnet资源的输入,实现一个blueprint中联动创建多个资源。

    node_templates:
      my-subnet:
        type: HuaweiCloud.VPC.Subnet
        properties:
          name: {get_input: subnet-name}
          cidr: {get_input: vpc-cidr}
          gateway: {get_input: subnet-gateway}
          dnsList: {get_input: dnsList}
          vpc: {get_attribute: [my-second-vpc,refID]}
          availabilityZone: {get_input: az}
        requirements:
          - vpc:
            node: my-vpc
            relationship: HuaweiCloud.Relationships.ContainedIn      
      my-second-vpc:
        type: HuaweiCloud.VPC.VPC
        properties:
          name: {get_input: vpc-name}
          cidr: {get_input: vpc-cidr}
support.huaweicloud.com/tr-aos/aos_01_4135.html