1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. apigateway
  5. getApis
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.apigateway.getApis

Explore with Pulumi AI

Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

This data source provides the Api Gateway APIs of the current Alibaba Cloud user.

NOTE: Available since v1.22.0.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const name = config.get("name") || "terraform-example";
const _default = new alicloud.apigateway.Group("default", {
    name: name,
    description: name,
});
const defaultApi = new alicloud.apigateway.Api("default", {
    groupId: _default.id,
    name: name,
    description: name,
    authType: "APP",
    serviceType: "HTTP",
    requestConfig: {
        protocol: "HTTP",
        method: "GET",
        path: "/test/path",
        mode: "MAPPING",
    },
    httpServiceConfig: {
        address: "http://apigateway-backend.alicloudapi.com:8080",
        method: "GET",
        path: "/web/cloudapi",
        timeout: 20,
        aoneName: "cloudapi-openapi",
    },
    requestParameters: [{
        name: name,
        type: "STRING",
        required: "OPTIONAL",
        "in": "QUERY",
        inService: "QUERY",
        nameService: name,
    }],
});
const ids = alicloud.apigateway.getApisOutput({
    ids: [defaultApi.id],
});
export const apiGatewayApisId0 = ids.apply(ids => ids.apis?.[0]?.id);
Copy
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "terraform-example"
default = alicloud.apigateway.Group("default",
    name=name,
    description=name)
default_api = alicloud.apigateway.Api("default",
    group_id=default.id,
    name=name,
    description=name,
    auth_type="APP",
    service_type="HTTP",
    request_config={
        "protocol": "HTTP",
        "method": "GET",
        "path": "/test/path",
        "mode": "MAPPING",
    },
    http_service_config={
        "address": "http://apigateway-backend.alicloudapi.com:8080",
        "method": "GET",
        "path": "/web/cloudapi",
        "timeout": 20,
        "aone_name": "cloudapi-openapi",
    },
    request_parameters=[{
        "name": name,
        "type": "STRING",
        "required": "OPTIONAL",
        "in_": "QUERY",
        "in_service": "QUERY",
        "name_service": name,
    }])
ids = alicloud.apigateway.get_apis_output(ids=[default_api.id])
pulumi.export("apiGatewayApisId0", ids.apis[0].id)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/apigateway"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		cfg := config.New(ctx, "")
		name := "terraform-example"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		_default, err := apigateway.NewGroup(ctx, "default", &apigateway.GroupArgs{
			Name:        pulumi.String(name),
			Description: pulumi.String(name),
		})
		if err != nil {
			return err
		}
		defaultApi, err := apigateway.NewApi(ctx, "default", &apigateway.ApiArgs{
			GroupId:     _default.ID(),
			Name:        pulumi.String(name),
			Description: pulumi.String(name),
			AuthType:    pulumi.String("APP"),
			ServiceType: pulumi.String("HTTP"),
			RequestConfig: &apigateway.ApiRequestConfigArgs{
				Protocol: pulumi.String("HTTP"),
				Method:   pulumi.String("GET"),
				Path:     pulumi.String("/test/path"),
				Mode:     pulumi.String("MAPPING"),
			},
			HttpServiceConfig: &apigateway.ApiHttpServiceConfigArgs{
				Address:  pulumi.String("http://apigateway-backend.alicloudapi.com:8080"),
				Method:   pulumi.String("GET"),
				Path:     pulumi.String("/web/cloudapi"),
				Timeout:  pulumi.Int(20),
				AoneName: pulumi.String("cloudapi-openapi"),
			},
			RequestParameters: apigateway.ApiRequestParameterArray{
				&apigateway.ApiRequestParameterArgs{
					Name:        pulumi.String(name),
					Type:        pulumi.String("STRING"),
					Required:    pulumi.String("OPTIONAL"),
					In:          pulumi.String("QUERY"),
					InService:   pulumi.String("QUERY"),
					NameService: pulumi.String(name),
				},
			},
		})
		if err != nil {
			return err
		}
		ids := apigateway.GetApisOutput(ctx, apigateway.GetApisOutputArgs{
			Ids: pulumi.StringArray{
				defaultApi.ID(),
			},
		}, nil)
		ctx.Export("apiGatewayApisId0", ids.ApplyT(func(ids apigateway.GetApisResult) (*string, error) {
			return &ids.Apis[0].Id, nil
		}).(pulumi.StringPtrOutput))
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var name = config.Get("name") ?? "terraform-example";
    var @default = new AliCloud.ApiGateway.Group("default", new()
    {
        Name = name,
        Description = name,
    });

    var defaultApi = new AliCloud.ApiGateway.Api("default", new()
    {
        GroupId = @default.Id,
        Name = name,
        Description = name,
        AuthType = "APP",
        ServiceType = "HTTP",
        RequestConfig = new AliCloud.ApiGateway.Inputs.ApiRequestConfigArgs
        {
            Protocol = "HTTP",
            Method = "GET",
            Path = "/test/path",
            Mode = "MAPPING",
        },
        HttpServiceConfig = new AliCloud.ApiGateway.Inputs.ApiHttpServiceConfigArgs
        {
            Address = "http://apigateway-backend.alicloudapi.com:8080",
            Method = "GET",
            Path = "/web/cloudapi",
            Timeout = 20,
            AoneName = "cloudapi-openapi",
        },
        RequestParameters = new[]
        {
            new AliCloud.ApiGateway.Inputs.ApiRequestParameterArgs
            {
                Name = name,
                Type = "STRING",
                Required = "OPTIONAL",
                In = "QUERY",
                InService = "QUERY",
                NameService = name,
            },
        },
    });

    var ids = AliCloud.ApiGateway.GetApis.Invoke(new()
    {
        Ids = new[]
        {
            defaultApi.Id,
        },
    });

    return new Dictionary<string, object?>
    {
        ["apiGatewayApisId0"] = ids.Apply(getApisResult => getApisResult.Apis[0]?.Id),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.apigateway.Group;
import com.pulumi.alicloud.apigateway.GroupArgs;
import com.pulumi.alicloud.apigateway.Api;
import com.pulumi.alicloud.apigateway.ApiArgs;
import com.pulumi.alicloud.apigateway.inputs.ApiRequestConfigArgs;
import com.pulumi.alicloud.apigateway.inputs.ApiHttpServiceConfigArgs;
import com.pulumi.alicloud.apigateway.inputs.ApiRequestParameterArgs;
import com.pulumi.alicloud.apigateway.ApigatewayFunctions;
import com.pulumi.alicloud.apigateway.inputs.GetApisArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var config = ctx.config();
        final var name = config.get("name").orElse("terraform-example");
        var default_ = new Group("default", GroupArgs.builder()
            .name(name)
            .description(name)
            .build());

        var defaultApi = new Api("defaultApi", ApiArgs.builder()
            .groupId(default_.id())
            .name(name)
            .description(name)
            .authType("APP")
            .serviceType("HTTP")
            .requestConfig(ApiRequestConfigArgs.builder()
                .protocol("HTTP")
                .method("GET")
                .path("/test/path")
                .mode("MAPPING")
                .build())
            .httpServiceConfig(ApiHttpServiceConfigArgs.builder()
                .address("http://apigateway-backend.alicloudapi.com:8080")
                .method("GET")
                .path("/web/cloudapi")
                .timeout(20)
                .aoneName("cloudapi-openapi")
                .build())
            .requestParameters(ApiRequestParameterArgs.builder()
                .name(name)
                .type("STRING")
                .required("OPTIONAL")
                .in("QUERY")
                .inService("QUERY")
                .nameService(name)
                .build())
            .build());

        final var ids = ApigatewayFunctions.getApis(GetApisArgs.builder()
            .ids(defaultApi.id())
            .build());

        ctx.export("apiGatewayApisId0", ids.applyValue(getApisResult -> getApisResult).applyValue(ids -> ids.applyValue(getApisResult -> getApisResult.apis()[0].id())));
    }
}
Copy
configuration:
  name:
    type: string
    default: terraform-example
