com.pulumi.gcp.cloudrun.kotlin.ServiceArgs.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-gcp-kotlin Show documentation
Show all versions of pulumi-gcp-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.cloudrun.kotlin
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.gcp.cloudrun.ServiceArgs.builder
import com.pulumi.gcp.cloudrun.kotlin.inputs.ServiceMetadataArgs
import com.pulumi.gcp.cloudrun.kotlin.inputs.ServiceMetadataArgsBuilder
import com.pulumi.gcp.cloudrun.kotlin.inputs.ServiceTemplateArgs
import com.pulumi.gcp.cloudrun.kotlin.inputs.ServiceTemplateArgsBuilder
import com.pulumi.gcp.cloudrun.kotlin.inputs.ServiceTrafficArgs
import com.pulumi.gcp.cloudrun.kotlin.inputs.ServiceTrafficArgsBuilder
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmName
/**
* A Cloud Run service has a unique endpoint and autoscales containers.
* To get more information about Service, see:
* * [API documentation](https://cloud.google.com/run/docs/reference/rest/v1/namespaces.services)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/run/docs/)
* > **Warning:** We recommend using the `gcp.cloudrunv2.Service` resource which offers a better
* developer experience and broader support of Cloud Run features.
* ## Example Usage
* ### Cloud Run Service Pubsub
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const _default = new gcp.cloudrun.Service("default", {
* name: "cloud_run_service_name",
* location: "us-central1",
* template: {
* spec: {
* containers: [{
* image: "gcr.io/cloudrun/hello",
* }],
* },
* },
* traffics: [{
* percent: 100,
* latestRevision: true,
* }],
* });
* const sa = new gcp.serviceaccount.Account("sa", {
* accountId: "cloud-run-pubsub-invoker",
* displayName: "Cloud Run Pub/Sub Invoker",
* });
* const binding = new gcp.cloudrun.IamBinding("binding", {
* location: _default.location,
* service: _default.name,
* role: "roles/run.invoker",
* members: [pulumi.interpolate`serviceAccount:${sa.email}`],
* });
* const project = new gcp.projects.IAMBinding("project", {
* role: "roles/iam.serviceAccountTokenCreator",
* members: [pulumi.interpolate`serviceAccount:${sa.email}`],
* });
* const topic = new gcp.pubsub.Topic("topic", {name: "pubsub_topic"});
* const subscription = new gcp.pubsub.Subscription("subscription", {
* name: "pubsub_subscription",
* topic: topic.name,
* pushConfig: {
* pushEndpoint: _default.statuses.apply(statuses => statuses[0].url),
* oidcToken: {
* serviceAccountEmail: sa.email,
* },
* attributes: {
* "x-goog-version": "v1",
* },
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* default = gcp.cloudrun.Service("default",
* name="cloud_run_service_name",
* location="us-central1",
* template=gcp.cloudrun.ServiceTemplateArgs(
* spec=gcp.cloudrun.ServiceTemplateSpecArgs(
* containers=[gcp.cloudrun.ServiceTemplateSpecContainerArgs(
* image="gcr.io/cloudrun/hello",
* )],
* ),
* ),
* traffics=[gcp.cloudrun.ServiceTrafficArgs(
* percent=100,
* latest_revision=True,
* )])
* sa = gcp.serviceaccount.Account("sa",
* account_id="cloud-run-pubsub-invoker",
* display_name="Cloud Run Pub/Sub Invoker")
* binding = gcp.cloudrun.IamBinding("binding",
* location=default.location,
* service=default.name,
* role="roles/run.invoker",
* members=[sa.email.apply(lambda email: f"serviceAccount:{email}")])
* project = gcp.projects.IAMBinding("project",
* role="roles/iam.serviceAccountTokenCreator",
* members=[sa.email.apply(lambda email: f"serviceAccount:{email}")])
* topic = gcp.pubsub.Topic("topic", name="pubsub_topic")
* subscription = gcp.pubsub.Subscription("subscription",
* name="pubsub_subscription",
* topic=topic.name,
* push_config=gcp.pubsub.SubscriptionPushConfigArgs(
* push_endpoint=default.statuses[0].url,
* oidc_token=gcp.pubsub.SubscriptionPushConfigOidcTokenArgs(
* service_account_email=sa.email,
* ),
* attributes={
* "x-goog-version": "v1",
* },
* ))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var @default = new Gcp.CloudRun.Service("default", new()
* {
* Name = "cloud_run_service_name",
* Location = "us-central1",
* Template = new Gcp.CloudRun.Inputs.ServiceTemplateArgs
* {
* Spec = new Gcp.CloudRun.Inputs.ServiceTemplateSpecArgs
* {
* Containers = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerArgs
* {
* Image = "gcr.io/cloudrun/hello",
* },
* },
* },
* },
* Traffics = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTrafficArgs
* {
* Percent = 100,
* LatestRevision = true,
* },
* },
* });
* var sa = new Gcp.ServiceAccount.Account("sa", new()
* {
* AccountId = "cloud-run-pubsub-invoker",
* DisplayName = "Cloud Run Pub/Sub Invoker",
* });
* var binding = new Gcp.CloudRun.IamBinding("binding", new()
* {
* Location = @default.Location,
* Service = @default.Name,
* Role = "roles/run.invoker",
* Members = new[]
* {
* sa.Email.Apply(email => $"serviceAccount:{email}"),
* },
* });
* var project = new Gcp.Projects.IAMBinding("project", new()
* {
* Role = "roles/iam.serviceAccountTokenCreator",
* Members = new[]
* {
* sa.Email.Apply(email => $"serviceAccount:{email}"),
* },
* });
* var topic = new Gcp.PubSub.Topic("topic", new()
* {
* Name = "pubsub_topic",
* });
* var subscription = new Gcp.PubSub.Subscription("subscription", new()
* {
* Name = "pubsub_subscription",
* Topic = topic.Name,
* PushConfig = new Gcp.PubSub.Inputs.SubscriptionPushConfigArgs
* {
* PushEndpoint = @default.Statuses.Apply(statuses => statuses[0].Url),
* OidcToken = new Gcp.PubSub.Inputs.SubscriptionPushConfigOidcTokenArgs
* {
* ServiceAccountEmail = sa.Email,
* },
* Attributes =
* {
* { "x-goog-version", "v1" },
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/cloudrun"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/pubsub"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/serviceaccount"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := cloudrun.NewService(ctx, "default", &cloudrun.ServiceArgs{
* Name: pulumi.String("cloud_run_service_name"),
* Location: pulumi.String("us-central1"),
* Template: &cloudrun.ServiceTemplateArgs{
* Spec: &cloudrun.ServiceTemplateSpecArgs{
* Containers: cloudrun.ServiceTemplateSpecContainerArray{
* &cloudrun.ServiceTemplateSpecContainerArgs{
* Image: pulumi.String("gcr.io/cloudrun/hello"),
* },
* },
* },
* },
* Traffics: cloudrun.ServiceTrafficArray{
* &cloudrun.ServiceTrafficArgs{
* Percent: pulumi.Int(100),
* LatestRevision: pulumi.Bool(true),
* },
* },
* })
* if err != nil {
* return err
* }
* sa, err := serviceaccount.NewAccount(ctx, "sa", &serviceaccount.AccountArgs{
* AccountId: pulumi.String("cloud-run-pubsub-invoker"),
* DisplayName: pulumi.String("Cloud Run Pub/Sub Invoker"),
* })
* if err != nil {
* return err
* }
* _, err = cloudrun.NewIamBinding(ctx, "binding", &cloudrun.IamBindingArgs{
* Location: _default.Location,
* Service: _default.Name,
* Role: pulumi.String("roles/run.invoker"),
* Members: pulumi.StringArray{
* sa.Email.ApplyT(func(email string) (string, error) {
* return fmt.Sprintf("serviceAccount:%v", email), nil
* }).(pulumi.StringOutput),
* },
* })
* if err != nil {
* return err
* }
* _, err = projects.NewIAMBinding(ctx, "project", &projects.IAMBindingArgs{
* Role: pulumi.String("roles/iam.serviceAccountTokenCreator"),
* Members: pulumi.StringArray{
* sa.Email.ApplyT(func(email string) (string, error) {
* return fmt.Sprintf("serviceAccount:%v", email), nil
* }).(pulumi.StringOutput),
* },
* })
* if err != nil {
* return err
* }
* topic, err := pubsub.NewTopic(ctx, "topic", &pubsub.TopicArgs{
* Name: pulumi.String("pubsub_topic"),
* })
* if err != nil {
* return err
* }
* _, err = pubsub.NewSubscription(ctx, "subscription", &pubsub.SubscriptionArgs{
* Name: pulumi.String("pubsub_subscription"),
* Topic: topic.Name,
* PushConfig: &pubsub.SubscriptionPushConfigArgs{
* PushEndpoint: _default.Statuses.ApplyT(func(statuses []cloudrun.ServiceStatus) (*string, error) {
* return &statuses[0].Url, nil
* }).(pulumi.StringPtrOutput),
* OidcToken: &pubsub.SubscriptionPushConfigOidcTokenArgs{
* ServiceAccountEmail: sa.Email,
* },
* Attributes: pulumi.StringMap{
* "x-goog-version": pulumi.String("v1"),
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.cloudrun.Service;
* import com.pulumi.gcp.cloudrun.ServiceArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateSpecArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTrafficArgs;
* import com.pulumi.gcp.serviceaccount.Account;
* import com.pulumi.gcp.serviceaccount.AccountArgs;
* import com.pulumi.gcp.cloudrun.IamBinding;
* import com.pulumi.gcp.cloudrun.IamBindingArgs;
* import com.pulumi.gcp.projects.IAMBinding;
* import com.pulumi.gcp.projects.IAMBindingArgs;
* import com.pulumi.gcp.pubsub.Topic;
* import com.pulumi.gcp.pubsub.TopicArgs;
* import com.pulumi.gcp.pubsub.Subscription;
* import com.pulumi.gcp.pubsub.SubscriptionArgs;
* import com.pulumi.gcp.pubsub.inputs.SubscriptionPushConfigArgs;
* import com.pulumi.gcp.pubsub.inputs.SubscriptionPushConfigOidcTokenArgs;
* 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 default_ = new Service("default", ServiceArgs.builder()
* .name("cloud_run_service_name")
* .location("us-central1")
* .template(ServiceTemplateArgs.builder()
* .spec(ServiceTemplateSpecArgs.builder()
* .containers(ServiceTemplateSpecContainerArgs.builder()
* .image("gcr.io/cloudrun/hello")
* .build())
* .build())
* .build())
* .traffics(ServiceTrafficArgs.builder()
* .percent(100)
* .latestRevision(true)
* .build())
* .build());
* var sa = new Account("sa", AccountArgs.builder()
* .accountId("cloud-run-pubsub-invoker")
* .displayName("Cloud Run Pub/Sub Invoker")
* .build());
* var binding = new IamBinding("binding", IamBindingArgs.builder()
* .location(default_.location())
* .service(default_.name())
* .role("roles/run.invoker")
* .members(sa.email().applyValue(email -> String.format("serviceAccount:%s", email)))
* .build());
* var project = new IAMBinding("project", IAMBindingArgs.builder()
* .role("roles/iam.serviceAccountTokenCreator")
* .members(sa.email().applyValue(email -> String.format("serviceAccount:%s", email)))
* .build());
* var topic = new Topic("topic", TopicArgs.builder()
* .name("pubsub_topic")
* .build());
* var subscription = new Subscription("subscription", SubscriptionArgs.builder()
* .name("pubsub_subscription")
* .topic(topic.name())
* .pushConfig(SubscriptionPushConfigArgs.builder()
* .pushEndpoint(default_.statuses().applyValue(statuses -> statuses[0].url()))
* .oidcToken(SubscriptionPushConfigOidcTokenArgs.builder()
* .serviceAccountEmail(sa.email())
* .build())
* .attributes(Map.of("x-goog-version", "v1"))
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:cloudrun:Service
* properties:
* name: cloud_run_service_name
* location: us-central1
* template:
* spec:
* containers:
* - image: gcr.io/cloudrun/hello
* traffics:
* - percent: 100
* latestRevision: true
* sa:
* type: gcp:serviceaccount:Account
* properties:
* accountId: cloud-run-pubsub-invoker
* displayName: Cloud Run Pub/Sub Invoker
* binding:
* type: gcp:cloudrun:IamBinding
* properties:
* location: ${default.location}
* service: ${default.name}
* role: roles/run.invoker
* members:
* - serviceAccount:${sa.email}
* project:
* type: gcp:projects:IAMBinding
* properties:
* role: roles/iam.serviceAccountTokenCreator
* members:
* - serviceAccount:${sa.email}
* topic:
* type: gcp:pubsub:Topic
* properties:
* name: pubsub_topic
* subscription:
* type: gcp:pubsub:Subscription
* properties:
* name: pubsub_subscription
* topic: ${topic.name}
* pushConfig:
* pushEndpoint: ${default.statuses[0].url}
* oidcToken:
* serviceAccountEmail: ${sa.email}
* attributes:
* x-goog-version: v1
* ```
*
* ### Cloud Run Service Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const _default = new gcp.cloudrun.Service("default", {
* name: "cloudrun-srv",
* location: "us-central1",
* template: {
* spec: {
* containers: [{
* image: "us-docker.pkg.dev/cloudrun/container/hello",
* }],
* },
* },
* traffics: [{
* percent: 100,
* latestRevision: true,
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* default = gcp.cloudrun.Service("default",
* name="cloudrun-srv",
* location="us-central1",
* template=gcp.cloudrun.ServiceTemplateArgs(
* spec=gcp.cloudrun.ServiceTemplateSpecArgs(
* containers=[gcp.cloudrun.ServiceTemplateSpecContainerArgs(
* image="us-docker.pkg.dev/cloudrun/container/hello",
* )],
* ),
* ),
* traffics=[gcp.cloudrun.ServiceTrafficArgs(
* percent=100,
* latest_revision=True,
* )])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var @default = new Gcp.CloudRun.Service("default", new()
* {
* Name = "cloudrun-srv",
* Location = "us-central1",
* Template = new Gcp.CloudRun.Inputs.ServiceTemplateArgs
* {
* Spec = new Gcp.CloudRun.Inputs.ServiceTemplateSpecArgs
* {
* Containers = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerArgs
* {
* Image = "us-docker.pkg.dev/cloudrun/container/hello",
* },
* },
* },
* },
* Traffics = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTrafficArgs
* {
* Percent = 100,
* LatestRevision = true,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/cloudrun"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := cloudrun.NewService(ctx, "default", &cloudrun.ServiceArgs{
* Name: pulumi.String("cloudrun-srv"),
* Location: pulumi.String("us-central1"),
* Template: &cloudrun.ServiceTemplateArgs{
* Spec: &cloudrun.ServiceTemplateSpecArgs{
* Containers: cloudrun.ServiceTemplateSpecContainerArray{
* &cloudrun.ServiceTemplateSpecContainerArgs{
* Image: pulumi.String("us-docker.pkg.dev/cloudrun/container/hello"),
* },
* },
* },
* },
* Traffics: cloudrun.ServiceTrafficArray{
* &cloudrun.ServiceTrafficArgs{
* Percent: pulumi.Int(100),
* LatestRevision: pulumi.Bool(true),
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.cloudrun.Service;
* import com.pulumi.gcp.cloudrun.ServiceArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateSpecArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTrafficArgs;
* 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 default_ = new Service("default", ServiceArgs.builder()
* .name("cloudrun-srv")
* .location("us-central1")
* .template(ServiceTemplateArgs.builder()
* .spec(ServiceTemplateSpecArgs.builder()
* .containers(ServiceTemplateSpecContainerArgs.builder()
* .image("us-docker.pkg.dev/cloudrun/container/hello")
* .build())
* .build())
* .build())
* .traffics(ServiceTrafficArgs.builder()
* .percent(100)
* .latestRevision(true)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:cloudrun:Service
* properties:
* name: cloudrun-srv
* location: us-central1
* template:
* spec:
* containers:
* - image: us-docker.pkg.dev/cloudrun/container/hello
* traffics:
* - percent: 100
* latestRevision: true
* ```
*
* ### Cloud Run Service Sql
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const instance = new gcp.sql.DatabaseInstance("instance", {
* name: "cloudrun-sql",
* region: "us-east1",
* databaseVersion: "MYSQL_5_7",
* settings: {
* tier: "db-f1-micro",
* },
* deletionProtection: true,
* });
* const _default = new gcp.cloudrun.Service("default", {
* name: "cloudrun-srv",
* location: "us-central1",
* template: {
* spec: {
* containers: [{
* image: "us-docker.pkg.dev/cloudrun/container/hello",
* }],
* },
* metadata: {
* annotations: {
* "autoscaling.knative.dev/maxScale": "1000",
* "run.googleapis.com/cloudsql-instances": instance.connectionName,
* "run.googleapis.com/client-name": "demo",
* },
* },
* },
* autogenerateRevisionName: true,
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* instance = gcp.sql.DatabaseInstance("instance",
* name="cloudrun-sql",
* region="us-east1",
* database_version="MYSQL_5_7",
* settings=gcp.sql.DatabaseInstanceSettingsArgs(
* tier="db-f1-micro",
* ),
* deletion_protection=True)
* default = gcp.cloudrun.Service("default",
* name="cloudrun-srv",
* location="us-central1",
* template=gcp.cloudrun.ServiceTemplateArgs(
* spec=gcp.cloudrun.ServiceTemplateSpecArgs(
* containers=[gcp.cloudrun.ServiceTemplateSpecContainerArgs(
* image="us-docker.pkg.dev/cloudrun/container/hello",
* )],
* ),
* metadata=gcp.cloudrun.ServiceTemplateMetadataArgs(
* annotations={
* "autoscaling.knative.dev/maxScale": "1000",
* "run.googleapis.com/cloudsql-instances": instance.connection_name,
* "run.googleapis.com/client-name": "demo",
* },
* ),
* ),
* autogenerate_revision_name=True)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var instance = new Gcp.Sql.DatabaseInstance("instance", new()
* {
* Name = "cloudrun-sql",
* Region = "us-east1",
* DatabaseVersion = "MYSQL_5_7",
* Settings = new Gcp.Sql.Inputs.DatabaseInstanceSettingsArgs
* {
* Tier = "db-f1-micro",
* },
* DeletionProtection = true,
* });
* var @default = new Gcp.CloudRun.Service("default", new()
* {
* Name = "cloudrun-srv",
* Location = "us-central1",
* Template = new Gcp.CloudRun.Inputs.ServiceTemplateArgs
* {
* Spec = new Gcp.CloudRun.Inputs.ServiceTemplateSpecArgs
* {
* Containers = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerArgs
* {
* Image = "us-docker.pkg.dev/cloudrun/container/hello",
* },
* },
* },
* Metadata = new Gcp.CloudRun.Inputs.ServiceTemplateMetadataArgs
* {
* Annotations =
* {
* { "autoscaling.knative.dev/maxScale", "1000" },
* { "run.googleapis.com/cloudsql-instances", instance.ConnectionName },
* { "run.googleapis.com/client-name", "demo" },
* },
* },
* },
* AutogenerateRevisionName = true,
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/cloudrun"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/sql"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* instance, err := sql.NewDatabaseInstance(ctx, "instance", &sql.DatabaseInstanceArgs{
* Name: pulumi.String("cloudrun-sql"),
* Region: pulumi.String("us-east1"),
* DatabaseVersion: pulumi.String("MYSQL_5_7"),
* Settings: &sql.DatabaseInstanceSettingsArgs{
* Tier: pulumi.String("db-f1-micro"),
* },
* DeletionProtection: pulumi.Bool(true),
* })
* if err != nil {
* return err
* }
* _, err = cloudrun.NewService(ctx, "default", &cloudrun.ServiceArgs{
* Name: pulumi.String("cloudrun-srv"),
* Location: pulumi.String("us-central1"),
* Template: &cloudrun.ServiceTemplateArgs{
* Spec: &cloudrun.ServiceTemplateSpecArgs{
* Containers: cloudrun.ServiceTemplateSpecContainerArray{
* &cloudrun.ServiceTemplateSpecContainerArgs{
* Image: pulumi.String("us-docker.pkg.dev/cloudrun/container/hello"),
* },
* },
* },
* Metadata: &cloudrun.ServiceTemplateMetadataArgs{
* Annotations: pulumi.StringMap{
* "autoscaling.knative.dev/maxScale": pulumi.String("1000"),
* "run.googleapis.com/cloudsql-instances": instance.ConnectionName,
* "run.googleapis.com/client-name": pulumi.String("demo"),
* },
* },
* },
* AutogenerateRevisionName: pulumi.Bool(true),
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.sql.DatabaseInstance;
* import com.pulumi.gcp.sql.DatabaseInstanceArgs;
* import com.pulumi.gcp.sql.inputs.DatabaseInstanceSettingsArgs;
* import com.pulumi.gcp.cloudrun.Service;
* import com.pulumi.gcp.cloudrun.ServiceArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateSpecArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateMetadataArgs;
* 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 instance = new DatabaseInstance("instance", DatabaseInstanceArgs.builder()
* .name("cloudrun-sql")
* .region("us-east1")
* .databaseVersion("MYSQL_5_7")
* .settings(DatabaseInstanceSettingsArgs.builder()
* .tier("db-f1-micro")
* .build())
* .deletionProtection("true")
* .build());
* var default_ = new Service("default", ServiceArgs.builder()
* .name("cloudrun-srv")
* .location("us-central1")
* .template(ServiceTemplateArgs.builder()
* .spec(ServiceTemplateSpecArgs.builder()
* .containers(ServiceTemplateSpecContainerArgs.builder()
* .image("us-docker.pkg.dev/cloudrun/container/hello")
* .build())
* .build())
* .metadata(ServiceTemplateMetadataArgs.builder()
* .annotations(Map.ofEntries(
* Map.entry("autoscaling.knative.dev/maxScale", "1000"),
* Map.entry("run.googleapis.com/cloudsql-instances", instance.connectionName()),
* Map.entry("run.googleapis.com/client-name", "demo")
* ))
* .build())
* .build())
* .autogenerateRevisionName(true)
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:cloudrun:Service
* properties:
* name: cloudrun-srv
* location: us-central1
* template:
* spec:
* containers:
* - image: us-docker.pkg.dev/cloudrun/container/hello
* metadata:
* annotations:
* autoscaling.knative.dev/maxScale: '1000'
* run.googleapis.com/cloudsql-instances: ${instance.connectionName}
* run.googleapis.com/client-name: demo
* autogenerateRevisionName: true
* instance:
* type: gcp:sql:DatabaseInstance
* properties:
* name: cloudrun-sql
* region: us-east1
* databaseVersion: MYSQL_5_7
* settings:
* tier: db-f1-micro
* deletionProtection: 'true'
* ```
*
* ### Cloud Run Service Noauth
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const _default = new gcp.cloudrun.Service("default", {
* name: "cloudrun-srv",
* location: "us-central1",
* template: {
* spec: {
* containers: [{
* image: "us-docker.pkg.dev/cloudrun/container/hello",
* }],
* },
* },
* });
* const noauth = gcp.organizations.getIAMPolicy({
* bindings: [{
* role: "roles/run.invoker",
* members: ["allUsers"],
* }],
* });
* const noauthIamPolicy = new gcp.cloudrun.IamPolicy("noauth", {
* location: _default.location,
* project: _default.project,
* service: _default.name,
* policyData: noauth.then(noauth => noauth.policyData),
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* default = gcp.cloudrun.Service("default",
* name="cloudrun-srv",
* location="us-central1",
* template=gcp.cloudrun.ServiceTemplateArgs(
* spec=gcp.cloudrun.ServiceTemplateSpecArgs(
* containers=[gcp.cloudrun.ServiceTemplateSpecContainerArgs(
* image="us-docker.pkg.dev/cloudrun/container/hello",
* )],
* ),
* ))
* noauth = gcp.organizations.get_iam_policy(bindings=[gcp.organizations.GetIAMPolicyBindingArgs(
* role="roles/run.invoker",
* members=["allUsers"],
* )])
* noauth_iam_policy = gcp.cloudrun.IamPolicy("noauth",
* location=default.location,
* project=default.project,
* service=default.name,
* policy_data=noauth.policy_data)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var @default = new Gcp.CloudRun.Service("default", new()
* {
* Name = "cloudrun-srv",
* Location = "us-central1",
* Template = new Gcp.CloudRun.Inputs.ServiceTemplateArgs
* {
* Spec = new Gcp.CloudRun.Inputs.ServiceTemplateSpecArgs
* {
* Containers = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerArgs
* {
* Image = "us-docker.pkg.dev/cloudrun/container/hello",
* },
* },
* },
* },
* });
* var noauth = Gcp.Organizations.GetIAMPolicy.Invoke(new()
* {
* Bindings = new[]
* {
* new Gcp.Organizations.Inputs.GetIAMPolicyBindingInputArgs
* {
* Role = "roles/run.invoker",
* Members = new[]
* {
* "allUsers",
* },
* },
* },
* });
* var noauthIamPolicy = new Gcp.CloudRun.IamPolicy("noauth", new()
* {
* Location = @default.Location,
* Project = @default.Project,
* Service = @default.Name,
* PolicyData = noauth.Apply(getIAMPolicyResult => getIAMPolicyResult.PolicyData),
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/cloudrun"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := cloudrun.NewService(ctx, "default", &cloudrun.ServiceArgs{
* Name: pulumi.String("cloudrun-srv"),
* Location: pulumi.String("us-central1"),
* Template: &cloudrun.ServiceTemplateArgs{
* Spec: &cloudrun.ServiceTemplateSpecArgs{
* Containers: cloudrun.ServiceTemplateSpecContainerArray{
* &cloudrun.ServiceTemplateSpecContainerArgs{
* Image: pulumi.String("us-docker.pkg.dev/cloudrun/container/hello"),
* },
* },
* },
* },
* })
* if err != nil {
* return err
* }
* noauth, err := organizations.LookupIAMPolicy(ctx, &organizations.LookupIAMPolicyArgs{
* Bindings: []organizations.GetIAMPolicyBinding{
* {
* Role: "roles/run.invoker",
* Members: []string{
* "allUsers",
* },
* },
* },
* }, nil)
* if err != nil {
* return err
* }
* _, err = cloudrun.NewIamPolicy(ctx, "noauth", &cloudrun.IamPolicyArgs{
* Location: _default.Location,
* Project: _default.Project,
* Service: _default.Name,
* PolicyData: pulumi.String(noauth.PolicyData),
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.cloudrun.Service;
* import com.pulumi.gcp.cloudrun.ServiceArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateSpecArgs;
* import com.pulumi.gcp.organizations.OrganizationsFunctions;
* import com.pulumi.gcp.organizations.inputs.GetIAMPolicyArgs;
* import com.pulumi.gcp.cloudrun.IamPolicy;
* import com.pulumi.gcp.cloudrun.IamPolicyArgs;
* 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 default_ = new Service("default", ServiceArgs.builder()
* .name("cloudrun-srv")
* .location("us-central1")
* .template(ServiceTemplateArgs.builder()
* .spec(ServiceTemplateSpecArgs.builder()
* .containers(ServiceTemplateSpecContainerArgs.builder()
* .image("us-docker.pkg.dev/cloudrun/container/hello")
* .build())
* .build())
* .build())
* .build());
* final var noauth = OrganizationsFunctions.getIAMPolicy(GetIAMPolicyArgs.builder()
* .bindings(GetIAMPolicyBindingArgs.builder()
* .role("roles/run.invoker")
* .members("allUsers")
* .build())
* .build());
* var noauthIamPolicy = new IamPolicy("noauthIamPolicy", IamPolicyArgs.builder()
* .location(default_.location())
* .project(default_.project())
* .service(default_.name())
* .policyData(noauth.applyValue(getIAMPolicyResult -> getIAMPolicyResult.policyData()))
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:cloudrun:Service
* properties:
* name: cloudrun-srv
* location: us-central1
* template:
* spec:
* containers:
* - image: us-docker.pkg.dev/cloudrun/container/hello
* noauthIamPolicy:
* type: gcp:cloudrun:IamPolicy
* name: noauth
* properties:
* location: ${default.location}
* project: ${default.project}
* service: ${default.name}
* policyData: ${noauth.policyData}
* variables:
* noauth:
* fn::invoke:
* Function: gcp:organizations:getIAMPolicy
* Arguments:
* bindings:
* - role: roles/run.invoker
* members:
* - allUsers
* ```
*
* ### Cloud Run Service Probes
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const _default = new gcp.cloudrun.Service("default", {
* name: "cloudrun-srv",
* location: "us-central1",
* template: {
* spec: {
* containers: [{
* image: "us-docker.pkg.dev/cloudrun/container/hello",
* startupProbe: {
* initialDelaySeconds: 0,
* timeoutSeconds: 1,
* periodSeconds: 3,
* failureThreshold: 1,
* tcpSocket: {
* port: 8080,
* },
* },
* livenessProbe: {
* httpGet: {
* path: "/",
* },
* },
* }],
* },
* },
* traffics: [{
* percent: 100,
* latestRevision: true,
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* default = gcp.cloudrun.Service("default",
* name="cloudrun-srv",
* location="us-central1",
* template=gcp.cloudrun.ServiceTemplateArgs(
* spec=gcp.cloudrun.ServiceTemplateSpecArgs(
* containers=[gcp.cloudrun.ServiceTemplateSpecContainerArgs(
* image="us-docker.pkg.dev/cloudrun/container/hello",
* startup_probe=gcp.cloudrun.ServiceTemplateSpecContainerStartupProbeArgs(
* initial_delay_seconds=0,
* timeout_seconds=1,
* period_seconds=3,
* failure_threshold=1,
* tcp_socket=gcp.cloudrun.ServiceTemplateSpecContainerStartupProbeTcpSocketArgs(
* port=8080,
* ),
* ),
* liveness_probe=gcp.cloudrun.ServiceTemplateSpecContainerLivenessProbeArgs(
* http_get=gcp.cloudrun.ServiceTemplateSpecContainerLivenessProbeHttpGetArgs(
* path="/",
* ),
* ),
* )],
* ),
* ),
* traffics=[gcp.cloudrun.ServiceTrafficArgs(
* percent=100,
* latest_revision=True,
* )])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var @default = new Gcp.CloudRun.Service("default", new()
* {
* Name = "cloudrun-srv",
* Location = "us-central1",
* Template = new Gcp.CloudRun.Inputs.ServiceTemplateArgs
* {
* Spec = new Gcp.CloudRun.Inputs.ServiceTemplateSpecArgs
* {
* Containers = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerArgs
* {
* Image = "us-docker.pkg.dev/cloudrun/container/hello",
* StartupProbe = new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerStartupProbeArgs
* {
* InitialDelaySeconds = 0,
* TimeoutSeconds = 1,
* PeriodSeconds = 3,
* FailureThreshold = 1,
* TcpSocket = new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerStartupProbeTcpSocketArgs
* {
* Port = 8080,
* },
* },
* LivenessProbe = new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerLivenessProbeArgs
* {
* HttpGet = new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerLivenessProbeHttpGetArgs
* {
* Path = "/",
* },
* },
* },
* },
* },
* },
* Traffics = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTrafficArgs
* {
* Percent = 100,
* LatestRevision = true,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/cloudrun"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := cloudrun.NewService(ctx, "default", &cloudrun.ServiceArgs{
* Name: pulumi.String("cloudrun-srv"),
* Location: pulumi.String("us-central1"),
* Template: &cloudrun.ServiceTemplateArgs{
* Spec: &cloudrun.ServiceTemplateSpecArgs{
* Containers: cloudrun.ServiceTemplateSpecContainerArray{
* &cloudrun.ServiceTemplateSpecContainerArgs{
* Image: pulumi.String("us-docker.pkg.dev/cloudrun/container/hello"),
* StartupProbe: &cloudrun.ServiceTemplateSpecContainerStartupProbeArgs{
* InitialDelaySeconds: pulumi.Int(0),
* TimeoutSeconds: pulumi.Int(1),
* PeriodSeconds: pulumi.Int(3),
* FailureThreshold: pulumi.Int(1),
* TcpSocket: &cloudrun.ServiceTemplateSpecContainerStartupProbeTcpSocketArgs{
* Port: pulumi.Int(8080),
* },
* },
* LivenessProbe: &cloudrun.ServiceTemplateSpecContainerLivenessProbeArgs{
* HttpGet: &cloudrun.ServiceTemplateSpecContainerLivenessProbeHttpGetArgs{
* Path: pulumi.String("/"),
* },
* },
* },
* },
* },
* },
* Traffics: cloudrun.ServiceTrafficArray{
* &cloudrun.ServiceTrafficArgs{
* Percent: pulumi.Int(100),
* LatestRevision: pulumi.Bool(true),
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.cloudrun.Service;
* import com.pulumi.gcp.cloudrun.ServiceArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateSpecArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTrafficArgs;
* 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 default_ = new Service("default", ServiceArgs.builder()
* .name("cloudrun-srv")
* .location("us-central1")
* .template(ServiceTemplateArgs.builder()
* .spec(ServiceTemplateSpecArgs.builder()
* .containers(ServiceTemplateSpecContainerArgs.builder()
* .image("us-docker.pkg.dev/cloudrun/container/hello")
* .startupProbe(ServiceTemplateSpecContainerStartupProbeArgs.builder()
* .initialDelaySeconds(0)
* .timeoutSeconds(1)
* .periodSeconds(3)
* .failureThreshold(1)
* .tcpSocket(ServiceTemplateSpecContainerStartupProbeTcpSocketArgs.builder()
* .port(8080)
* .build())
* .build())
* .livenessProbe(ServiceTemplateSpecContainerLivenessProbeArgs.builder()
* .httpGet(ServiceTemplateSpecContainerLivenessProbeHttpGetArgs.builder()
* .path("/")
* .build())
* .build())
* .build())
* .build())
* .build())
* .traffics(ServiceTrafficArgs.builder()
* .percent(100)
* .latestRevision(true)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:cloudrun:Service
* properties:
* name: cloudrun-srv
* location: us-central1
* template:
* spec:
* containers:
* - image: us-docker.pkg.dev/cloudrun/container/hello
* startupProbe:
* initialDelaySeconds: 0
* timeoutSeconds: 1
* periodSeconds: 3
* failureThreshold: 1
* tcpSocket:
* port: 8080
* livenessProbe:
* httpGet:
* path: /
* traffics:
* - percent: 100
* latestRevision: true
* ```
*
* ### Cloud Run Service Multicontainer
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const _default = new gcp.cloudrun.Service("default", {
* name: "cloudrun-srv",
* location: "us-central1",
* metadata: {
* annotations: {
* "run.googleapis.com/launch-stage": "BETA",
* },
* },
* template: {
* metadata: {
* annotations: {
* "run.googleapis.com/container-dependencies": JSON.stringify({
* "hello-1": ["hello-2"],
* }),
* },
* },
* spec: {
* containers: [
* {
* name: "hello-1",
* ports: [{
* containerPort: 8080,
* }],
* image: "us-docker.pkg.dev/cloudrun/container/hello",
* volumeMounts: [{
* name: "shared-volume",
* mountPath: "/mnt/shared",
* }],
* },
* {
* name: "hello-2",
* image: "us-docker.pkg.dev/cloudrun/container/hello",
* envs: [{
* name: "PORT",
* value: "8081",
* }],
* startupProbe: {
* httpGet: {
* port: 8081,
* },
* },
* volumeMounts: [{
* name: "shared-volume",
* mountPath: "/mnt/shared",
* }],
* },
* ],
* volumes: [{
* name: "shared-volume",
* emptyDir: {
* medium: "Memory",
* sizeLimit: "128Mi",
* },
* }],
* },
* },
* });
* ```
* ```python
* import pulumi
* import json
* import pulumi_gcp as gcp
* default = gcp.cloudrun.Service("default",
* name="cloudrun-srv",
* location="us-central1",
* metadata=gcp.cloudrun.ServiceMetadataArgs(
* annotations={
* "run.googleapis.com/launch-stage": "BETA",
* },
* ),
* template=gcp.cloudrun.ServiceTemplateArgs(
* metadata=gcp.cloudrun.ServiceTemplateMetadataArgs(
* annotations={
* "run.googleapis.com/container-dependencies": json.dumps({
* "hello-1": ["hello-2"],
* }),
* },
* ),
* spec=gcp.cloudrun.ServiceTemplateSpecArgs(
* containers=[
* gcp.cloudrun.ServiceTemplateSpecContainerArgs(
* name="hello-1",
* ports=[gcp.cloudrun.ServiceTemplateSpecContainerPortArgs(
* container_port=8080,
* )],
* image="us-docker.pkg.dev/cloudrun/container/hello",
* volume_mounts=[gcp.cloudrun.ServiceTemplateSpecContainerVolumeMountArgs(
* name="shared-volume",
* mount_path="/mnt/shared",
* )],
* ),
* gcp.cloudrun.ServiceTemplateSpecContainerArgs(
* name="hello-2",
* image="us-docker.pkg.dev/cloudrun/container/hello",
* envs=[gcp.cloudrun.ServiceTemplateSpecContainerEnvArgs(
* name="PORT",
* value="8081",
* )],
* startup_probe=gcp.cloudrun.ServiceTemplateSpecContainerStartupProbeArgs(
* http_get=gcp.cloudrun.ServiceTemplateSpecContainerStartupProbeHttpGetArgs(
* port=8081,
* ),
* ),
* volume_mounts=[gcp.cloudrun.ServiceTemplateSpecContainerVolumeMountArgs(
* name="shared-volume",
* mount_path="/mnt/shared",
* )],
* ),
* ],
* volumes=[gcp.cloudrun.ServiceTemplateSpecVolumeArgs(
* name="shared-volume",
* empty_dir=gcp.cloudrun.ServiceTemplateSpecVolumeEmptyDirArgs(
* medium="Memory",
* size_limit="128Mi",
* ),
* )],
* ),
* ))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using System.Text.Json;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var @default = new Gcp.CloudRun.Service("default", new()
* {
* Name = "cloudrun-srv",
* Location = "us-central1",
* Metadata = new Gcp.CloudRun.Inputs.ServiceMetadataArgs
* {
* Annotations =
* {
* { "run.googleapis.com/launch-stage", "BETA" },
* },
* },
* Template = new Gcp.CloudRun.Inputs.ServiceTemplateArgs
* {
* Metadata = new Gcp.CloudRun.Inputs.ServiceTemplateMetadataArgs
* {
* Annotations =
* {
* { "run.googleapis.com/container-dependencies", JsonSerializer.Serialize(new Dictionary
* {
* ["hello-1"] = new[]
* {
* "hello-2",
* },
* }) },
* },
* },
* Spec = new Gcp.CloudRun.Inputs.ServiceTemplateSpecArgs
* {
* Containers = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerArgs
* {
* Name = "hello-1",
* Ports = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerPortArgs
* {
* ContainerPort = 8080,
* },
* },
* Image = "us-docker.pkg.dev/cloudrun/container/hello",
* VolumeMounts = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerVolumeMountArgs
* {
* Name = "shared-volume",
* MountPath = "/mnt/shared",
* },
* },
* },
* new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerArgs
* {
* Name = "hello-2",
* Image = "us-docker.pkg.dev/cloudrun/container/hello",
* Envs = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerEnvArgs
* {
* Name = "PORT",
* Value = "8081",
* },
* },
* StartupProbe = new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerStartupProbeArgs
* {
* HttpGet = new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerStartupProbeHttpGetArgs
* {
* Port = 8081,
* },
* },
* VolumeMounts = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTemplateSpecContainerVolumeMountArgs
* {
* Name = "shared-volume",
* MountPath = "/mnt/shared",
* },
* },
* },
* },
* Volumes = new[]
* {
* new Gcp.CloudRun.Inputs.ServiceTemplateSpecVolumeArgs
* {
* Name = "shared-volume",
* EmptyDir = new Gcp.CloudRun.Inputs.ServiceTemplateSpecVolumeEmptyDirArgs
* {
* Medium = "Memory",
* SizeLimit = "128Mi",
* },
* },
* },
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "encoding/json"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/cloudrun"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* tmpJSON0, err := json.Marshal(map[string]interface{}{
* "hello-1": []string{
* "hello-2",
* },
* })
* if err != nil {
* return err
* }
* json0 := string(tmpJSON0)
* _, err = cloudrun.NewService(ctx, "default", &cloudrun.ServiceArgs{
* Name: pulumi.String("cloudrun-srv"),
* Location: pulumi.String("us-central1"),
* Metadata: &cloudrun.ServiceMetadataArgs{
* Annotations: pulumi.StringMap{
* "run.googleapis.com/launch-stage": pulumi.String("BETA"),
* },
* },
* Template: &cloudrun.ServiceTemplateArgs{
* Metadata: &cloudrun.ServiceTemplateMetadataArgs{
* Annotations: pulumi.StringMap{
* "run.googleapis.com/container-dependencies": pulumi.String(json0),
* },
* },
* Spec: &cloudrun.ServiceTemplateSpecArgs{
* Containers: cloudrun.ServiceTemplateSpecContainerArray{
* &cloudrun.ServiceTemplateSpecContainerArgs{
* Name: pulumi.String("hello-1"),
* Ports: cloudrun.ServiceTemplateSpecContainerPortArray{
* &cloudrun.ServiceTemplateSpecContainerPortArgs{
* ContainerPort: pulumi.Int(8080),
* },
* },
* Image: pulumi.String("us-docker.pkg.dev/cloudrun/container/hello"),
* VolumeMounts: cloudrun.ServiceTemplateSpecContainerVolumeMountArray{
* &cloudrun.ServiceTemplateSpecContainerVolumeMountArgs{
* Name: pulumi.String("shared-volume"),
* MountPath: pulumi.String("/mnt/shared"),
* },
* },
* },
* &cloudrun.ServiceTemplateSpecContainerArgs{
* Name: pulumi.String("hello-2"),
* Image: pulumi.String("us-docker.pkg.dev/cloudrun/container/hello"),
* Envs: cloudrun.ServiceTemplateSpecContainerEnvArray{
* &cloudrun.ServiceTemplateSpecContainerEnvArgs{
* Name: pulumi.String("PORT"),
* Value: pulumi.String("8081"),
* },
* },
* StartupProbe: &cloudrun.ServiceTemplateSpecContainerStartupProbeArgs{
* HttpGet: &cloudrun.ServiceTemplateSpecContainerStartupProbeHttpGetArgs{
* Port: pulumi.Int(8081),
* },
* },
* VolumeMounts: cloudrun.ServiceTemplateSpecContainerVolumeMountArray{
* &cloudrun.ServiceTemplateSpecContainerVolumeMountArgs{
* Name: pulumi.String("shared-volume"),
* MountPath: pulumi.String("/mnt/shared"),
* },
* },
* },
* },
* Volumes: cloudrun.ServiceTemplateSpecVolumeArray{
* &cloudrun.ServiceTemplateSpecVolumeArgs{
* Name: pulumi.String("shared-volume"),
* EmptyDir: &cloudrun.ServiceTemplateSpecVolumeEmptyDirArgs{
* Medium: pulumi.String("Memory"),
* SizeLimit: pulumi.String("128Mi"),
* },
* },
* },
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.cloudrun.Service;
* import com.pulumi.gcp.cloudrun.ServiceArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceMetadataArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateMetadataArgs;
* import com.pulumi.gcp.cloudrun.inputs.ServiceTemplateSpecArgs;
* import static com.pulumi.codegen.internal.Serialization.*;
* 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 default_ = new Service("default", ServiceArgs.builder()
* .name("cloudrun-srv")
* .location("us-central1")
* .metadata(ServiceMetadataArgs.builder()
* .annotations(Map.of("run.googleapis.com/launch-stage", "BETA"))
* .build())
* .template(ServiceTemplateArgs.builder()
* .metadata(ServiceTemplateMetadataArgs.builder()
* .annotations(Map.of("run.googleapis.com/container-dependencies", serializeJson(
* jsonObject(
* jsonProperty("hello-1", jsonArray("hello-2"))
* ))))
* .build())
* .spec(ServiceTemplateSpecArgs.builder()
* .containers(
* ServiceTemplateSpecContainerArgs.builder()
* .name("hello-1")
* .ports(ServiceTemplateSpecContainerPortArgs.builder()
* .containerPort(8080)
* .build())
* .image("us-docker.pkg.dev/cloudrun/container/hello")
* .volumeMounts(ServiceTemplateSpecContainerVolumeMountArgs.builder()
* .name("shared-volume")
* .mountPath("/mnt/shared")
* .build())
* .build(),
* ServiceTemplateSpecContainerArgs.builder()
* .name("hello-2")
* .image("us-docker.pkg.dev/cloudrun/container/hello")
* .envs(ServiceTemplateSpecContainerEnvArgs.builder()
* .name("PORT")
* .value("8081")
* .build())
* .startupProbe(ServiceTemplateSpecContainerStartupProbeArgs.builder()
* .httpGet(ServiceTemplateSpecContainerStartupProbeHttpGetArgs.builder()
* .port(8081)
* .build())
* .build())
* .volumeMounts(ServiceTemplateSpecContainerVolumeMountArgs.builder()
* .name("shared-volume")
* .mountPath("/mnt/shared")
* .build())
* .build())
* .volumes(ServiceTemplateSpecVolumeArgs.builder()
* .name("shared-volume")
* .emptyDir(ServiceTemplateSpecVolumeEmptyDirArgs.builder()
* .medium("Memory")
* .sizeLimit("128Mi")
* .build())
* .build())
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:cloudrun:Service
* properties:
* name: cloudrun-srv
* location: us-central1
* metadata:
* annotations:
* run.googleapis.com/launch-stage: BETA
* template:
* metadata:
* annotations:
* run.googleapis.com/container-dependencies:
* fn::toJSON:
* hello-1:
* - hello-2
* spec:
* containers:
* - name: hello-1
* ports:
* - containerPort: 8080
* image: us-docker.pkg.dev/cloudrun/container/hello
* volumeMounts:
* - name: shared-volume
* mountPath: /mnt/shared
* - name: hello-2
* image: us-docker.pkg.dev/cloudrun/container/hello
* envs:
* - name: PORT
* value: '8081'
* startupProbe:
* httpGet:
* port: 8081
* volumeMounts:
* - name: shared-volume
* mountPath: /mnt/shared
* volumes:
* - name: shared-volume
* emptyDir:
* medium: Memory
* sizeLimit: 128Mi
* ```
*
* ## Import
* Service can be imported using any of these accepted formats:
* * `locations/{{location}}/namespaces/{{project}}/services/{{name}}`
* * `{{location}}/{{project}}/{{name}}`
* * `{{location}}/{{name}}`
* When using the `pulumi import` command, Service can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:cloudrun/service:Service default locations/{{location}}/namespaces/{{project}}/services/{{name}}
* ```
* ```sh
* $ pulumi import gcp:cloudrun/service:Service default {{location}}/{{project}}/{{name}}
* ```
* ```sh
* $ pulumi import gcp:cloudrun/service:Service default {{location}}/{{name}}
* ```
* @property autogenerateRevisionName If set to 'true', the revision name (template.metadata.name) will be omitted and autogenerated by Cloud Run. This cannot
* be set to 'true' while 'template.metadata.name' is also set. (For legacy support, if 'template.metadata.name' is unset
* in state while this field is set to false, the revision name will still autogenerate.)
* @property location The location of the cloud run instance. eg us-central1
* @property metadata Metadata associated with this Service, including name, namespace, labels, and annotations.
* @property name Name must be unique within a Google Cloud project and region.
* Is required when creating resources. Name is primarily intended
* for creation idempotence and configuration definition. Cannot be updated.
* More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
* @property project
* @property template template holds the latest specification for the Revision to be stamped out. The template references the container image,
* and may also include labels and annotations that should be attached to the Revision. To correlate a Revision, and/or to
* force a Revision to be created when the spec doesn't otherwise change, a nonce label may be provided in the template
* metadata. For more details, see:
* https://github.com/knative/serving/blob/main/docs/client-conventions.md#associate-modifications-with-revisions Cloud Run
* does not currently support referencing a build that is responsible for materializing the container image from source.
* @property traffics (Output)
* Traffic specifies how to distribute traffic over a collection of Knative Revisions
* and Configurations
* Structure is documented below.
*/
public data class ServiceArgs(
public val autogenerateRevisionName: Output? = null,
public val location: Output? = null,
public val metadata: Output? = null,
public val name: Output? = null,
public val project: Output? = null,
public val template: Output? = null,
public val traffics: Output>? = null,
) : ConvertibleToJava {
override fun toJava(): com.pulumi.gcp.cloudrun.ServiceArgs =
com.pulumi.gcp.cloudrun.ServiceArgs.builder()
.autogenerateRevisionName(autogenerateRevisionName?.applyValue({ args0 -> args0 }))
.location(location?.applyValue({ args0 -> args0 }))
.metadata(metadata?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) }))
.name(name?.applyValue({ args0 -> args0 }))
.project(project?.applyValue({ args0 -> args0 }))
.template(template?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) }))
.traffics(
traffics?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
args0.toJava()
})
})
}),
).build()
}
/**
* Builder for [ServiceArgs].
*/
@PulumiTagMarker
public class ServiceArgsBuilder internal constructor() {
private var autogenerateRevisionName: Output? = null
private var location: Output? = null
private var metadata: Output? = null
private var name: Output? = null
private var project: Output? = null
private var template: Output? = null
private var traffics: Output>? = null
/**
* @param value If set to 'true', the revision name (template.metadata.name) will be omitted and autogenerated by Cloud Run. This cannot
* be set to 'true' while 'template.metadata.name' is also set. (For legacy support, if 'template.metadata.name' is unset
* in state while this field is set to false, the revision name will still autogenerate.)
*/
@JvmName("dtbngdcwhdufeibw")
public suspend fun autogenerateRevisionName(`value`: Output) {
this.autogenerateRevisionName = value
}
/**
* @param value The location of the cloud run instance. eg us-central1
*/
@JvmName("hgcalcgthppsdsbh")
public suspend fun location(`value`: Output) {
this.location = value
}
/**
* @param value Metadata associated with this Service, including name, namespace, labels, and annotations.
*/
@JvmName("rdlaulmrijojnved")
public suspend fun metadata(`value`: Output) {
this.metadata = value
}
/**
* @param value Name must be unique within a Google Cloud project and region.
* Is required when creating resources. Name is primarily intended
* for creation idempotence and configuration definition. Cannot be updated.
* More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
*/
@JvmName("aualiydaiqpghjyn")
public suspend fun name(`value`: Output) {
this.name = value
}
/**
* @param value
*/
@JvmName("unxnnkejfxoaubrt")
public suspend fun project(`value`: Output) {
this.project = value
}
/**
* @param value template holds the latest specification for the Revision to be stamped out. The template references the container image,
* and may also include labels and annotations that should be attached to the Revision. To correlate a Revision, and/or to
* force a Revision to be created when the spec doesn't otherwise change, a nonce label may be provided in the template
* metadata. For more details, see:
* https://github.com/knative/serving/blob/main/docs/client-conventions.md#associate-modifications-with-revisions Cloud Run
* does not currently support referencing a build that is responsible for materializing the container image from source.
*/
@JvmName("dvvqbthkwxwvdevs")
public suspend fun template(`value`: Output) {
this.template = value
}
/**
* @param value (Output)
* Traffic specifies how to distribute traffic over a collection of Knative Revisions
* and Configurations
* Structure is documented below.
*/
@JvmName("roxhmnwncijegiec")
public suspend fun traffics(`value`: Output>) {
this.traffics = value
}
@JvmName("ltnwjtlidcfyrylo")
public suspend fun traffics(vararg values: Output) {
this.traffics = Output.all(values.asList())
}
/**
* @param values (Output)
* Traffic specifies how to distribute traffic over a collection of Knative Revisions
* and Configurations
* Structure is documented below.
*/
@JvmName("nhmtepcjhabpwtcc")
public suspend fun traffics(values: List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy