gcp logo
Google Cloud Classic v6.52.0, Mar 22 23

gcp.apigateway.Gateway

A consumable API that can be used by multiple Gateways.

To get more information about Gateway, see:

Example Usage

Apigateway Gateway Basic

using System;
using System.Collections.Generic;
using System.IO;
using Pulumi;
using Gcp = Pulumi.Gcp;

	private static string ReadFileBase64(string path) {
		return Convert.ToBase64String(Encoding.UTF8.GetBytes(File.ReadAllText(path)))
	}

return await Deployment.RunAsync(() => 
{
    var apiGwApi = new Gcp.ApiGateway.Api("apiGwApi", new()
    {
        ApiId = "api-gw",
    }, new CustomResourceOptions
    {
        Provider = google_beta,
    });

    var apiGwApiConfig = new Gcp.ApiGateway.ApiConfig("apiGwApiConfig", new()
    {
        Api = apiGwApi.ApiId,
        ApiConfigId = "config",
        OpenapiDocuments = new[]
        {
            new Gcp.ApiGateway.Inputs.ApiConfigOpenapiDocumentArgs
            {
                Document = new Gcp.ApiGateway.Inputs.ApiConfigOpenapiDocumentDocumentArgs
                {
                    Path = "spec.yaml",
                    Contents = ReadFileBase64("test-fixtures/apigateway/openapi.yaml"),
                },
            },
        },
    }, new CustomResourceOptions
    {
        Provider = google_beta,
    });

    var apiGwGateway = new Gcp.ApiGateway.Gateway("apiGwGateway", new()
    {
        ApiConfig = apiGwApiConfig.Id,
        GatewayId = "api-gw",
    }, new CustomResourceOptions
    {
        Provider = google_beta,
    });

});
package main

import (
	"encoding/base64"
	"os"

	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/apigateway"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func filebase64OrPanic(path string) pulumi.StringPtrInput {
	if fileData, err := os.ReadFile(path); err == nil {
		return pulumi.String(base64.StdEncoding.EncodeToString(fileData[:]))
	} else {
		panic(err.Error())
	}
}

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		apiGwApi, err := apigateway.NewApi(ctx, "apiGwApi", &apigateway.ApiArgs{
			ApiId: pulumi.String("api-gw"),
		}, pulumi.Provider(google_beta))
		if err != nil {
			return err
		}
		apiGwApiConfig, err := apigateway.NewApiConfig(ctx, "apiGwApiConfig", &apigateway.ApiConfigArgs{
			Api:         apiGwApi.ApiId,
			ApiConfigId: pulumi.String("config"),
			OpenapiDocuments: apigateway.ApiConfigOpenapiDocumentArray{
				&apigateway.ApiConfigOpenapiDocumentArgs{
					Document: &apigateway.ApiConfigOpenapiDocumentDocumentArgs{
						Path:     pulumi.String("spec.yaml"),
						Contents: filebase64OrPanic("test-fixtures/apigateway/openapi.yaml"),
					},
				},
			},
		}, pulumi.Provider(google_beta))
		if err != nil {
			return err
		}
		_, err = apigateway.NewGateway(ctx, "apiGwGateway", &apigateway.GatewayArgs{
			ApiConfig: apiGwApiConfig.ID(),
			GatewayId: pulumi.String("api-gw"),
		}, pulumi.Provider(google_beta))
		if err != nil {
			return err
		}
		return nil
	})
}
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 com.pulumi.gcp.apigateway.ApiConfig;
import com.pulumi.gcp.apigateway.ApiConfigArgs;
import com.pulumi.gcp.apigateway.inputs.ApiConfigOpenapiDocumentArgs;
import com.pulumi.gcp.apigateway.inputs.ApiConfigOpenapiDocumentDocumentArgs;
import com.pulumi.gcp.apigateway.Gateway;
import com.pulumi.gcp.apigateway.GatewayArgs;
import com.pulumi.resources.CustomResourceOptions;
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 apiGwApi = new Api("apiGwApi", ApiArgs.builder()        
            .apiId("api-gw")
            .build(), CustomResourceOptions.builder()
                .provider(google_beta)
                .build());

        var apiGwApiConfig = new ApiConfig("apiGwApiConfig", ApiConfigArgs.builder()        
            .api(apiGwApi.apiId())
            .apiConfigId("config")
            .openapiDocuments(ApiConfigOpenapiDocumentArgs.builder()
                .document(ApiConfigOpenapiDocumentDocumentArgs.builder()
                    .path("spec.yaml")
                    .contents(Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get("test-fixtures/apigateway/openapi.yaml"))))
                    .build())
                .build())
            .build(), CustomResourceOptions.builder()
                .provider(google_beta)
                .build());

        var apiGwGateway = new Gateway("apiGwGateway", GatewayArgs.builder()        
            .apiConfig(apiGwApiConfig.id())
            .gatewayId("api-gw")
            .build(), CustomResourceOptions.builder()
                .provider(google_beta)
                .build());

    }
}
import pulumi
import base64
import pulumi_gcp as gcp

