1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. apigateway
  5. Api
Google Cloud v8.14.0 published on Wednesday, Jan 15, 2025 by Pulumi

gcp.apigateway.Api

Explore with Pulumi AI

A consumable API that can be used by multiple Gateways.

To get more information about Api, see:

Example Usage

Apigateway Api Basic

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

const api = new gcp.apigateway.Api("api", {apiId: "my-api"});
Copy
import pulumi
import pulumi_gcp as gcp

api = gcp.apigateway.Api("api", api_id="my-api")
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/apigateway"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := apigateway.NewApi(ctx, "api", &apigateway.ApiArgs{
			ApiId: pulumi.String("my-api"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var api = new Gcp.ApiGateway.Api("api", new()
    {
        ApiId = "my-api",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.apigateway.Api;
import com.pulumi.gcp.apigateway.ApiArgs;
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) {
        var api = new Api("api", ApiArgs.builder()
            .apiId("my-api")
            .build());

    }
}
Copy
resources:
  api:
    type: gcp:apigateway:Api
    properties:
      apiId: my-api
Copy

Create Api Resource

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

Constructor syntax

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

@overload
def Api(resource_name: str,
        opts: Optional[ResourceOptions] = None,
        api_id: Optional[str] = None,
        display_name: Optional[str] = None,
        labels: Optional[Mapping[str, str]] = None,
        managed_service: Optional[str] = None,
        project: Optional[str] = None)
func NewApi(ctx *Context, name string, args ApiArgs, opts ...ResourceOption) (*Api, error)
public Api(string name, ApiArgs args, CustomResourceOptions? opts = null)
public Api(String name, ApiArgs args)
public Api(String name, ApiArgs args, CustomResourceOptions options)
type: gcp:apigateway:Api
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. ApiArgs
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. ApiArgs
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. ApiArgs
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. ApiArgs
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. ApiArgs
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 apiResource = new Gcp.ApiGateway.Api("apiResource", new()
{
    ApiId = "string",
    DisplayName = "string",
    Labels = 
    {
        { "string", "string" },
    },
    ManagedService = "string",
    Project = "string",
});
Copy
example, err := apigateway.NewApi(ctx, "apiResource", &apigateway.ApiArgs{
	ApiId:       pulumi.String("string"),
	DisplayName: pulumi.String("string"),
	Labels: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	ManagedService: pulumi.String("string"),
	Project:        pulumi.String("string"),
})
Copy
var apiResource = new Api("apiResource", ApiArgs.builder()
    .apiId("string")
    .displayName("string")
    .labels(Map.of("string", "string"))
    .managedService("string")
    .project("string")
    .build());
Copy
api_resource = gcp.apigateway.Api("apiResource",
    api_id="string",
    display_name="string",
    labels={
        "string": "string",
    },
    managed_service="string",
    project="string")
Copy
const apiResource = new gcp.apigateway.Api("apiResource", {
    apiId: "string",
    displayName: "string",
    labels: {
        string: "string",
    },
    managedService: "string",
    project: "string",
});
Copy
type: gcp:apigateway:Api
properties:
    apiId: string
    displayName: string
    labels:
        string: string
    managedService: string
    project: string
Copy

Api 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 Api resource accepts the following input properties:

ApiId
This property is required.
Changes to this property will trigger replacement.
string
Identifier to assign to the API. Must be unique within scope of the parent resource(project)


DisplayName string
A user-visible name for the API.
Labels Dictionary<string, string>

Resource labels to represent user-provided metadata.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

ManagedService Changes to this property will trigger replacement. string
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
ApiId
This property is required.
Changes to this property will trigger replacement.
string
Identifier to assign to the API. Must be unique within scope of the parent resource(project)


DisplayName string
A user-visible name for the API.
Labels map[string]string

Resource labels to represent user-provided metadata.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

ManagedService Changes to this property will trigger replacement. string
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
apiId
This property is required.
Changes to this property will trigger replacement.
String
Identifier to assign to the API. Must be unique within scope of the parent resource(project)


displayName String
A user-visible name for the API.
labels Map<String,String>

Resource labels to represent user-provided metadata.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

managedService Changes to this property will trigger replacement. String
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
apiId
This property is required.
Changes to this property will trigger replacement.
string
Identifier to assign to the API. Must be unique within scope of the parent resource(project)


displayName string
A user-visible name for the API.
labels {[key: string]: string}

Resource labels to represent user-provided metadata.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

managedService Changes to this property will trigger replacement. string
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
api_id
This property is required.
Changes to this property will trigger replacement.
str
Identifier to assign to the API. Must be unique within scope of the parent resource(project)


display_name str
A user-visible name for the API.
labels Mapping[str, str]

Resource labels to represent user-provided metadata.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

managed_service Changes to this property will trigger replacement. str
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
apiId
This property is required.
Changes to this property will trigger replacement.
String
Identifier to assign to the API. Must be unique within scope of the parent resource(project)


displayName String
A user-visible name for the API.
labels Map<String>

Resource labels to represent user-provided metadata.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

managedService Changes to this property will trigger replacement. String
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Outputs

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

CreateTime string
Creation timestamp in RFC3339 text format.
EffectiveLabels Dictionary<string, string>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
Id string
The provider-assigned unique ID for this managed resource.
Name string
The resource name of the API. Format projects/{{project}}/locations/global/apis/{{apiId}}
PulumiLabels Dictionary<string, string>
The combination of labels configured directly on the resource and default labels configured on the provider.
CreateTime string
Creation timestamp in RFC3339 text format.
EffectiveLabels map[string]string
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
Id string
The provider-assigned unique ID for this managed resource.
Name string
The resource name of the API. Format projects/{{project}}/locations/global/apis/{{apiId}}
PulumiLabels map[string]string
The combination of labels configured directly on the resource and default labels configured on the provider.
createTime String
Creation timestamp in RFC3339 text format.
effectiveLabels Map<String,String>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
id String
The provider-assigned unique ID for this managed resource.
name String
The resource name of the API. Format projects/{{project}}/locations/global/apis/{{apiId}}
pulumiLabels Map<String,String>
The combination of labels configured directly on the resource and default labels configured on the provider.
createTime string
Creation timestamp in RFC3339 text format.
effectiveLabels {[key: string]: string}
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
id string
The provider-assigned unique ID for this managed resource.
name string
The resource name of the API. Format projects/{{project}}/locations/global/apis/{{apiId}}
pulumiLabels {[key: string]: string}
The combination of labels configured directly on the resource and default labels configured on the provider.
create_time str
Creation timestamp in RFC3339 text format.
effective_labels Mapping[str, str]
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
id str
The provider-assigned unique ID for this managed resource.
name str
The resource name of the API. Format projects/{{project}}/locations/global/apis/{{apiId}}
pulumi_labels Mapping[str, str]
The combination of labels configured directly on the resource and default labels configured on the provider.
createTime String
Creation timestamp in RFC3339 text format.
effectiveLabels Map<String>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
id String
The provider-assigned unique ID for this managed resource.
name String
The resource name of the API. Format projects/{{project}}/locations/global/apis/{{apiId}}
pulumiLabels Map<String>
The combination of labels configured directly on the resource and default labels configured on the provider.

Look up Existing Api Resource

Get an existing Api 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?: ApiState, opts?: CustomResourceOptions): Api
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        api_id: Optional[str] = None,
        create_time: Optional[str] = None,
        display_name: Optional[str] = None,
        effective_labels: Optional[Mapping[str, str]] = None,
        labels: Optional[Mapping[str, str]] = None,
        managed_service: Optional[str] = None,
        name: Optional[str] = None,
        project: Optional[str] = None,
        pulumi_labels: Optional[Mapping[str, str]] = None) -> Api
func GetApi(ctx *Context, name string, id IDInput, state *ApiState, opts ...ResourceOption) (*Api, error)
public static Api Get(string name, Input<string> id, ApiState? state, CustomResourceOptions? opts = null)
public static Api get(String name, Output<String> id, ApiState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
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:
ApiId Changes to this property will trigger replacement. string
Identifier to assign to the API. Must be unique within scope of the parent resource(project)


CreateTime string
Creation timestamp in RFC3339 text format.
DisplayName string
A user-visible name for the API.
EffectiveLabels Dictionary<string, string>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
Labels Dictionary<string, string>

Resource labels to represent user-provided metadata.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

ManagedService Changes to this property will trigger replacement. string
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
Name string
The resource name of the API. Format projects/{{project}}/locations/global/apis/{{apiId}}
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
PulumiLabels Dictionary<string, string>
The combination of labels configured directly on the resource and default labels configured on the provider.
ApiId Changes to this property will trigger replacement. string
Identifier to assign to the API. Must be unique within scope of the parent resource(project)


CreateTime string
Creation timestamp in RFC3339 text format.
DisplayName string
A user-visible name for the API.
EffectiveLabels map[string]string
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
Labels map[string]string

Resource labels to represent user-provided metadata.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

ManagedService Changes to this property will trigger replacement. string
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
Name string
The resource name of the API. Format projects/{{project}}/locations/global/apis/{{apiId}}
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
PulumiLabels map[string]string
The combination of labels configured directly on the resource and default labels configured on the provider.
apiId Changes to this property will trigger replacement. String
Identifier to assign to the API. Must be unique within scope of the parent resource(project)


createTime String
Creation timestamp in RFC3339 text format.
displayName String
A user-visible name for the API.
effectiveLabels Map<String,String>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
labels Map<String,String>

Resource labels to represent user-provided metadata.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

managedService Changes to this property will trigger replacement. String
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
name String
The resource name of the API. Format projects/{{project}}/locations/global/apis/{{apiId}}
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
pulumiLabels Map<String,String>
The combination of labels configured directly on the resource and default labels configured on the provider.
apiId Changes to this property will trigger replacement. string
Identifier to assign to the API. Must be unique within scope of the parent resource(project)


createTime string
Creation timestamp in RFC3339 text format.
displayName string
A user-visible name for the API.
effectiveLabels {[key: string]: string}
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
labels {[key: string]: string}

Resource labels to represent user-provided metadata.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

managedService Changes to this property will trigger replacement. string
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
name string
The resource name of the API. Format projects/{{project}}/locations/global/apis/{{apiId}}
project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
pulumiLabels {[key: string]: string}
The combination of labels configured directly on the resource and default labels configured on the provider.
api_id Changes to this property will trigger replacement. str
Identifier to assign to the API. Must be unique within scope of the parent resource(project)


create_time str
Creation timestamp in RFC3339 text format.
display_name str
A user-visible name for the API.
effective_labels Mapping[str, str]
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
labels Mapping[str, str]

Resource labels to represent user-provided metadata.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

managed_service Changes to this property will trigger replacement. str
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
name str
The resource name of the API. Format projects/{{project}}/locations/global/apis/{{apiId}}
project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
pulumi_labels Mapping[str, str]
The combination of labels configured directly on the resource and default labels configured on the provider.
apiId Changes to this property will trigger replacement. String
Identifier to assign to the API. Must be unique within scope of the parent resource(project)


createTime String
Creation timestamp in RFC3339 text format.
displayName String
A user-visible name for the API.
effectiveLabels Map<String>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
labels Map<String>

Resource labels to represent user-provided metadata.

Note: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field effective_labels for all of the labels present on the resource.

managedService Changes to this property will trigger replacement. String
Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
name String
The resource name of the API. Format projects/{{project}}/locations/global/apis/{{apiId}}
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
pulumiLabels Map<String>
The combination of labels configured directly on the resource and default labels configured on the provider.

Import

Api can be imported using any of these accepted formats:

  • projects/{{project}}/locations/global/apis/{{api_id}}

  • {{project}}/{{api_id}}

  • {{api_id}}

When using the pulumi import command, Api can be imported using one of the formats above. For example:

$ pulumi import gcp:apigateway/api:Api default projects/{{project}}/locations/global/apis/{{api_id}}
Copy
$ pulumi import gcp:apigateway/api:Api default {{project}}/{{api_id}}
Copy
$ pulumi import gcp:apigateway/api:Api default {{api_id}}
Copy

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

Package Details

Repository
Google Cloud (GCP) Classic pulumi/pulumi-gcp
License
Apache-2.0
Notes
This Pulumi package is based on the google-beta Terraform Provider.