gcp.apigateway.Gateway
Explore with Pulumi AI
A consumable API that can be used by multiple Gateways.
To get more information about Gateway, see:
- API documentation
- How-to Guides
Example Usage
Apigateway Gateway Basic
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
private static string ReadFileBase64(string path) {
return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(File.ReadAllText(path)));
}
return await Deployment.RunAsync(() =>
{
var apiGwApi = new Gcp.ApiGateway.Api("apiGwApi", new()
{
ApiId = "my-api",
}, new CustomResourceOptions
{
Provider = google_beta,
});
var apiGwApiConfig = new Gcp.ApiGateway.ApiConfig("apiGwApiConfig", new()
{
Api = apiGwApi.ApiId,
ApiConfigId = "my-config",
OpenapiDocuments = new[]
{
new Gcp.ApiGateway.Inputs.ApiConfigOpenapiDocumentArgs
{
Document = new Gcp.ApiGateway.Inputs.ApiConfigOpenapiDocumentDocumentArgs
{
Path = "spec.yaml",
Contents = ReadFileBase64("test-fixtures/openapi.yaml"),
},
},
},
}, new CustomResourceOptions
{
Provider = google_beta,
});
var apiGwGateway = new Gcp.ApiGateway.Gateway("apiGwGateway", new()
{
ApiConfig = apiGwApiConfig.Id,
GatewayId = "my-gateway",
}, 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("my-api"),
}, pulumi.Provider(google_beta))
if err != nil {
return err
}
apiGwApiConfig, err := apigateway.NewApiConfig(ctx, "apiGwApiConfig", &apigateway.ApiConfigArgs{
Api: apiGwApi.ApiId,
ApiConfigId: pulumi.String("my-config"),
OpenapiDocuments: apigateway.ApiConfigOpenapiDocumentArray{
&apigateway.ApiConfigOpenapiDocumentArgs{
Document: &apigateway.ApiConfigOpenapiDocumentDocumentArgs{
Path: pulumi.String("spec.yaml"),
Contents: filebase64OrPanic("test-fixtures/openapi.yaml"),
},
},
},
}, pulumi.Provider(google_beta))
if err != nil {
return err
}
_, err = apigateway.NewGateway(ctx, "apiGwGateway", &apigateway.GatewayArgs{
ApiConfig: apiGwApiConfig.ID(),
GatewayId: pulumi.String("my-gateway"),
}, 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("my-api")
.build(), CustomResourceOptions.builder()
.provider(google_beta)
.build());
var apiGwApiConfig = new ApiConfig("apiGwApiConfig", ApiConfigArgs.builder()
.api(apiGwApi.apiId())
.apiConfigId("my-config")
.openapiDocuments(ApiConfigOpenapiDocumentArgs.builder()
.document(ApiConfigOpenapiDocumentDocumentArgs.builder()
.path("spec.yaml")
.contents(Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get("test-fixtures/openapi.yaml"))))
.build())
.build())
.build(), CustomResourceOptions.builder()
.provider(google_beta)
.build());
var apiGwGateway = new Gateway("apiGwGateway", GatewayArgs.builder()
.apiConfig(apiGwApiConfig.id())
.gatewayId("my-gateway")
.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="my-api",
opts=pulumi.ResourceOptions(provider=google_beta))
api_gw_api_config = gcp.apigateway.ApiConfig("apiGwApiConfig",
api=api_gw_api.api_id,
api_config_id="my-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/openapi.yaml"),
),
)],
opts=pulumi.ResourceOptions(provider=google_beta))
api_gw_gateway = gcp.apigateway.Gateway("apiGwGateway",
api_config=api_gw_api_config.id,
gateway_id="my-gateway",
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: "my-api"}, {
provider: google_beta,
});
const apiGwApiConfig = new gcp.apigateway.ApiConfig("apiGwApiConfig", {
api: apiGwApi.apiId,
apiConfigId: "my-config",
openapiDocuments: [{
document: {
path: "spec.yaml",
contents: Buffer.from(fs.readFileSync("test-fixtures/openapi.yaml"), 'binary').toString('base64'),
},
}],
}, {
provider: google_beta,
});
const apiGwGateway = new gcp.apigateway.Gateway("apiGwGateway", {
apiConfig: apiGwApiConfig.id,
gatewayId: "my-gateway",
}, {
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:
- Api
Config 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.- Gateway
Id string Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).
- Display
Name 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.
- Api
Config 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.- Gateway
Id string Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).
- Display
Name 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.
- api
Config 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.- gateway
Id String Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).
- display
Name 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.
- api
Config 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.- gateway
Id string Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).
- display
Name 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.
- api
Config 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.- gateway
Id String Identifier to assign to the Gateway. Must be unique within scope of the parent resource(project).
- display
Name 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:
- Default
Hostname 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 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 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 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}
- default
Hostname 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.
- Api
Config 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.- Default
Hostname string The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.
- Display
Name string A user-visible name for the API.
- Gateway
Id 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.
- Api
Config 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.- Default
Hostname string The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.
- Display
Name string A user-visible name for the API.
- Gateway
Id 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.
- api
Config 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.- default
Hostname String The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.
- display
Name String A user-visible name for the API.
- gateway
Id 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.
- api
Config 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.- default
Hostname string The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.
- display
Name string A user-visible name for the API.
- gateway
Id 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.
- api
Config 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.- default
Hostname String The default API Gateway host name of the form {gatewayId}-{hash}.{region_code}.gateway.dev.
- display
Name String A user-visible name for the API.
- gateway
Id 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.