api_gw_api = gcp.apigateway.Api("apiGwApi", api_id="api-gw",
opts=pulumi.ResourceOptions(provider=google_beta))
api_gw_api_config = gcp.apigateway.ApiConfig("apiGwApiConfig",
    api=api_gw_api.api_id,
    api_config_id="config",
    openapi_documents=[gcp.apigateway.ApiConfigOpenapiDocumentArgs(
        document=gcp.apigateway.ApiConfigOpenapiDocumentDocumentArgs(
            path="spec.yaml",
            contents=(lambda path: base64.b64encode(open(path).read().encode()).decode())("test-fixtures/apigateway/openapi.yaml"),
        ),
    )],
    opts=pulumi.ResourceOptions(provider=google_beta))
api_gw_gateway = gcp.apigateway.Gateway("apiGwGateway",
    api_config=api_gw_api_config.id,
    gateway_id="api-gw",
    opts=pulumi.ResourceOptions(provider=google_beta))
import * as pulumi from "@pulumi/pulumi";
import * as fs from "fs";
import * as gcp from "@pulumi/gcp";

const apiGwApi = new gcp.apigateway.Api("apiGwApi", {apiId: "api-gw"}, {
    provider: google_beta,
});
const apiGwApiConfig = new gcp.apigateway.ApiConfig("apiGwApiConfig", {
    api: apiGwApi.apiId,
    apiConfigId: "config",
    openapiDocuments: [{
        document: {
            path: "spec.yaml",
            contents: Buffer.from(fs.readFileSync("test-fixtures/apigateway/openapi.yaml"), 'binary').toString('base64'),
        },
    }],
}, {
    provider: google_beta,
});
const apiGwGateway = new gcp.apigateway.Gateway("apiGwGateway", {
    apiConfig: apiGwApiConfig.id,
    gatewayId: "api-gw",
}, {
    provider: google_beta,
});

Coming soon!

Create Gateway Resource

new Gateway(name: string, args: GatewayArgs, opts?: CustomResourceOptions);
@overload
def Gateway(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            api_config: Optional[str] = None,
            display_name: Optional[str] = None,
            gateway_id: Optional[str] = None,
            labels: Optional[Mapping[str, str]] = None,
            project: Optional[str] = None,
            region: Optional[str] = None)
@overload
def Gateway(resource_name: str,
            args: GatewayArgs,
            opts: Optional[ResourceOptions] = None)
func NewGateway(ctx *Context, name string, args GatewayArgs, opts ...ResourceOption) (*Gateway, error)
public Gateway(string name, GatewayArgs args, CustomResourceOptions? opts = null)
public Gateway(String name, GatewayArgs args)
public Gateway(String name, GatewayArgs args, CustomResourceOptions options)
type: gcp:apigateway:Gateway
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

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

Gateway Resource Properties

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

Inputs

The Gateway resource accepts the following input properties:

ApiConfig string

Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}. When changing api configs please ensure the new config is a new resource and the lifecycle rule create_before_destroy is set.

GatewayId string

Identifier to assign to the Gateway. 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.

Project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Region string

The region of the gateway for the API.

ApiConfig string

Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}. When changing api configs please ensure the new config is a new resource and the lifecycle rule create_before_destroy is set.

GatewayId string

Identifier to assign to the Gateway. 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.

Project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Region string

The region of the gateway for the API.

apiConfig String

Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}. When changing api configs please ensure the new config is a new resource and the lifecycle rule create_before_destroy is set.

gatewayId String

Identifier to assign to the Gateway. 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.

project String

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

region String

The region of the gateway for the API.

apiConfig string

Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}. When changing api configs please ensure the new config is a new resource and the lifecycle rule create_before_destroy is set.

gatewayId string

Identifier to assign to the Gateway. 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.

project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

region string

The region of the gateway for the API.

api_config str

Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}. When changing api configs please ensure the new config is a new resource and the lifecycle rule create_before_destroy is set.

gateway_id str

Identifier to assign to the Gateway. 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.

