本文为您介绍如何通过阿里云CLI(3.0.25以下版本)调用资源相关的API。

DecribeResources

查询资源栈资源信息。

命令 功能 备注
--StackName 指定资源栈的名称 必选
--StackId 指定资源栈的ID 必选

调用示例

aliyun ros GET /stacks/[StackName]/[StackId]/resources

查询成功后,输出资源栈资源信息,否则输出错误信息。

成功示例

$ aliyun ros GET /stacks/ros_test_cli_stack_name/***-**-**-**-***/resources

[
    {
        "Status": "CREATE_COMPLETE",
        "Updated": "2019-07-20T10:28:24",
        "Name": "Eip",
        "Created": "2019-07-20T10:28:22",
        "ResourceData": null,
        "PhysicalId": "***",
        "StatusReason": "state changed",
        "Deleted": null,
        "Type": "ALIYUN::VPC::EIP",
        "Id": "Eip"
    }
]

失败示例

$ aliyun ros GET /stacks/ros_test_cli_stack_name/***-**-**-**-***/resources

ERROR: SDK.ServerError
ErrorCode: StackNotFound
Recommend:
RequestId:
Message: The Stack (ros_test_cli_stack_name) could not be found.

DescribeResourceTypes

查询所有可用的资源类型信息。

命令 功能 备注
--SupportStatus 通过支持状态过滤资源类型 可选。有效支持状态:UNKNOWN、SUPPORTED、DEPRECATED、UNSUPPORTED和HIDDEN。

调用示例

aliyun ros GET /resource_types

查询成功后,输出所有资源类型信息,否则输出错误信息。

成功示例

$ aliyun ros GET /resource_types

