gcp.endpoints.Service
Explore with Pulumi AI
This resource creates and rolls out a Cloud Endpoints service using OpenAPI or gRPC. View the relevant docs for OpenAPI and gRPC.
Example Usage
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 openapiService = new Gcp.Endpoints.Service("openapiService", new()
{
ServiceName = "api-name.endpoints.project-id.cloud.goog",
Project = "project-id",
OpenapiConfig = File.ReadAllText("openapi_spec.yml"),
});
var grpcService = new Gcp.Endpoints.Service("grpcService", new()
{
ServiceName = "api-name.endpoints.project-id.cloud.goog",
Project = "project-id",
GrpcConfig = File.ReadAllText("service_spec.yml"),
ProtocOutputBase64 = ReadFileBase64("compiled_descriptor_file.pb"),
});
});
package main
import (
"encoding/base64"
"os"
"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/endpoints"
"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 readFileOrPanic(path string) pulumi.StringPtrInput {
data, err := os.ReadFile(path)
if err != nil {
panic(err.Error())
}
return pulumi.String(string(data))
}
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := endpoints.NewService(ctx, "openapiService", &endpoints.ServiceArgs{
ServiceName: pulumi.String("api-name.endpoints.project-id.cloud.goog"),
Project: pulumi.String("project-id"),
OpenapiConfig: readFileOrPanic("openapi_spec.yml"),
})
if err != nil {
return err
}
_, err = endpoints.NewService(ctx, "grpcService", &endpoints.ServiceArgs{
ServiceName: pulumi.String("api-name.endpoints.project-id.cloud.goog"),
Project: pulumi.String("project-id"),
GrpcConfig: readFileOrPanic("service_spec.yml"),
ProtocOutputBase64: filebase64OrPanic("compiled_descriptor_file.pb"),
})
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.endpoints.Service;
import com.pulumi.gcp.endpoints.ServiceArgs;
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 openapiService = new Service("openapiService", ServiceArgs.builder()
.serviceName("api-name.endpoints.project-id.cloud.goog")
.project("project-id")
.openapiConfig(Files.readString(Paths.get("openapi_spec.yml")))
.build());
var grpcService = new Service("grpcService", ServiceArgs.builder()
.serviceName("api-name.endpoints.project-id.cloud.goog")
.project("project-id")
.grpcConfig(Files.readString(Paths.get("service_spec.yml")))
.protocOutputBase64(Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get("compiled_descriptor_file.pb"))))
.build());
}
}
import pulumi
import base64
import pulumi_gcp as gcp
openapi_service = gcp.endpoints.Service("openapiService",
service_name="api-name.endpoints.project-id.cloud.goog",
project="project-id",
openapi_config=(lambda path: open(path).read())("openapi_spec.yml"))
grpc_service = gcp.endpoints.Service("grpcService",
service_name="api-name.endpoints.project-id.cloud.goog",
project="project-id",
grpc_config=(lambda path: open(path).read())("service_spec.yml"),
protoc_output_base64=(lambda path: base64.b64encode(open(path).read().encode()).decode())("compiled_descriptor_file.pb"))
import * as pulumi from "@pulumi/pulumi";
import * as fs from "fs";
import * as gcp from "@pulumi/gcp";
const openapiService = new gcp.endpoints.Service("openapiService", {
serviceName: "api-name.endpoints.project-id.cloud.goog",
project: "project-id",
openapiConfig: fs.readFileSync("openapi_spec.yml"),
});
const grpcService = new gcp.endpoints.Service("grpcService", {
serviceName: "api-name.endpoints.project-id.cloud.goog",
project: "project-id",
grpcConfig: fs.readFileSync("service_spec.yml"),
protocOutputBase64: Buffer.from(fs.readFileSync("compiled_descriptor_file.pb"), 'binary').toString('base64'),
});
Coming soon!
Create Service Resource
new Service(name: string, args: ServiceArgs, opts?: CustomResourceOptions);
@overload
def Service(resource_name: str,
opts: Optional[ResourceOptions] = None,
grpc_config: Optional[str] = None,
openapi_config: Optional[str] = None,
project: Optional[str] = None,
protoc_output_base64: Optional[str] = None,
service_name: Optional[str] = None)
@overload
def Service(resource_name: str,
args: ServiceArgs,
opts: Optional[ResourceOptions] = None)
func NewService(ctx *Context, name string, args ServiceArgs, opts ...ResourceOption) (*Service, error)
public Service(string name, ServiceArgs args, CustomResourceOptions? opts = null)
public Service(String name, ServiceArgs args)
public Service(String name, ServiceArgs args, CustomResourceOptions options)
type: gcp:endpoints:Service
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ServiceArgs
- 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 ServiceArgs
- 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 ServiceArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ServiceArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ServiceArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Service 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 Service resource accepts the following input properties:
- Service
Name string The name of the service. Usually of the form
$apiname.endpoints.$projectid.cloud.goog
.- Grpc
Config string The full text of the Service Config YAML file (Example located here). If provided, must also provide
protoc_output_base64
.open_api
config must not be provided.- Openapi
Config string The full text of the OpenAPI YAML configuration as described here. Either this, or both of
grpc_config
andprotoc_output_base64
must be specified.- Project string
The project ID that the service belongs to. If not provided, provider project is used.
- Protoc
Output stringBase64 The full contents of the Service Descriptor File generated by protoc. This should be a compiled .pb file, base64-encoded.
- Service
Name string The name of the service. Usually of the form
$apiname.endpoints.$projectid.cloud.goog
.- Grpc
Config string The full text of the Service Config YAML file (Example located here). If provided, must also provide
protoc_output_base64
.open_api
config must not be provided.- Openapi
Config string The full text of the OpenAPI YAML configuration as described here. Either this, or both of
grpc_config
andprotoc_output_base64
must be specified.- Project string
The project ID that the service belongs to. If not provided, provider project is used.
- Protoc
Output stringBase64 The full contents of the Service Descriptor File generated by protoc. This should be a compiled .pb file, base64-encoded.
- service
Name String The name of the service. Usually of the form
$apiname.endpoints.$projectid.cloud.goog
.- grpc
Config String The full text of the Service Config YAML file (Example located here). If provided, must also provide
protoc_output_base64
.open_api
config must not be provided.- openapi
Config String The full text of the OpenAPI YAML configuration as described here. Either this, or both of
grpc_config
andprotoc_output_base64
must be specified.- project String
The project ID that the service belongs to. If not provided, provider project is used.
- protoc
Output StringBase64 The full contents of the Service Descriptor File generated by protoc. This should be a compiled .pb file, base64-encoded.
- service
Name string The name of the service. Usually of the form
$apiname.endpoints.$projectid.cloud.goog
.- grpc
Config string The full text of the Service Config YAML file (Example located here). If provided, must also provide
protoc_output_base64
.open_api
config must not be provided.- openapi
Config string The full text of the OpenAPI YAML configuration as described here. Either this, or both of
grpc_config
andprotoc_output_base64
must be specified.- project string
The project ID that the service belongs to. If not provided, provider project is used.
- protoc
Output stringBase64 The full contents of the Service Descriptor File generated by protoc. This should be a compiled .pb file, base64-encoded.
- service_
name str The name of the service. Usually of the form
$apiname.endpoints.$projectid.cloud.goog
.- grpc_
config str The full text of the Service Config YAML file (Example located here). If provided, must also provide
protoc_output_base64
.open_api
config must not be provided.- openapi_
config str The full text of the OpenAPI YAML configuration as described here. Either this, or both of
grpc_config
andprotoc_output_base64
must be specified.- project str
The project ID that the service belongs to. If not provided, provider project is used.
- protoc_
output_ strbase64 The full contents of the Service Descriptor File generated by protoc. This should be a compiled .pb file, base64-encoded.
- service
Name String The name of the service. Usually of the form
$apiname.endpoints.$projectid.cloud.goog
.- grpc
Config String The full text of the Service Config YAML file (Example located here). If provided, must also provide
protoc_output_base64
.open_api
config must not be provided.- openapi
Config String The full text of the OpenAPI YAML configuration as described here. Either this, or both of
grpc_config
andprotoc_output_base64
must be specified.- project String
The project ID that the service belongs to. If not provided, provider project is used.
- protoc
Output StringBase64 The full contents of the Service Descriptor File generated by protoc. This should be a compiled .pb file, base64-encoded.
Outputs
All input properties are implicitly available as output properties. Additionally, the Service resource produces the following output properties:
- Apis
List<Service
Api> A list of API objects; structure is documented below.
- Config
Id string The autogenerated ID for the configuration that is rolled out as part of the creation of this resource. Must be provided to compute engine instances as a tag.
- Dns
Address string The address at which the service can be found - usually the same as the service name.
- Endpoints
List<Service
Endpoint> A list of Endpoint objects; structure is documented below.
- Id string
The provider-assigned unique ID for this managed resource.
- Apis
[]Service
Api A list of API objects; structure is documented below.
- Config
Id string The autogenerated ID for the configuration that is rolled out as part of the creation of this resource. Must be provided to compute engine instances as a tag.
- Dns
Address string The address at which the service can be found - usually the same as the service name.
- Endpoints
[]Service
Endpoint A list of Endpoint objects; structure is documented below.
- Id string
The provider-assigned unique ID for this managed resource.
- apis
List<Service
Api> A list of API objects; structure is documented below.
- config
Id String The autogenerated ID for the configuration that is rolled out as part of the creation of this resource. Must be provided to compute engine instances as a tag.
- dns
Address String The address at which the service can be found - usually the same as the service name.
- endpoints
List<Service
Endpoint> A list of Endpoint objects; structure is documented below.
- id String
The provider-assigned unique ID for this managed resource.
- apis
Service
Api[] A list of API objects; structure is documented below.
- config
Id string The autogenerated ID for the configuration that is rolled out as part of the creation of this resource. Must be provided to compute engine instances as a tag.
- dns
Address string The address at which the service can be found - usually the same as the service name.
- endpoints
Service
Endpoint[] A list of Endpoint objects; structure is documented below.
- id string
The provider-assigned unique ID for this managed resource.
- apis
Sequence[Service
Api] A list of API objects; structure is documented below.
- config_
id str The autogenerated ID for the configuration that is rolled out as part of the creation of this resource. Must be provided to compute engine instances as a tag.
- dns_
address str The address at which the service can be found - usually the same as the service name.
- endpoints
Sequence[Service
Endpoint] A list of Endpoint objects; structure is documented below.
- id str
The provider-assigned unique ID for this managed resource.
- apis List<Property Map>
A list of API objects; structure is documented below.
- config
Id String The autogenerated ID for the configuration that is rolled out as part of the creation of this resource. Must be provided to compute engine instances as a tag.
- dns
Address String The address at which the service can be found - usually the same as the service name.
- endpoints List<Property Map>
A list of Endpoint objects; structure is documented below.
- id String
The provider-assigned unique ID for this managed resource.
Look up Existing Service Resource
Get an existing Service 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?: ServiceState, opts?: CustomResourceOptions): Service
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
apis: Optional[Sequence[ServiceApiArgs]] = None,
config_id: Optional[str] = None,
dns_address: Optional[str] = None,
endpoints: Optional[Sequence[ServiceEndpointArgs]] = None,
grpc_config: Optional[str] = None,
openapi_config: Optional[str] = None,
project: Optional[str] = None,
protoc_output_base64: Optional[str] = None,
service_name: Optional[str] = None) -> Service
func GetService(ctx *Context, name string, id IDInput, state *ServiceState, opts ...ResourceOption) (*Service, error)
public static Service Get(string name, Input<string> id, ServiceState? state, CustomResourceOptions? opts = null)
public static Service get(String name, Output<String> id, ServiceState 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.
- Apis
List<Service
Api> A list of API objects; structure is documented below.
- Config
Id string The autogenerated ID for the configuration that is rolled out as part of the creation of this resource. Must be provided to compute engine instances as a tag.
- Dns
Address string The address at which the service can be found - usually the same as the service name.
- Endpoints
List<Service
Endpoint> A list of Endpoint objects; structure is documented below.
- Grpc
Config string The full text of the Service Config YAML file (Example located here). If provided, must also provide
protoc_output_base64
.open_api
config must not be provided.- Openapi
Config string The full text of the OpenAPI YAML configuration as described here. Either this, or both of
grpc_config
andprotoc_output_base64
must be specified.- Project string
The project ID that the service belongs to. If not provided, provider project is used.
- Protoc
Output stringBase64 The full contents of the Service Descriptor File generated by protoc. This should be a compiled .pb file, base64-encoded.
- Service
Name string The name of the service. Usually of the form
$apiname.endpoints.$projectid.cloud.goog
.
- Apis
[]Service
Api Args A list of API objects; structure is documented below.
- Config
Id string The autogenerated ID for the configuration that is rolled out as part of the creation of this resource. Must be provided to compute engine instances as a tag.
- Dns
Address string The address at which the service can be found - usually the same as the service name.
- Endpoints
[]Service
Endpoint Args A list of Endpoint objects; structure is documented below.
- Grpc
Config string The full text of the Service Config YAML file (Example located here). If provided, must also provide
protoc_output_base64
.open_api
config must not be provided.- Openapi
Config string The full text of the OpenAPI YAML configuration as described here. Either this, or both of
grpc_config
andprotoc_output_base64
must be specified.- Project string
The project ID that the service belongs to. If not provided, provider project is used.
- Protoc
Output stringBase64 The full contents of the Service Descriptor File generated by protoc. This should be a compiled .pb file, base64-encoded.
- Service
Name string The name of the service. Usually of the form
$apiname.endpoints.$projectid.cloud.goog
.
- apis
List<Service
Api> A list of API objects; structure is documented below.
- config
Id String The autogenerated ID for the configuration that is rolled out as part of the creation of this resource. Must be provided to compute engine instances as a tag.
- dns
Address String The address at which the service can be found - usually the same as the service name.
- endpoints
List<Service
Endpoint> A list of Endpoint objects; structure is documented below.
- grpc
Config String The full text of the Service Config YAML file (Example located here). If provided, must also provide
protoc_output_base64
.open_api
config must not be provided.- openapi
Config String The full text of the OpenAPI YAML configuration as described here. Either this, or both of
grpc_config
andprotoc_output_base64
must be specified.- project String
The project ID that the service belongs to. If not provided, provider project is used.
- protoc
Output StringBase64 The full contents of the Service Descriptor File generated by protoc. This should be a compiled .pb file, base64-encoded.
- service
Name String The name of the service. Usually of the form
$apiname.endpoints.$projectid.cloud.goog
.
- apis
Service
Api[] A list of API objects; structure is documented below.
- config
Id string The autogenerated ID for the configuration that is rolled out as part of the creation of this resource. Must be provided to compute engine instances as a tag.
- dns
Address string The address at which the service can be found - usually the same as the service name.
- endpoints
Service
Endpoint[] A list of Endpoint objects; structure is documented below.
- grpc
Config string The full text of the Service Config YAML file (Example located here). If provided, must also provide
protoc_output_base64
.open_api
config must not be provided.- openapi
Config string The full text of the OpenAPI YAML configuration as described here. Either this, or both of
grpc_config
andprotoc_output_base64
must be specified.- project string
The project ID that the service belongs to. If not provided, provider project is used.
- protoc
Output stringBase64 The full contents of the Service Descriptor File generated by protoc. This should be a compiled .pb file, base64-encoded.
- service
Name string The name of the service. Usually of the form
$apiname.endpoints.$projectid.cloud.goog
.
- apis
Sequence[Service
Api Args] A list of API objects; structure is documented below.
- config_
id str The autogenerated ID for the configuration that is rolled out as part of the creation of this resource. Must be provided to compute engine instances as a tag.
- dns_
address str The address at which the service can be found - usually the same as the service name.
- endpoints
Sequence[Service
Endpoint Args] A list of Endpoint objects; structure is documented below.
- grpc_
config str The full text of the Service Config YAML file (Example located here). If provided, must also provide
protoc_output_base64
.open_api
config must not be provided.- openapi_
config str The full text of the OpenAPI YAML configuration as described here. Either this, or both of
grpc_config
andprotoc_output_base64
must be specified.- project str
The project ID that the service belongs to. If not provided, provider project is used.
- protoc_
output_ strbase64 The full contents of the Service Descriptor File generated by protoc. This should be a compiled .pb file, base64-encoded.
- service_
name str The name of the service. Usually of the form
$apiname.endpoints.$projectid.cloud.goog
.
- apis List<Property Map>
A list of API objects; structure is documented below.
- config
Id String The autogenerated ID for the configuration that is rolled out as part of the creation of this resource. Must be provided to compute engine instances as a tag.
- dns
Address String The address at which the service can be found - usually the same as the service name.
- endpoints List<Property Map>
A list of Endpoint objects; structure is documented below.
- grpc
Config String The full text of the Service Config YAML file (Example located here). If provided, must also provide
protoc_output_base64
.open_api
config must not be provided.- openapi
Config String The full text of the OpenAPI YAML configuration as described here. Either this, or both of
grpc_config
andprotoc_output_base64
must be specified.- project String
The project ID that the service belongs to. If not provided, provider project is used.
- protoc
Output StringBase64 The full contents of the Service Descriptor File generated by protoc. This should be a compiled .pb file, base64-encoded.
- service
Name String The name of the service. Usually of the form
$apiname.endpoints.$projectid.cloud.goog
.
Supporting Types
ServiceApi, ServiceApiArgs
- Methods
List<Service
Api Method> A list of Method objects; structure is documented below.
- Name string
The simple name of the endpoint as described in the config.
- Syntax string
SYNTAX_PROTO2
orSYNTAX_PROTO3
.- Version string
A version string for this api. If specified, will have the form major-version.minor-version, e.g.
1.10
.
- Methods
[]Service
Api Method A list of Method objects; structure is documented below.
- Name string
The simple name of the endpoint as described in the config.
- Syntax string
SYNTAX_PROTO2
orSYNTAX_PROTO3
.- Version string
A version string for this api. If specified, will have the form major-version.minor-version, e.g.
1.10
.
- methods
List<Service
Api Method> A list of Method objects; structure is documented below.
- name String
The simple name of the endpoint as described in the config.
- syntax String
SYNTAX_PROTO2
orSYNTAX_PROTO3
.- version String
A version string for this api. If specified, will have the form major-version.minor-version, e.g.
1.10
.
- methods
Service
Api Method[] A list of Method objects; structure is documented below.
- name string
The simple name of the endpoint as described in the config.
- syntax string
SYNTAX_PROTO2
orSYNTAX_PROTO3
.- version string
A version string for this api. If specified, will have the form major-version.minor-version, e.g.
1.10
.
- methods
Sequence[Service
Api Method] A list of Method objects; structure is documented below.
- name str
The simple name of the endpoint as described in the config.
- syntax str
SYNTAX_PROTO2
orSYNTAX_PROTO3
.- version str
A version string for this api. If specified, will have the form major-version.minor-version, e.g.
1.10
.
- methods List<Property Map>
A list of Method objects; structure is documented below.
- name String
The simple name of the endpoint as described in the config.
- syntax String
SYNTAX_PROTO2
orSYNTAX_PROTO3
.- version String
A version string for this api. If specified, will have the form major-version.minor-version, e.g.
1.10
.
ServiceApiMethod, ServiceApiMethodArgs
- Name string
The simple name of the endpoint as described in the config.
- Request
Type string The type URL for the request to this API.
- Response
Type string The type URL for the response from this API.
- Syntax string
SYNTAX_PROTO2
orSYNTAX_PROTO3
.
- Name string
The simple name of the endpoint as described in the config.
- Request
Type string The type URL for the request to this API.
- Response
Type string The type URL for the response from this API.
- Syntax string
SYNTAX_PROTO2
orSYNTAX_PROTO3
.
- name String
The simple name of the endpoint as described in the config.
- request
Type String The type URL for the request to this API.
- response
Type String The type URL for the response from this API.
- syntax String
SYNTAX_PROTO2
orSYNTAX_PROTO3
.
- name string
The simple name of the endpoint as described in the config.
- request
Type string The type URL for the request to this API.
- response
Type string The type URL for the response from this API.
- syntax string
SYNTAX_PROTO2
orSYNTAX_PROTO3
.
- name str
The simple name of the endpoint as described in the config.
- request_
type str The type URL for the request to this API.
- response_
type str The type URL for the response from this API.
- syntax str
SYNTAX_PROTO2
orSYNTAX_PROTO3
.
- name String
The simple name of the endpoint as described in the config.
- request
Type String The type URL for the request to this API.
- response
Type String The type URL for the response from this API.
- syntax String
SYNTAX_PROTO2
orSYNTAX_PROTO3
.
ServiceEndpoint, ServiceEndpointArgs
Import
This resource does not support import.
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.