resources:
  default:
    type: alicloud:apigateway:Group
    properties:
      name: ${name}
      description: ${name}
  defaultApi:
    type: alicloud:apigateway:Api
    name: default
    properties:
      groupId: ${default.id}
      name: ${name}
      description: ${name}
      authType: APP
      serviceType: HTTP
      requestConfig:
        protocol: HTTP
        method: GET
        path: /test/path
        mode: MAPPING
      httpServiceConfig:
        address: http://apigateway-backend.alicloudapi.com:8080
        method: GET
        path: /web/cloudapi
        timeout: 20
        aoneName: cloudapi-openapi
      requestParameters:
        - name: ${name}
          type: STRING
          required: OPTIONAL
          in: QUERY
          inService: QUERY
          nameService: ${name}
variables:
  ids:
    fn::invoke:
      function: alicloud:apigateway:getApis
      arguments:
        ids:
          - ${defaultApi.id}
outputs:
  apiGatewayApisId0: ${ids.apis[0].id}
Copy

Using getApis

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getApis(args: GetApisArgs, opts?: InvokeOptions): Promise<GetApisResult>
function getApisOutput(args: GetApisOutputArgs, opts?: InvokeOptions): Output<GetApisResult>
Copy
def get_apis(api_id: Optional[str] = None,
             group_id: Optional[str] = None,
             ids: Optional[Sequence[str]] = None,
             name_regex: Optional[str] = None,
             output_file: Optional[str] = None,
             opts: Optional[InvokeOptions] = None) -> GetApisResult
def get_apis_output(api_id: Optional[pulumi.Input[str]] = None,
             group_id: Optional[pulumi.Input[str]] = None,
             ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
             name_regex: Optional[pulumi.Input[str]] = None,
             output_file: Optional[pulumi.Input[str]] = None,
             opts: Optional[InvokeOptions] = None) -> Output[GetApisResult]
Copy
func GetApis(ctx *Context, args *GetApisArgs, opts ...InvokeOption) (*GetApisResult, error)
func GetApisOutput(ctx *Context, args *GetApisOutputArgs, opts ...InvokeOption) GetApisResultOutput
Copy

> Note: This function is named GetApis in the Go SDK.

