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

alicloud.apig.HttpApi

Explore with Pulumi AI

Provides a APIG Http Api resource.

For information about APIG Http Api and how to use it, see What is Http Api.

NOTE: Available since v1.240.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 protocol = config.get("protocol") || "HTTP";
const protocolHttps = config.get("protocolHttps") || "HTTPS";
const _default = alicloud.resourcemanager.getResourceGroups({});
const defaultHttpApi = new alicloud.apig.HttpApi("default", {
    httpApiName: name,
    protocols: [protocol],
    basePath: "/v1",
    description: "zhiwei_pop_examplecase",
    type: "Rest",
});
Copy
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "terraform-example"
protocol = config.get("protocol")
if protocol is None:
    protocol = "HTTP"
protocol_https = config.get("protocolHttps")
if protocol_https is None:
    protocol_https = "HTTPS"
default = alicloud.resourcemanager.get_resource_groups()
default_http_api = alicloud.apig.HttpApi("default",
    http_api_name=name,
    protocols=[protocol],
    base_path="/v1",
    description="zhiwei_pop_examplecase",
    type="Rest")
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/apig"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/resourcemanager"
	"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
		}
		protocol := "HTTP"
		if param := cfg.Get("protocol"); param != "" {
			protocol = param
		}
		protocolHttps := "HTTPS"
		if param := cfg.Get("protocolHttps"); param != "" {
			protocolHttps = param
		}
		_, err := resourcemanager.GetResourceGroups(ctx, &resourcemanager.GetResourceGroupsArgs{}, nil)
		if err != nil {
			return err
		}
		_, err = apig.NewHttpApi(ctx, "default", &apig.HttpApiArgs{
			HttpApiName: pulumi.String(name),
			Protocols: pulumi.StringArray{
				pulumi.String(protocol),
			},
			BasePath:    pulumi.String("/v1"),
			Description: pulumi.String("zhiwei_pop_examplecase"),
			Type:        pulumi.String("Rest"),
		})
		if err != nil {
			return err
		}
		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 protocol = config.Get("protocol") ?? "HTTP";
    var protocolHttps = config.Get("protocolHttps") ?? "HTTPS";
    var @default = AliCloud.ResourceManager.GetResourceGroups.Invoke();

    var defaultHttpApi = new AliCloud.Apig.HttpApi("default", new()
    {
        HttpApiName = name,
        Protocols = new[]
        {
            protocol,
        },
        BasePath = "/v1",
        Description = "zhiwei_pop_examplecase",
        Type = "Rest",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
import com.pulumi.alicloud.resourcemanager.inputs.GetResourceGroupsArgs;
import com.pulumi.alicloud.apig.HttpApi;
import com.pulumi.alicloud.apig.HttpApiArgs;
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");
        final var protocol = config.get("protocol").orElse("HTTP");
        final var protocolHttps = config.get("protocolHttps").orElse("HTTPS");
        final var default = ResourcemanagerFunctions.getResourceGroups();

        var defaultHttpApi = new HttpApi("defaultHttpApi", HttpApiArgs.builder()
            .httpApiName(name)
            .protocols(protocol)
            .basePath("/v1")
            .description("zhiwei_pop_examplecase")
            .type("Rest")
            .build());

    }
}
Copy
configuration:
  name:
    type: string
    default: terraform-example
  protocol:
    type: string
    default: HTTP
  protocolHttps:
    type: string
    default: HTTPS
resources:
  defaultHttpApi:
    type: alicloud:apig:HttpApi
    name: default
    properties:
      httpApiName: ${name}
      protocols:
        - ${protocol}
      basePath: /v1
      description: zhiwei_pop_examplecase
      type: Rest
variables:
  default:
    fn::invoke:
      function: alicloud:resourcemanager:getResourceGroups
      arguments: {}
Copy

Create HttpApi Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new HttpApi(name: string, args: HttpApiArgs, opts?: CustomResourceOptions);
@overload
def HttpApi(resource_name: str,
            args: HttpApiArgs,
            opts: Optional[ResourceOptions] = None)

@overload
def HttpApi(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            http_api_name: Optional[str] = None,
            protocols: Optional[Sequence[str]] = None,
            base_path: Optional[str] = None,
            description: Optional[str] = None,
            resource_group_id: Optional[str] = None,
            type: Optional[str] = None)
func NewHttpApi(ctx *Context, name string, args HttpApiArgs, opts ...ResourceOption) (*HttpApi, error)
public HttpApi(string name, HttpApiArgs args, CustomResourceOptions? opts = null)
public HttpApi(String name, HttpApiArgs args)
public HttpApi(String name, HttpApiArgs args, CustomResourceOptions options)
type: alicloud:apig:HttpApi
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. HttpApiArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. HttpApiArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. HttpApiArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. HttpApiArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. HttpApiArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var httpApiResource = new AliCloud.Apig.HttpApi("httpApiResource", new()
{
    HttpApiName = "string",
    Protocols = new[]
    {
        "string",
    },
    BasePath = "string",
    Description = "string",
    ResourceGroupId = "string",
    Type = "string",
});
Copy
example, err := apig.NewHttpApi(ctx, "httpApiResource", &apig.HttpApiArgs{
	HttpApiName: pulumi.String("string"),
	Protocols: pulumi.StringArray{
		pulumi.String("string"),
	},
	BasePath:        pulumi.String("string"),
	Description:     pulumi.String("string"),
	ResourceGroupId: pulumi.String("string"),
	Type:            pulumi.String("string"),
})
Copy
var httpApiResource = new HttpApi("httpApiResource", HttpApiArgs.builder()
    .httpApiName("string")
    .protocols("string")
    .basePath("string")
    .description("string")
    .resourceGroupId("string")
    .type("string")
    .build());