{
    "ResourceTypes": [
        "ALIYUN::ACTIONTRAIL::Trail",
        "ALIYUN::ACTIONTRAIL::TrailLogging",
        "ALIYUN::ApiGateway::Api",
        "ALIYUN::ApiGateway::App",
        "ALIYUN::ApiGateway::Authorization",
        "ALIYUN::ApiGateway::CustomDomain",
        "ALIYUN::ApiGateway::Deployment",
        "ALIYUN::ApiGateway::Group",
        "ALIYUN::ApiGateway::Signature",
        "ALIYUN::ApiGateway::SignatureBinding",
        "ALIYUN::ApiGateway::StageConfig",
        "ALIYUN::ApiGateway::TrafficControl",
        "ALIYUN::ApiGateway::TrafficControlBinding",
        "ALIYUN::ApiGateway::VpcAccessConfig",
        "ALIYUN::BSS::WaitOrder",
        "ALIYUN::CDN::Domain",
        "ALIYUN::CDN::DomainConfig",
        "ALIYUN::CEN::CenBandwidthLimit",
        "ALIYUN::CEN::CenBandwidthPackage",
        "ALIYUN::CEN::CenBandwidthPackageAssociation",
        "ALIYUN::CEN::CenInstance",
        "ALIYUN::CEN::CenInstanceAttachment",
        "ALIYUN::CEN::RouteEntry",
        "ALIYUN::CMS::MonitorGroup",
        "ALIYUN::CS::App",
        "ALIYUN::CS::Cluster",
        "ALIYUN::DNS::Domain",
        "ALIYUN::DNS::DomainGroup",
        "ALIYUN::DNS::DomainRecord",
        "ALIYUN::ECS::AutoSnapshotPolicy",
        "ALIYUN::ECS::BandwidthPackage",
        "ALIYUN::ECS::Command",
        "ALIYUN::ECS::CopyImage",
        "ALIYUN::ECS::CustomImage",
        "ALIYUN::ECS::DedicatedHost",
        "ALIYUN::ECS::DeploymentSet",
        "ALIYUN::ECS::Disk",
        "ALIYUN::ECS::DiskAttachment",
        "ALIYUN::ECS::ForwardEntry",
        "ALIYUN::ECS::Instance",
        "ALIYUN::ECS::InstanceClone",
        "ALIYUN::ECS::InstanceGroup",
        "ALIYUN::ECS::InstanceGroupClone",
        "ALIYUN::ECS::Invocation",
        "ALIYUN::ECS::JoinSecurityGroup",
        "ALIYUN::ECS::LaunchTemplate",
        "ALIYUN::ECS::NatGateway",
        "ALIYUN::ECS::NetworkInterface",
        "ALIYUN::ECS::NetworkInterfaceAttachment",
        "ALIYUN::ECS::NetworkInterfacePermission",
        "ALIYUN::ECS::PrepayInstance",
        "ALIYUN::ECS::PrepayInstanceGroupClone",
        "ALIYUN::ECS::Route",
        "ALIYUN::ECS::SNatEntry",
        "ALIYUN::ECS::SSHKeyPair",
        "ALIYUN::ECS::SSHKeyPairAttachment",
        "ALIYUN::ECS::SecurityGroup",
        "ALIYUN::ECS::SecurityGroupClone",
        "ALIYUN::ECS::SecurityGroupEgress",
        "ALIYUN::ECS::SecurityGroupIngress",
        "ALIYUN::ECS::Snapshot",
        "ALIYUN::ECS::VPC",
        "ALIYUN::ECS::VSwitch",
        "ALIYUN::ESS::AlarmTask",
        "ALIYUN::ESS::AlarmTaskEnable",
        "ALIYUN::ESS::LifecycleHook",
        "ALIYUN::ESS::ScalingConfiguration",
        "ALIYUN::ESS::ScalingGroup",
        "ALIYUN::ESS::ScalingGroupEnable",
        "ALIYUN::ESS::ScalingRule",
        "ALIYUN::ESS::ScheduledTask",
        "ALIYUN::FC::Function",
        "ALIYUN::FC::FunctionInvoker",
        "ALIYUN::FC::Service",
        "ALIYUN::FC::Trigger",
        "ALIYUN::KMS::Alias",
        "ALIYUN::KMS::Key",
        "ALIYUN::MEMCACHE::Instance",
        "ALIYUN::MNS::Queue",
        "ALIYUN::MNS::Subscription",
        "ALIYUN::MNS::Topic",
        "ALIYUN::MONGODB::Instance",
        "ALIYUN::MONGODB::PrepayInstance",
        "ALIYUN::MarketPlace::Image",
        "ALIYUN::MarketPlace::Order",
        "ALIYUN::NAS::AccessGroup",
        "ALIYUN::NAS::AccessRule",
        "ALIYUN::NAS::FileSystem",
        "ALIYUN::NAS::MountTarget",
        "ALIYUN::OSS::Bucket",
        "ALIYUN::OTS::Instance",
        "ALIYUN::OTS::VpcBinder",
        "ALIYUN::PVTZ::Zone",
        "ALIYUN::PVTZ::ZoneRecord",
        "ALIYUN::PVTZ::ZoneVpcBinder",
        "ALIYUN::RAM::AccessKey",
        "ALIYUN::RAM::AttachPolicyToRole",
        "ALIYUN::RAM::Group",
        "ALIYUN::RAM::ManagedPolicy",
        "ALIYUN::RAM::Role",
        "ALIYUN::RAM::User",
        "ALIYUN::RAM::UserToGroupAddition",
        "ALIYUN::RDS::Account",
        "ALIYUN::RDS::AccountPrivilege",
        "ALIYUN::RDS::DBInstance",
        "ALIYUN::RDS::DBInstanceParameterGroup",
        "ALIYUN::RDS::DBInstanceSecurityIps",
        "ALIYUN::RDS::PrepayDBInstance",
        "ALIYUN::REDIS::Instance",
        "ALIYUN::REDIS::PrepayInstance",
        "ALIYUN::ROS::Stack",
        "ALIYUN::ROS::WaitCondition",
        "ALIYUN::ROS::WaitConditionHandle",
        "ALIYUN::SAG::ACL",
        "ALIYUN::SAG::ACLAssociation",
        "ALIYUN::SAG::ACLRule",
        "ALIYUN::SAG::CloudConnectNetwork",
        "ALIYUN::SAG::SmartAccessGatewayBinding",
        "ALIYUN::SLB::AccessControl",
        "ALIYUN::SLB::BackendServerAttachment",
        "ALIYUN::SLB::BackendServerToVServerGroupAddition",
        "ALIYUN::SLB::Certificate",
        "ALIYUN::SLB::DomainExtension",
        "ALIYUN::SLB::Listener",
        "ALIYUN::SLB::LoadBalancer",
        "ALIYUN::SLB::LoadBalancerClone",
        "ALIYUN::SLB::MasterSlaveServerGroup",
        "ALIYUN::SLB::Rule",
        "ALIYUN::SLB::VServerGroup",
        "ALIYUN::SLS::ApplyConfigToMachineGroup",
        "ALIYUN::SLS::MachineGroup",
        "ALIYUN::UIS::Uis",
        "ALIYUN::UIS::UisConnection",
        "ALIYUN::UIS::UisNode",
        "ALIYUN::VPC::EIP",
        "ALIYUN::VPC::EIPAssociation",
        "ALIYUN::VPC::PeeringRouterInterfaceBinding",
        "ALIYUN::VPC::PeeringRouterInterfaceConnection",
        "ALIYUN::VPC::RouterInterface",
        "ALIYUN::VPC::SnatEntry"
    ]
}