project str

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

region str

The region of the gateway for the API.

apiConfig String

Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}. When changing api configs please ensure the new config is a new resource and the lifecycle rule create_before_destroy is set.

gatewayId String

Identifier to assign to the Gateway. 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.

project String

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

region String

The region of the gateway for the API.

Outputs

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

DefaultHostname string

The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.

Id string

The provider-assigned unique ID for this managed resource.

Name string

Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}

DefaultHostname string

The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.

Id string

The provider-assigned unique ID for this managed resource.

Name string

Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}

defaultHostname String

The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.

id String

The provider-assigned unique ID for this managed resource.

name String

Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}

defaultHostname string

The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.

id string

The provider-assigned unique ID for this managed resource.

name string

Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}

default_hostname str

The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.

id str

The provider-assigned unique ID for this managed resource.

name str

Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}

defaultHostname String

The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.

id String

The provider-assigned unique ID for this managed resource.

name String

Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}

Look up Existing Gateway Resource

Get an existing Gateway 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?: GatewayState, opts?: CustomResourceOptions): Gateway
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        api_config: Optional[str] = None,
        default_hostname: Optional[str] = None,
        display_name: Optional[str] = None,
        gateway_id: Optional[str] = None,
        labels: Optional[Mapping[str, str]] = None,
        name: Optional[str] = None,
        project: Optional[str] = None,
        region: Optional[str] = None) -> Gateway
func GetGateway(ctx *Context, name string, id IDInput, state *GatewayState, opts ...ResourceOption) (*Gateway, error)
public static Gateway Get(string name, Input<string> id, GatewayState? state, CustomResourceOptions? opts = null)
public static Gateway get(String name, Output<String> id, GatewayState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
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
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
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
The unique name of the resulting resource.
id
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
The unique name of the resulting resource.
id
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:
ApiConfig string

Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}. When changing api configs please ensure the new config is a new resource and the lifecycle rule create_before_destroy is set.

DefaultHostname string

The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.

DisplayName string

A user-visible name for the API.

GatewayId string

Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).

Labels Dictionary<string, string>

Resource labels to represent user-provided metadata.

Name string

Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}

Project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Region string

The region of the gateway for the API.

ApiConfig string

Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}. When changing api configs please ensure the new config is a new resource and the lifecycle rule create_before_destroy is set.

DefaultHostname string

The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.

DisplayName string

A user-visible name for the API.

GatewayId string

Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).

Labels map[string]string

Resource labels to represent user-provided metadata.

Name string

Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}

Project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Region string

The region of the gateway for the API.

apiConfig String

Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}. When changing api configs please ensure the new config is a new resource and the lifecycle rule create_before_destroy is set.

defaultHostname String

The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.

displayName String

A user-visible name for the API.

gatewayId String

Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).

labels Map<String,String>

Resource labels to represent user-provided metadata.

name String

Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}

project String

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

region String

The region of the gateway for the API.

apiConfig string

Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}. When changing api configs please ensure the new config is a new resource and the lifecycle rule create_before_destroy is set.

defaultHostname string

The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.

displayName string

A user-visible name for the API.

gatewayId string

Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).

labels {[key: string]: string}

Resource labels to represent user-provided metadata.

name string

Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}

project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

region string

The region of the gateway for the API.

api_config str

Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}. When changing api configs please ensure the new config is a new resource and the lifecycle rule create_before_destroy is set.

default_hostname str

The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.

display_name str

A user-visible name for the API.

gateway_id str

Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).

labels Mapping[str, str]

Resource labels to represent user-provided metadata.

name str

Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}

project str

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

region str

The region of the gateway for the API.

apiConfig String

Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}. When changing api configs please ensure the new config is a new resource and the lifecycle rule create_before_destroy is set.

defaultHostname String

The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.

displayName String

A user-visible name for the API.

gatewayId String

Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).

labels Map<String>

Resource labels to represent user-provided metadata.

name String

Resource name of the Gateway. Format: projects/{project}/locations/{region}/gateways/{gateway}

project String

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

region String

The region of the gateway for the API.

Import

Gateway can be imported using any of these accepted formats

 $ pulumi import gcp:apigateway/gateway:Gateway default projects/{{project}}/locations/{{region}}/gateways/{{gateway_id}}
 $ pulumi import gcp:apigateway/gateway:Gateway default {{project}}/{{region}}/{{gateway_id}}
 $ pulumi import gcp:apigateway/gateway:Gateway default {{region}}/{{gateway_id}}
 $ pulumi import gcp:apigateway/gateway:Gateway default {{gateway_id}}

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.