Copy
http_api_resource = alicloud.apig.HttpApi("httpApiResource",
    http_api_name="string",
    protocols=["string"],
    base_path="string",
    description="string",
    resource_group_id="string",
    type="string")
Copy
const httpApiResource = new alicloud.apig.HttpApi("httpApiResource", {
    httpApiName: "string",
    protocols: ["string"],
    basePath: "string",
    description: "string",
    resourceGroupId: "string",
    type: "string",
});
Copy
type: alicloud:apig:HttpApi
properties:
    basePath: string
    description: string
    httpApiName: string
    protocols:
        - string
    resourceGroupId: string
    type: string
Copy

HttpApi Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The HttpApi resource accepts the following input properties:

HttpApiName
This property is required.
Changes to this property will trigger replacement.
string
The name of the resource
Protocols This property is required. List<string>
API protocol
BasePath string
API path
Description string
Description of API
ResourceGroupId string
The ID of the resource group
Type Changes to this property will trigger replacement. string
API type
HttpApiName
This property is required.
Changes to this property will trigger replacement.
string
The name of the resource
Protocols This property is required. []string
API protocol
BasePath string
API path
Description string
Description of API
ResourceGroupId string
The ID of the resource group
Type Changes to this property will trigger replacement. string
API type
httpApiName
This property is required.
Changes to this property will trigger replacement.
String
The name of the resource
protocols This property is required. List<String>
API protocol
basePath String
API path
description String
Description of API
resourceGroupId String
The ID of the resource group
type Changes to this property will trigger replacement. String
API type
httpApiName
This property is required.
Changes to this property will trigger replacement.
string
The name of the resource
protocols This property is required. string[]
API protocol
basePath string
API path
description string
Description of API
resourceGroupId string
The ID of the resource group
type Changes to this property will trigger replacement. string
API type
http_api_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the resource
protocols This property is required. Sequence[str]
API protocol
base_path str
API path
description str
Description of API
resource_group_id str
The ID of the resource group
type Changes to this property will trigger replacement. str
API type
httpApiName
This property is required.
Changes to this property will trigger replacement.
String
The name of the resource
protocols This property is required. List<String>
API protocol
basePath String
API path
description String
Description of API
resourceGroupId String
The ID of the resource group
type Changes to this property will trigger replacement. String
API type

Outputs

All input properties are implicitly available as output properties. Additionally, the HttpApi resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing HttpApi Resource

Get an existing HttpApi resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: HttpApiState, opts?: CustomResourceOptions): HttpApi
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        base_path: Optional[str] = None,
        description: Optional[str] = None,
        http_api_name: Optional[str] = None,
        protocols: Optional[Sequence[str]] = None,
        resource_group_id: Optional[str] = None,
        type: Optional[str] = None) -> HttpApi
func GetHttpApi(ctx *Context, name string, id IDInput, state *HttpApiState, opts ...ResourceOption) (*HttpApi, error)
public static HttpApi Get(string name, Input<string> id, HttpApiState? state, CustomResourceOptions? opts = null)
public static HttpApi get(String name, Output<String> id, HttpApiState state, CustomResourceOptions options)
resources:  _:    type: alicloud:apig:HttpApi    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
BasePath string
API path
Description string
Description of API
HttpApiName Changes to this property will trigger replacement. string
The name of the resource
Protocols List<string>
API protocol
ResourceGroupId string
The ID of the resource group
Type Changes to this property will trigger replacement. string
API type
BasePath string
API path
Description string
Description of API
HttpApiName Changes to this property will trigger replacement. string
The name of the resource
Protocols []string
API protocol
ResourceGroupId string
The ID of the resource group
Type Changes to this property will trigger replacement. string
API type
basePath String
API path
description String
Description of API
httpApiName Changes to this property will trigger replacement. String
The name of the resource
protocols List<String>
API protocol
resourceGroupId String
The ID of the resource group
type Changes to this property will trigger replacement. String
API type
basePath string
API path
description string
Description of API
httpApiName Changes to this property will trigger replacement. string
The name of the resource
protocols string[]
API protocol
resourceGroupId string
The ID of the resource group
type Changes to this property will trigger replacement. string
API type
base_path str
API path
description str
Description of API
http_api_name Changes to this property will trigger replacement. str
The name of the resource
protocols Sequence[str]
API protocol
resource_group_id str
The ID of the resource group
type Changes to this property will trigger replacement. str
API type
basePath String
API path
description String
Description of API
httpApiName Changes to this property will trigger replacement. String
The name of the resource
protocols List<String>
API protocol
resourceGroupId String
The ID of the resource group
type Changes to this property will trigger replacement. String
API type

Import

APIG Http Api can be imported using the id, e.g.

$ pulumi import alicloud:apig/httpApi:HttpApi example <id>
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.