DescribeResourceTypeDetail

查询资源类型详情信息。

命令 功能 备注
--TypeName 指定资源类型的名称 必选

调用示例

aliyun ros GET /resource_types/[TypeName]

查询成功后,返回资源类型信息,否则输出错误信息。

成功示例

$ aliyun ros GET /resource_types/ALIYUN::ROS::Stack

{
    "ResourceType": "ALIYUN::ROS::Stack",
    "Attributes": {},
    "Properties": {
        "TemplateURL": {
            "Description": "The URL of a template that specifies the stack to be created as a resource. Supported url schemas: https, https and oss. For example:\nhttp://www.my-site.com/simple-tpl\nhttps://www.my-site.com/simple-tpl\noss://stacks/simple-tpl",
            "Required": true,
            "UpdateAllowed": true,
            "Type": "string",
            "Immutable": false,
            "Constraints": [
                {
                    "Length": {
                        "Max": 1024
                    }
                }
            ]
        },
        "TimeoutMins": {
            "UpdateAllowed": true,
            "Required": true,
            "Type": "number",
            "Description": "The length of time, in minutes, to wait for the nested stack creation.",
            "Immutable": false
        },
        "Parameters": {
            "UpdateAllowed": true,
            "Required": false,
            "Type": "map",
            "Description": "The set of parameters passed to this nested stack.",
            "Immutable": false
        }
    },
    "SupportStatus": {
        "Status": "SUPPORTED",
        "Message": null,
        "Version": null
    }
}

失败示例

$ aliyun ros GET /resource_types/ALIYUN::ROS::Stack2

ERROR: SDK.ServerError
ErrorCode: ResourceTypeNotFound
Recommend:
RequestId:
Message: The Resource Type (ALIYUN::ROS::Stack2) could not be found.

DescribeResourceTypeTemplate

查询资源类型模板信息。

命令 功能 备注
--TypeName 指定资源类型的名称 必选

调用示例

aliyun ros GET /resource_types/[TypeName]/template

查询成功后,返回资源类型的模板信息,否则输出错误信息。

成功示例

$ aliyun ros GET /resource_types/ALIYUN::ROS::Stack/template

{
    "ROSTemplateFormatVersion": "2015-09-01",
    "Resources": {
        "NestedStack": {
            "Type": "ALIYUN::ROS::Stack",
            "Properties": {
                "TemplateURL": {
                    "Ref": "TemplateURL"
                },
                "TimeoutMins": {
                    "Ref": "TimeoutMins"
                },
                "Parameters": {
                    "Ref": "Parameters"
                }
            }
        }
    },
    "Parameters": {
        "TemplateURL": {
            "Type": "String",
            "Description": "The URL of a template that specifies the stack to be created as a resource. Supported url schemas: https, https and oss. For example:\nhttp://www.my-site.com/simple-tpl\nhttps://www.my-site.com/simple-tpl\noss://stacks/simple-tpl",
            "MaxLength": 1024
        },
        "TimeoutMins": {
            "Type": "Number",
            "Description": "The length of time, in minutes, to wait for the nested stack creation."
        },
        "Parameters": {
            "Type": "Json",
            "Description": "The set of parameters passed to this nested stack."
        }
    },
    "Outputs": {}
}

失败示例

$ aliyun ros GET /resource_types/ALIYUN::ROS::Stack2/template

ERROR: SDK.ServerError
ErrorCode:
Recommend:
RequestId:
Message: {"message": "The Resource Type (ALIYUN::ROS::Stack2) could not be found.", "code": "ResourceTypeNotFound"}