public static class GetApis 
{
    public static Task<GetApisResult> InvokeAsync(GetApisArgs args, InvokeOptions? opts = null)
    public static Output<GetApisResult> Invoke(GetApisInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetApisResult> getApis(GetApisArgs args, InvokeOptions options)
public static Output<GetApisResult> getApis(GetApisArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: alicloud:apigateway/getApis:getApis
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

ApiId Changes to this property will trigger replacement. string
The ID of the API.
GroupId Changes to this property will trigger replacement. string
The ID of the API group.
Ids Changes to this property will trigger replacement. List<string>
A list of API IDs.
NameRegex Changes to this property will trigger replacement. string
A regex string to filter results by API name.
OutputFile string
File name where to save data source results (after running pulumi preview).
ApiId Changes to this property will trigger replacement. string
The ID of the API.
GroupId Changes to this property will trigger replacement. string
The ID of the API group.
Ids Changes to this property will trigger replacement. []string
A list of API IDs.
NameRegex Changes to this property will trigger replacement. string
A regex string to filter results by API name.
OutputFile string
File name where to save data source results (after running pulumi preview).
apiId Changes to this property will trigger replacement. String
The ID of the API.
groupId Changes to this property will trigger replacement. String
The ID of the API group.
ids Changes to this property will trigger replacement. List<String>
A list of API IDs.
nameRegex Changes to this property will trigger replacement. String
A regex string to filter results by API name.
outputFile String
File name where to save data source results (after running pulumi preview).
apiId Changes to this property will trigger replacement. string
The ID of the API.
groupId Changes to this property will trigger replacement. string
The ID of the API group.
ids Changes to this property will trigger replacement. string[]
A list of API IDs.
nameRegex Changes to this property will trigger replacement. string
A regex string to filter results by API name.
outputFile string
File name where to save data source results (after running pulumi preview).
api_id Changes to this property will trigger replacement. str
The ID of the API.
group_id Changes to this property will trigger replacement. str
The ID of the API group.
ids Changes to this property will trigger replacement. Sequence[str]
A list of API IDs.
name_regex Changes to this property will trigger replacement. str
A regex string to filter results by API name.
output_file str
File name where to save data source results (after running pulumi preview).
apiId Changes to this property will trigger replacement. String
The ID of the API.
groupId Changes to this property will trigger replacement. String
The ID of the API group.
ids Changes to this property will trigger replacement. List<String>
A list of API IDs.
nameRegex Changes to this property will trigger replacement. String
A regex string to filter results by API name.
outputFile String
File name where to save data source results (after running pulumi preview).

getApis Result

The following output properties are available:

Apis List<Pulumi.AliCloud.ApiGateway.Outputs.GetApisApi>
A list of APIs. Each element contains the following attributes:
Id string
The provider-assigned unique ID for this managed resource.
Ids List<string>
Names List<string>
A list of API names.
ApiId string
(Available since v1.224.0) The ID of the API.
GroupId string
The ID of the API group.
NameRegex string
OutputFile string
Apis []GetApisApi
A list of APIs. Each element contains the following attributes:
Id string
The provider-assigned unique ID for this managed resource.
Ids []string
Names []string
A list of API names.
ApiId string
(Available since v1.224.0) The ID of the API.
GroupId string
The ID of the API group.
NameRegex string
OutputFile string
apis List<GetApisApi>
A list of APIs. Each element contains the following attributes:
id String
The provider-assigned unique ID for this managed resource.
ids List<String>
names List<String>
A list of API names.
apiId String
(Available since v1.224.0) The ID of the API.
groupId String
The ID of the API group.
nameRegex String
outputFile String
apis GetApisApi[]
A list of APIs. Each element contains the following attributes:
id string
The provider-assigned unique ID for this managed resource.
ids string[]
names string[]
A list of API names.
apiId string
(Available since v1.224.0) The ID of the API.
groupId string
The ID of the API group.
nameRegex string
outputFile string
apis Sequence[GetApisApi]
A list of APIs. Each element contains the following attributes:
id str
The provider-assigned unique ID for this managed resource.
ids Sequence[str]
names Sequence[str]
A list of API names.
api_id str
(Available since v1.224.0) The ID of the API.
group_id str
The ID of the API group.
name_regex str
output_file str
apis List<Property Map>
A list of APIs. Each element contains the following attributes:
id String
The provider-assigned unique ID for this managed resource.
ids List<String>
names List<String>
A list of API names.
apiId String
(Available since v1.224.0) The ID of the API.
groupId String
The ID of the API group.
nameRegex String
outputFile String

Supporting Types

GetApisApi

ApiId This property is required. string
The ID of the API.
Description This property is required. string
The description of the API.
GroupId This property is required. string
The ID of the API group.
GroupName This property is required. string
The name of the API group.
Id This property is required. string
Name This property is required. string
The name of the API.
RegionId This property is required. string
The region ID of the API.
ApiId This property is required. string
The ID of the API.
Description This property is required. string
The description of the API.
GroupId This property is required. string
The ID of the API group.
GroupName This property is required. string
The name of the API group.
Id This property is required. string
Name This property is required. string
The name of the API.
RegionId This property is required. string
The region ID of the API.
apiId This property is required. String
The ID of the API.
description This property is required. String
The description of the API.
groupId This property is required. String
The ID of the API group.
groupName This property is required. String
The name of the API group.
id This property is required. String
name This property is required. String
The name of the API.
regionId This property is required. String
The region ID of the API.
apiId This property is required. string
The ID of the API.
description This property is required. string
The description of the API.
groupId This property is required. string
The ID of the API group.
groupName This property is required. string
The name of the API group.
id This property is required. string
name This property is required. string
The name of the API.
regionId This property is required. string
The region ID of the API.
api_id This property is required. str
The ID of the API.
description This property is required. str
The description of the API.
group_id This property is required. str
The ID of the API group.
group_name This property is required. str
The name of the API group.
id This property is required. str
name This property is required. str
The name of the API.
region_id This property is required. str
The region ID of the API.
apiId This property is required. String
The ID of the API.
description This property is required. String
The description of the API.
groupId This property is required. String
The ID of the API group.
groupName This property is required. String
The name of the API group.
id This property is required. String
name This property is required. String
The name of the API.
regionId This property is required. String
The region ID of the API.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi