All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.gcp.apphub.kotlin.WorkloadArgs.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 8.12.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.apphub.kotlin

import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.gcp.apphub.WorkloadArgs.builder
import com.pulumi.gcp.apphub.kotlin.inputs.WorkloadAttributesArgs
import com.pulumi.gcp.apphub.kotlin.inputs.WorkloadAttributesArgsBuilder
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.jvm.JvmName

/**
 * Workload represents a binary deployment (such as Managed Instance Groups (MIGs), GKE deployments, etc.) that performs the smallest logical subset of business functionality. It registers identified workload to the Application.
 * ## Example Usage
 * ### Apphub Workload Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * import * as std from "@pulumi/std";
 * import * as time from "@pulumi/time";
 * const application = new gcp.apphub.Application("application", {
 *     location: "us-central1",
 *     applicationId: "example-application-1",
 *     scope: {
 *         type: "REGIONAL",
 *     },
 * });
 * const serviceProject = new gcp.organizations.Project("service_project", {
 *     projectId: "project-1",
 *     name: "Service Project",
 *     orgId: "123456789",
 *     billingAccount: "000000-0000000-0000000-000000",
 * });
 * // Enable Compute API
 * const computeServiceProject = new gcp.projects.Service("compute_service_project", {
 *     project: serviceProject.projectId,
 *     service: "compute.googleapis.com",
 * });
 * const wait120s = new time.index.Sleep("wait_120s", {createDuration: "120s"});
 * const serviceProjectAttachment = new gcp.apphub.ServiceProjectAttachment("service_project_attachment", {serviceProjectAttachmentId: serviceProject.projectId});
 * // VPC network
 * const ilbNetwork = new gcp.compute.Network("ilb_network", {
 *     name: "l7-ilb-network",
 *     project: serviceProject.projectId,
 *     autoCreateSubnetworks: false,
 * });
 * // backend subnet
 * const ilbSubnet = new gcp.compute.Subnetwork("ilb_subnet", {
 *     name: "l7-ilb-subnet",
 *     project: serviceProject.projectId,
 *     ipCidrRange: "10.0.1.0/24",
 *     region: "us-central1",
 *     network: ilbNetwork.id,
 * });
 * // instance template
 * const instanceTemplate = new gcp.compute.InstanceTemplate("instance_template", {
 *     networkInterfaces: [{
 *         accessConfigs: [{}],
 *         network: ilbNetwork.id,
 *         subnetwork: ilbSubnet.id,
 *     }],
 *     name: "l7-ilb-mig-template",
 *     project: serviceProject.projectId,
 *     machineType: "e2-small",
 *     tags: ["http-server"],
 *     disks: [{
 *         sourceImage: "debian-cloud/debian-10",
 *         autoDelete: true,
 *         boot: true,
 *     }],
 *     metadata: {
 *         "startup-script": `#! /bin/bash
 * set -euo pipefail
 * export DEBIAN_FRONTEND=noninteractive
 * apt-get update
 * apt-get install -y nginx-light jq
 * NAME=(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname")
 * IP=(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip")
 * METADATA=(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])')
 * cat < /var/www/html/index.html
 * 
 * Name: NAME
 * IP: IP
 * Metadata: METADATA
 * 
* EOF * `, * }, * }); * const mig = new gcp.compute.RegionInstanceGroupManager("mig", { * name: "l7-ilb-mig1", * project: serviceProject.projectId, * region: "us-central1", * versions: [{ * instanceTemplate: instanceTemplate.id, * name: "primary", * }], * baseInstanceName: "vm", * targetSize: 2, * }); * // Discovered workload * const catalog-workload = std.replaceOutput({ * text: mig.instanceGroup, * search: "https://www.googleapis.com/compute/v1", * replace: "//compute.googleapis.com", * }).apply(invoke => gcp.apphub.getDiscoveredWorkloadOutput({ * location: "us-central1", * workloadUri: invoke.result, * })); * const wait120sForResourceIngestion = new time.index.Sleep("wait_120s_for_resource_ingestion", {createDuration: "120s"}); * const example = new gcp.apphub.Workload("example", { * location: "us-central1", * applicationId: application.applicationId, * workloadId: mig.name, * discoveredWorkload: catalog_workload.apply(catalog_workload => catalog_workload.name), * }); * ``` * ```python * import pulumi * import pulumi_gcp as gcp * import pulumi_std as std * import pulumi_time as time * application = gcp.apphub.Application("application", * location="us-central1", * application_id="example-application-1", * scope=gcp.apphub.ApplicationScopeArgs( * type="REGIONAL", * )) * service_project = gcp.organizations.Project("service_project", * project_id="project-1", * name="Service Project", * org_id="123456789", * billing_account="000000-0000000-0000000-000000") * # Enable Compute API * compute_service_project = gcp.projects.Service("compute_service_project", * project=service_project.project_id, * service="compute.googleapis.com") * wait120s = time.index.Sleep("wait_120s", create_duration=120s) * service_project_attachment = gcp.apphub.ServiceProjectAttachment("service_project_attachment", service_project_attachment_id=service_project.project_id) * # VPC network * ilb_network = gcp.compute.Network("ilb_network", * name="l7-ilb-network", * project=service_project.project_id, * auto_create_subnetworks=False) * # backend subnet * ilb_subnet = gcp.compute.Subnetwork("ilb_subnet", * name="l7-ilb-subnet", * project=service_project.project_id, * ip_cidr_range="10.0.1.0/24", * region="us-central1", * network=ilb_network.id) * # instance template * instance_template = gcp.compute.InstanceTemplate("instance_template", * network_interfaces=[gcp.compute.InstanceTemplateNetworkInterfaceArgs( * access_configs=[gcp.compute.InstanceTemplateNetworkInterfaceAccessConfigArgs()], * network=ilb_network.id, * subnetwork=ilb_subnet.id, * )], * name="l7-ilb-mig-template", * project=service_project.project_id, * machine_type="e2-small", * tags=["http-server"], * disks=[gcp.compute.InstanceTemplateDiskArgs( * source_image="debian-cloud/debian-10", * auto_delete=True, * boot=True, * )], * metadata={ * "startup-script": """#! /bin/bash * set -euo pipefail * export DEBIAN_FRONTEND=noninteractive * apt-get update * apt-get install -y nginx-light jq * NAME=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname") * IP=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip") * METADATA=$(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])') * cat < /var/www/html/index.html *
 * Name: $NAME
 * IP: $IP
 * Metadata: $METADATA
 * 
* EOF * """, * }) * mig = gcp.compute.RegionInstanceGroupManager("mig", * name="l7-ilb-mig1", * project=service_project.project_id, * region="us-central1", * versions=[gcp.compute.RegionInstanceGroupManagerVersionArgs( * instance_template=instance_template.id, * name="primary", * )], * base_instance_name="vm", * target_size=2) * # Discovered workload * catalog_workload = std.replace_output(text=mig.instance_group, * search="https://www.googleapis.com/compute/v1", * replace="//compute.googleapis.com").apply(lambda invoke: gcp.apphub.get_discovered_workload_output(location="us-central1", * workload_uri=invoke.result)) * wait120s_for_resource_ingestion = time.index.Sleep("wait_120s_for_resource_ingestion", create_duration=120s) * example = gcp.apphub.Workload("example", * location="us-central1", * application_id=application.application_id, * workload_id=mig.name, * discovered_workload=catalog_workload.name) * ``` * ```csharp * using System.Collections.Generic; * using System.Linq; * using Pulumi; * using Gcp = Pulumi.Gcp; * using Std = Pulumi.Std; * using Time = Pulumi.Time; * return await Deployment.RunAsync(() => * { * var application = new Gcp.Apphub.Application("application", new() * { * Location = "us-central1", * ApplicationId = "example-application-1", * Scope = new Gcp.Apphub.Inputs.ApplicationScopeArgs * { * Type = "REGIONAL", * }, * }); * var serviceProject = new Gcp.Organizations.Project("service_project", new() * { * ProjectId = "project-1", * Name = "Service Project", * OrgId = "123456789", * BillingAccount = "000000-0000000-0000000-000000", * }); * // Enable Compute API * var computeServiceProject = new Gcp.Projects.Service("compute_service_project", new() * { * Project = serviceProject.ProjectId, * ServiceName = "compute.googleapis.com", * }); * var wait120s = new Time.Index.Sleep("wait_120s", new() * { * CreateDuration = "120s", * }); * var serviceProjectAttachment = new Gcp.Apphub.ServiceProjectAttachment("service_project_attachment", new() * { * ServiceProjectAttachmentId = serviceProject.ProjectId, * }); * // VPC network * var ilbNetwork = new Gcp.Compute.Network("ilb_network", new() * { * Name = "l7-ilb-network", * Project = serviceProject.ProjectId, * AutoCreateSubnetworks = false, * }); * // backend subnet * var ilbSubnet = new Gcp.Compute.Subnetwork("ilb_subnet", new() * { * Name = "l7-ilb-subnet", * Project = serviceProject.ProjectId, * IpCidrRange = "10.0.1.0/24", * Region = "us-central1", * Network = ilbNetwork.Id, * }); * // instance template * var instanceTemplate = new Gcp.Compute.InstanceTemplate("instance_template", new() * { * NetworkInterfaces = new[] * { * new Gcp.Compute.Inputs.InstanceTemplateNetworkInterfaceArgs * { * AccessConfigs = new[] * { * null, * }, * Network = ilbNetwork.Id, * Subnetwork = ilbSubnet.Id, * }, * }, * Name = "l7-ilb-mig-template", * Project = serviceProject.ProjectId, * MachineType = "e2-small", * Tags = new[] * { * "http-server", * }, * Disks = new[] * { * new Gcp.Compute.Inputs.InstanceTemplateDiskArgs * { * SourceImage = "debian-cloud/debian-10", * AutoDelete = true, * Boot = true, * }, * }, * Metadata = * { * { "startup-script", @"#! /bin/bash * set -euo pipefail * export DEBIAN_FRONTEND=noninteractive * apt-get update * apt-get install -y nginx-light jq * NAME=$(curl -H ""Metadata-Flavor: Google"" ""http://metadata.google.internal/computeMetadata/v1/instance/hostname"") * IP=$(curl -H ""Metadata-Flavor: Google"" ""http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip"") * METADATA=$(curl -f -H ""Metadata-Flavor: Google"" ""http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True"" | jq 'del(.[""startup-script""])') * cat < /var/www/html/index.html *
 * Name: $NAME
 * IP: $IP
 * Metadata: $METADATA
 * 
* EOF * " }, * }, * }); * var mig = new Gcp.Compute.RegionInstanceGroupManager("mig", new() * { * Name = "l7-ilb-mig1", * Project = serviceProject.ProjectId, * Region = "us-central1", * Versions = new[] * { * new Gcp.Compute.Inputs.RegionInstanceGroupManagerVersionArgs * { * InstanceTemplate = instanceTemplate.Id, * Name = "primary", * }, * }, * BaseInstanceName = "vm", * TargetSize = 2, * }); * // Discovered workload * var catalog_workload = Gcp.Apphub.GetDiscoveredWorkload.Invoke(new() * { * Location = "us-central1", * WorkloadUri = Std.Replace.Invoke(new() * { * Text = mig.InstanceGroup, * Search = "https://www.googleapis.com/compute/v1", * Replace = "//compute.googleapis.com", * }).Result, * }); * var wait120sForResourceIngestion = new Time.Index.Sleep("wait_120s_for_resource_ingestion", new() * { * CreateDuration = "120s", * }); * var example = new Gcp.Apphub.Workload("example", new() * { * Location = "us-central1", * ApplicationId = application.ApplicationId, * WorkloadId = mig.Name, * DiscoveredWorkload = catalog_workload.Apply(catalog_workload => catalog_workload.Apply(getDiscoveredWorkloadResult => getDiscoveredWorkloadResult.Name)), * }); * }); * ``` * ```go * package main * import ( * "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/apphub" * "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute" * "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations" * "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects" * "github.com/pulumi/pulumi-std/sdk/go/std" * "github.com/pulumi/pulumi-time/sdk/go/time" * "github.com/pulumi/pulumi/sdk/v3/go/pulumi" * ) * func main() { * pulumi.Run(func(ctx *pulumi.Context) error { * application, err := apphub.NewApplication(ctx, "application", &apphub.ApplicationArgs{ * Location: pulumi.String("us-central1"), * ApplicationId: pulumi.String("example-application-1"), * Scope: &apphub.ApplicationScopeArgs{ * Type: pulumi.String("REGIONAL"), * }, * }) * if err != nil { * return err * } * serviceProject, err := organizations.NewProject(ctx, "service_project", &organizations.ProjectArgs{ * ProjectId: pulumi.String("project-1"), * Name: pulumi.String("Service Project"), * OrgId: pulumi.String("123456789"), * BillingAccount: pulumi.String("000000-0000000-0000000-000000"), * }) * if err != nil { * return err * } * // Enable Compute API * _, err = projects.NewService(ctx, "compute_service_project", &projects.ServiceArgs{ * Project: serviceProject.ProjectId, * Service: pulumi.String("compute.googleapis.com"), * }) * if err != nil { * return err * } * _, err = time.NewSleep(ctx, "wait_120s", &time.SleepArgs{ * CreateDuration: "120s", * }) * if err != nil { * return err * } * _, err = apphub.NewServiceProjectAttachment(ctx, "service_project_attachment", &apphub.ServiceProjectAttachmentArgs{ * ServiceProjectAttachmentId: serviceProject.ProjectId, * }) * if err != nil { * return err * } * // VPC network * ilbNetwork, err := compute.NewNetwork(ctx, "ilb_network", &compute.NetworkArgs{ * Name: pulumi.String("l7-ilb-network"), * Project: serviceProject.ProjectId, * AutoCreateSubnetworks: pulumi.Bool(false), * }) * if err != nil { * return err * } * // backend subnet * ilbSubnet, err := compute.NewSubnetwork(ctx, "ilb_subnet", &compute.SubnetworkArgs{ * Name: pulumi.String("l7-ilb-subnet"), * Project: serviceProject.ProjectId, * IpCidrRange: pulumi.String("10.0.1.0/24"), * Region: pulumi.String("us-central1"), * Network: ilbNetwork.ID(), * }) * if err != nil { * return err * } * // instance template * instanceTemplate, err := compute.NewInstanceTemplate(ctx, "instance_template", &compute.InstanceTemplateArgs{ * NetworkInterfaces: compute.InstanceTemplateNetworkInterfaceArray{ * &compute.InstanceTemplateNetworkInterfaceArgs{ * AccessConfigs: compute.InstanceTemplateNetworkInterfaceAccessConfigArray{ * nil, * }, * Network: ilbNetwork.ID(), * Subnetwork: ilbSubnet.ID(), * }, * }, * Name: pulumi.String("l7-ilb-mig-template"), * Project: serviceProject.ProjectId, * MachineType: pulumi.String("e2-small"), * Tags: pulumi.StringArray{ * pulumi.String("http-server"), * }, * Disks: compute.InstanceTemplateDiskArray{ * &compute.InstanceTemplateDiskArgs{ * SourceImage: pulumi.String("debian-cloud/debian-10"), * AutoDelete: pulumi.Bool(true), * Boot: pulumi.Bool(true), * }, * }, * Metadata: pulumi.Map{ * "startup-script": pulumi.Any(`#! /bin/bash * set -euo pipefail * export DEBIAN_FRONTEND=noninteractive * apt-get update * apt-get install -y nginx-light jq * NAME=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname") * IP=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip") * METADATA=$(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])') * cat < /var/www/html/index.html *
 * Name: $NAME
 * IP: $IP
 * Metadata: $METADATA
 * 
* EOF * `), * }, * }) * if err != nil { * return err * } * mig, err := compute.NewRegionInstanceGroupManager(ctx, "mig", &compute.RegionInstanceGroupManagerArgs{ * Name: pulumi.String("l7-ilb-mig1"), * Project: serviceProject.ProjectId, * Region: pulumi.String("us-central1"), * Versions: compute.RegionInstanceGroupManagerVersionArray{ * &compute.RegionInstanceGroupManagerVersionArgs{ * InstanceTemplate: instanceTemplate.ID(), * Name: pulumi.String("primary"), * }, * }, * BaseInstanceName: pulumi.String("vm"), * TargetSize: pulumi.Int(2), * }) * if err != nil { * return err * } * // Discovered workload * catalog_workload := std.ReplaceOutput(ctx, std.ReplaceOutputArgs{ * Text: mig.InstanceGroup, * Search: pulumi.String("https://www.googleapis.com/compute/v1"), * Replace: pulumi.String("//compute.googleapis.com"), * }, nil).ApplyT(func(invoke std.ReplaceResult) (apphub.GetDiscoveredWorkloadResult, error) { * return apphub.GetDiscoveredWorkloadOutput(ctx, apphub.GetDiscoveredWorkloadOutputArgs{ * Location: "us-central1", * WorkloadUri: invoke.Result, * }, nil), nil * }).(apphub.GetDiscoveredWorkloadResultOutput) * _, err = time.NewSleep(ctx, "wait_120s_for_resource_ingestion", &time.SleepArgs{ * CreateDuration: "120s", * }) * if err != nil { * return err * } * _, err = apphub.NewWorkload(ctx, "example", &apphub.WorkloadArgs{ * Location: pulumi.String("us-central1"), * ApplicationId: application.ApplicationId, * WorkloadId: mig.Name, * DiscoveredWorkload: catalog_workload.ApplyT(func(catalog_workload apphub.GetDiscoveredWorkloadResult) (*string, error) { * return &catalog_workload.Name, nil * }).(pulumi.StringPtrOutput), * }) * 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.apphub.Application; * import com.pulumi.gcp.apphub.ApplicationArgs; * import com.pulumi.gcp.apphub.inputs.ApplicationScopeArgs; * import com.pulumi.gcp.organizations.Project; * import com.pulumi.gcp.organizations.ProjectArgs; * import com.pulumi.gcp.projects.Service; * import com.pulumi.gcp.projects.ServiceArgs; * import com.pulumi.time.sleep; * import com.pulumi.time.SleepArgs; * import com.pulumi.gcp.apphub.ServiceProjectAttachment; * import com.pulumi.gcp.apphub.ServiceProjectAttachmentArgs; * import com.pulumi.gcp.compute.Network; * import com.pulumi.gcp.compute.NetworkArgs; * import com.pulumi.gcp.compute.Subnetwork; * import com.pulumi.gcp.compute.SubnetworkArgs; * import com.pulumi.gcp.compute.InstanceTemplate; * import com.pulumi.gcp.compute.InstanceTemplateArgs; * import com.pulumi.gcp.compute.inputs.InstanceTemplateNetworkInterfaceArgs; * import com.pulumi.gcp.compute.inputs.InstanceTemplateDiskArgs; * import com.pulumi.gcp.compute.RegionInstanceGroupManager; * import com.pulumi.gcp.compute.RegionInstanceGroupManagerArgs; * import com.pulumi.gcp.compute.inputs.RegionInstanceGroupManagerVersionArgs; * import com.pulumi.gcp.apphub.ApphubFunctions; * import com.pulumi.gcp.apphub.inputs.GetDiscoveredWorkloadArgs; * import com.pulumi.gcp.apphub.Workload; * import com.pulumi.gcp.apphub.WorkloadArgs; * 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 application = new Application("application", ApplicationArgs.builder() * .location("us-central1") * .applicationId("example-application-1") * .scope(ApplicationScopeArgs.builder() * .type("REGIONAL") * .build()) * .build()); * var serviceProject = new Project("serviceProject", ProjectArgs.builder() * .projectId("project-1") * .name("Service Project") * .orgId("123456789") * .billingAccount("000000-0000000-0000000-000000") * .build()); * // Enable Compute API * var computeServiceProject = new Service("computeServiceProject", ServiceArgs.builder() * .project(serviceProject.projectId()) * .service("compute.googleapis.com") * .build()); * var wait120s = new Sleep("wait120s", SleepArgs.builder() * .createDuration("120s") * .build()); * var serviceProjectAttachment = new ServiceProjectAttachment("serviceProjectAttachment", ServiceProjectAttachmentArgs.builder() * .serviceProjectAttachmentId(serviceProject.projectId()) * .build()); * // VPC network * var ilbNetwork = new Network("ilbNetwork", NetworkArgs.builder() * .name("l7-ilb-network") * .project(serviceProject.projectId()) * .autoCreateSubnetworks(false) * .build()); * // backend subnet * var ilbSubnet = new Subnetwork("ilbSubnet", SubnetworkArgs.builder() * .name("l7-ilb-subnet") * .project(serviceProject.projectId()) * .ipCidrRange("10.0.1.0/24") * .region("us-central1") * .network(ilbNetwork.id()) * .build()); * // instance template * var instanceTemplate = new InstanceTemplate("instanceTemplate", InstanceTemplateArgs.builder() * .networkInterfaces(InstanceTemplateNetworkInterfaceArgs.builder() * .accessConfigs() * .network(ilbNetwork.id()) * .subnetwork(ilbSubnet.id()) * .build()) * .name("l7-ilb-mig-template") * .project(serviceProject.projectId()) * .machineType("e2-small") * .tags("http-server") * .disks(InstanceTemplateDiskArgs.builder() * .sourceImage("debian-cloud/debian-10") * .autoDelete(true) * .boot(true) * .build()) * .metadata(Map.of("startup-script", """ * #! /bin/bash * set -euo pipefail * export DEBIAN_FRONTEND=noninteractive * apt-get update * apt-get install -y nginx-light jq * NAME=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname") * IP=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip") * METADATA=$(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])') * cat < /var/www/html/index.html *
 * Name: $NAME
 * IP: $IP
 * Metadata: $METADATA
 * 
* EOF * """)) * .build()); * var mig = new RegionInstanceGroupManager("mig", RegionInstanceGroupManagerArgs.builder() * .name("l7-ilb-mig1") * .project(serviceProject.projectId()) * .region("us-central1") * .versions(RegionInstanceGroupManagerVersionArgs.builder() * .instanceTemplate(instanceTemplate.id()) * .name("primary") * .build()) * .baseInstanceName("vm") * .targetSize(2) * .build()); * // Discovered workload * final var catalog-workload = ApphubFunctions.getDiscoveredWorkload(GetDiscoveredWorkloadArgs.builder() * .location("us-central1") * .workloadUri(StdFunctions.replace().applyValue(invoke -> invoke.result())) * .build()); * var wait120sForResourceIngestion = new Sleep("wait120sForResourceIngestion", SleepArgs.builder() * .createDuration("120s") * .build()); * var example = new Workload("example", WorkloadArgs.builder() * .location("us-central1") * .applicationId(application.applicationId()) * .workloadId(mig.name()) * .discoveredWorkload(catalog_workload.applyValue(catalog_workload -> catalog_workload.name())) * .build()); * } * } * ``` * ```yaml * resources: * application: * type: gcp:apphub:Application * properties: * location: us-central1 * applicationId: example-application-1 * scope: * type: REGIONAL * serviceProject: * type: gcp:organizations:Project * name: service_project * properties: * projectId: project-1 * name: Service Project * orgId: '123456789' * billingAccount: 000000-0000000-0000000-000000 * # Enable Compute API * computeServiceProject: * type: gcp:projects:Service * name: compute_service_project * properties: * project: ${serviceProject.projectId} * service: compute.googleapis.com * wait120s: * type: time:sleep * name: wait_120s * properties: * createDuration: 120s * serviceProjectAttachment: * type: gcp:apphub:ServiceProjectAttachment * name: service_project_attachment * properties: * serviceProjectAttachmentId: ${serviceProject.projectId} * wait120sForResourceIngestion: * type: time:sleep * name: wait_120s_for_resource_ingestion * properties: * createDuration: 120s * example: * type: gcp:apphub:Workload * properties: * location: us-central1 * applicationId: ${application.applicationId} * workloadId: ${mig.name} * discoveredWorkload: ${["catalog-workload"].name} * # VPC network * ilbNetwork: * type: gcp:compute:Network * name: ilb_network * properties: * name: l7-ilb-network * project: ${serviceProject.projectId} * autoCreateSubnetworks: false * # backend subnet * ilbSubnet: * type: gcp:compute:Subnetwork * name: ilb_subnet * properties: * name: l7-ilb-subnet * project: ${serviceProject.projectId} * ipCidrRange: 10.0.1.0/24 * region: us-central1 * network: ${ilbNetwork.id} * # instance template * instanceTemplate: * type: gcp:compute:InstanceTemplate * name: instance_template * properties: * networkInterfaces: * - accessConfigs: * - {} * network: ${ilbNetwork.id} * subnetwork: ${ilbSubnet.id} * name: l7-ilb-mig-template * project: ${serviceProject.projectId} * machineType: e2-small * tags: * - http-server * disks: * - sourceImage: debian-cloud/debian-10 * autoDelete: true * boot: true * metadata: * startup-script: | * #! /bin/bash * set -euo pipefail * export DEBIAN_FRONTEND=noninteractive * apt-get update * apt-get install -y nginx-light jq * NAME=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname") * IP=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip") * METADATA=$(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])') * cat < /var/www/html/index.html *
 *           Name: $NAME
 *           IP: $IP
 *           Metadata: $METADATA
 *           
* EOF * mig: * type: gcp:compute:RegionInstanceGroupManager * properties: * name: l7-ilb-mig1 * project: ${serviceProject.projectId} * region: us-central1 * versions: * - instanceTemplate: ${instanceTemplate.id} * name: primary * baseInstanceName: vm * targetSize: 2 * variables: * # Discovered workload * catalog-workload: * fn::invoke: * Function: gcp:apphub:getDiscoveredWorkload * Arguments: * location: us-central1 * workloadUri: * fn::invoke: * Function: std:replace * Arguments: * text: ${mig.instanceGroup} * search: https://www.googleapis.com/compute/v1 * replace: //compute.googleapis.com * Return: result * ``` * * ### Apphub Workload Full * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as std from "@pulumi/std"; * import * as time from "@pulumi/time"; * const application = new gcp.apphub.Application("application", { * location: "us-central1", * applicationId: "example-application-1", * scope: { * type: "REGIONAL", * }, * }); * const serviceProject = new gcp.organizations.Project("service_project", { * projectId: "project-1", * name: "Service Project", * orgId: "123456789", * billingAccount: "000000-0000000-0000000-000000", * }); * // Enable Compute API * const computeServiceProject = new gcp.projects.Service("compute_service_project", { * project: serviceProject.projectId, * service: "compute.googleapis.com", * }); * const wait120s = new time.index.Sleep("wait_120s", {createDuration: "120s"}); * const serviceProjectAttachment = new gcp.apphub.ServiceProjectAttachment("service_project_attachment", {serviceProjectAttachmentId: serviceProject.projectId}); * // VPC network * const ilbNetwork = new gcp.compute.Network("ilb_network", { * name: "l7-ilb-network", * project: serviceProject.projectId, * autoCreateSubnetworks: false, * }); * // backend subnet * const ilbSubnet = new gcp.compute.Subnetwork("ilb_subnet", { * name: "l7-ilb-subnet", * project: serviceProject.projectId, * ipCidrRange: "10.0.1.0/24", * region: "us-central1", * network: ilbNetwork.id, * }); * // instance template * const instanceTemplate = new gcp.compute.InstanceTemplate("instance_template", { * networkInterfaces: [{ * accessConfigs: [{}], * network: ilbNetwork.id, * subnetwork: ilbSubnet.id, * }], * name: "l7-ilb-mig-template", * project: serviceProject.projectId, * machineType: "e2-small", * tags: ["http-server"], * disks: [{ * sourceImage: "debian-cloud/debian-10", * autoDelete: true, * boot: true, * }], * metadata: { * "startup-script": `#! /bin/bash * set -euo pipefail * export DEBIAN_FRONTEND=noninteractive * apt-get update * apt-get install -y nginx-light jq * NAME=(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname") * IP=(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip") * METADATA=(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])') * cat < /var/www/html/index.html *
 * Name: NAME
 * IP: IP
 * Metadata: METADATA
 * 
* EOF * `, * }, * }); * const mig = new gcp.compute.RegionInstanceGroupManager("mig", { * name: "l7-ilb-mig1", * project: serviceProject.projectId, * region: "us-central1", * versions: [{ * instanceTemplate: instanceTemplate.id, * name: "primary", * }], * baseInstanceName: "vm", * targetSize: 2, * }); * // Discovered workload * const catalog-workload = std.replaceOutput({ * text: mig.instanceGroup, * search: "https://www.googleapis.com/compute/v1", * replace: "//compute.googleapis.com", * }).apply(invoke => gcp.apphub.getDiscoveredWorkloadOutput({ * location: "us-central1", * workloadUri: invoke.result, * })); * const wait120sForResourceIngestion = new time.index.Sleep("wait_120s_for_resource_ingestion", {createDuration: "120s"}); * const example = new gcp.apphub.Workload("example", { * location: "us-central1", * applicationId: application.applicationId, * workloadId: mig.name, * discoveredWorkload: catalog_workload.apply(catalog_workload => catalog_workload.name), * displayName: "Example Service Full", * description: "Register service for testing", * attributes: { * environment: { * type: "STAGING", * }, * criticality: { * type: "MISSION_CRITICAL", * }, * businessOwners: [{ * displayName: "Alice", * email: "[email protected]", * }], * developerOwners: [{ * displayName: "Bob", * email: "[email protected]", * }], * operatorOwners: [{ * displayName: "Charlie", * email: "[email protected]", * }], * }, * }); * ``` * ```python * import pulumi * import pulumi_gcp as gcp * import pulumi_std as std * import pulumi_time as time * application = gcp.apphub.Application("application", * location="us-central1", * application_id="example-application-1", * scope=gcp.apphub.ApplicationScopeArgs( * type="REGIONAL", * )) * service_project = gcp.organizations.Project("service_project", * project_id="project-1", * name="Service Project", * org_id="123456789", * billing_account="000000-0000000-0000000-000000") * # Enable Compute API * compute_service_project = gcp.projects.Service("compute_service_project", * project=service_project.project_id, * service="compute.googleapis.com") * wait120s = time.index.Sleep("wait_120s", create_duration=120s) * service_project_attachment = gcp.apphub.ServiceProjectAttachment("service_project_attachment", service_project_attachment_id=service_project.project_id) * # VPC network * ilb_network = gcp.compute.Network("ilb_network", * name="l7-ilb-network", * project=service_project.project_id, * auto_create_subnetworks=False) * # backend subnet * ilb_subnet = gcp.compute.Subnetwork("ilb_subnet", * name="l7-ilb-subnet", * project=service_project.project_id, * ip_cidr_range="10.0.1.0/24", * region="us-central1", * network=ilb_network.id) * # instance template * instance_template = gcp.compute.InstanceTemplate("instance_template", * network_interfaces=[gcp.compute.InstanceTemplateNetworkInterfaceArgs( * access_configs=[gcp.compute.InstanceTemplateNetworkInterfaceAccessConfigArgs()], * network=ilb_network.id, * subnetwork=ilb_subnet.id, * )], * name="l7-ilb-mig-template", * project=service_project.project_id, * machine_type="e2-small", * tags=["http-server"], * disks=[gcp.compute.InstanceTemplateDiskArgs( * source_image="debian-cloud/debian-10", * auto_delete=True, * boot=True, * )], * metadata={ * "startup-script": """#! /bin/bash * set -euo pipefail * export DEBIAN_FRONTEND=noninteractive * apt-get update * apt-get install -y nginx-light jq * NAME=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname") * IP=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip") * METADATA=$(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])') * cat < /var/www/html/index.html *
 * Name: $NAME
 * IP: $IP
 * Metadata: $METADATA
 * 
* EOF * """, * }) * mig = gcp.compute.RegionInstanceGroupManager("mig", * name="l7-ilb-mig1", * project=service_project.project_id, * region="us-central1", * versions=[gcp.compute.RegionInstanceGroupManagerVersionArgs( * instance_template=instance_template.id, * name="primary", * )], * base_instance_name="vm", * target_size=2) * # Discovered workload * catalog_workload = std.replace_output(text=mig.instance_group, * search="https://www.googleapis.com/compute/v1", * replace="//compute.googleapis.com").apply(lambda invoke: gcp.apphub.get_discovered_workload_output(location="us-central1", * workload_uri=invoke.result)) * wait120s_for_resource_ingestion = time.index.Sleep("wait_120s_for_resource_ingestion", create_duration=120s) * example = gcp.apphub.Workload("example", * location="us-central1", * application_id=application.application_id, * workload_id=mig.name, * discovered_workload=catalog_workload.name, * display_name="Example Service Full", * description="Register service for testing", * attributes=gcp.apphub.WorkloadAttributesArgs( * environment=gcp.apphub.WorkloadAttributesEnvironmentArgs( * type="STAGING", * ), * criticality=gcp.apphub.WorkloadAttributesCriticalityArgs( * type="MISSION_CRITICAL", * ), * business_owners=[gcp.apphub.WorkloadAttributesBusinessOwnerArgs( * display_name="Alice", * email="[email protected]", * )], * developer_owners=[gcp.apphub.WorkloadAttributesDeveloperOwnerArgs( * display_name="Bob", * email="[email protected]", * )], * operator_owners=[gcp.apphub.WorkloadAttributesOperatorOwnerArgs( * display_name="Charlie", * email="[email protected]", * )], * )) * ``` * ```csharp * using System.Collections.Generic; * using System.Linq; * using Pulumi; * using Gcp = Pulumi.Gcp; * using Std = Pulumi.Std; * using Time = Pulumi.Time; * return await Deployment.RunAsync(() => * { * var application = new Gcp.Apphub.Application("application", new() * { * Location = "us-central1", * ApplicationId = "example-application-1", * Scope = new Gcp.Apphub.Inputs.ApplicationScopeArgs * { * Type = "REGIONAL", * }, * }); * var serviceProject = new Gcp.Organizations.Project("service_project", new() * { * ProjectId = "project-1", * Name = "Service Project", * OrgId = "123456789", * BillingAccount = "000000-0000000-0000000-000000", * }); * // Enable Compute API * var computeServiceProject = new Gcp.Projects.Service("compute_service_project", new() * { * Project = serviceProject.ProjectId, * ServiceName = "compute.googleapis.com", * }); * var wait120s = new Time.Index.Sleep("wait_120s", new() * { * CreateDuration = "120s", * }); * var serviceProjectAttachment = new Gcp.Apphub.ServiceProjectAttachment("service_project_attachment", new() * { * ServiceProjectAttachmentId = serviceProject.ProjectId, * }); * // VPC network * var ilbNetwork = new Gcp.Compute.Network("ilb_network", new() * { * Name = "l7-ilb-network", * Project = serviceProject.ProjectId, * AutoCreateSubnetworks = false, * }); * // backend subnet * var ilbSubnet = new Gcp.Compute.Subnetwork("ilb_subnet", new() * { * Name = "l7-ilb-subnet", * Project = serviceProject.ProjectId, * IpCidrRange = "10.0.1.0/24", * Region = "us-central1", * Network = ilbNetwork.Id, * }); * // instance template * var instanceTemplate = new Gcp.Compute.InstanceTemplate("instance_template", new() * { * NetworkInterfaces = new[] * { * new Gcp.Compute.Inputs.InstanceTemplateNetworkInterfaceArgs * { * AccessConfigs = new[] * { * null, * }, * Network = ilbNetwork.Id, * Subnetwork = ilbSubnet.Id, * }, * }, * Name = "l7-ilb-mig-template", * Project = serviceProject.ProjectId, * MachineType = "e2-small", * Tags = new[] * { * "http-server", * }, * Disks = new[] * { * new Gcp.Compute.Inputs.InstanceTemplateDiskArgs * { * SourceImage = "debian-cloud/debian-10", * AutoDelete = true, * Boot = true, * }, * }, * Metadata = * { * { "startup-script", @"#! /bin/bash * set -euo pipefail * export DEBIAN_FRONTEND=noninteractive * apt-get update * apt-get install -y nginx-light jq * NAME=$(curl -H ""Metadata-Flavor: Google"" ""http://metadata.google.internal/computeMetadata/v1/instance/hostname"") * IP=$(curl -H ""Metadata-Flavor: Google"" ""http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip"") * METADATA=$(curl -f -H ""Metadata-Flavor: Google"" ""http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True"" | jq 'del(.[""startup-script""])') * cat < /var/www/html/index.html *
 * Name: $NAME
 * IP: $IP
 * Metadata: $METADATA
 * 
* EOF * " }, * }, * }); * var mig = new Gcp.Compute.RegionInstanceGroupManager("mig", new() * { * Name = "l7-ilb-mig1", * Project = serviceProject.ProjectId, * Region = "us-central1", * Versions = new[] * { * new Gcp.Compute.Inputs.RegionInstanceGroupManagerVersionArgs * { * InstanceTemplate = instanceTemplate.Id, * Name = "primary", * }, * }, * BaseInstanceName = "vm", * TargetSize = 2, * }); * // Discovered workload * var catalog_workload = Gcp.Apphub.GetDiscoveredWorkload.Invoke(new() * { * Location = "us-central1", * WorkloadUri = Std.Replace.Invoke(new() * { * Text = mig.InstanceGroup, * Search = "https://www.googleapis.com/compute/v1", * Replace = "//compute.googleapis.com", * }).Result, * }); * var wait120sForResourceIngestion = new Time.Index.Sleep("wait_120s_for_resource_ingestion", new() * { * CreateDuration = "120s", * }); * var example = new Gcp.Apphub.Workload("example", new() * { * Location = "us-central1", * ApplicationId = application.ApplicationId, * WorkloadId = mig.Name, * DiscoveredWorkload = catalog_workload.Apply(catalog_workload => catalog_workload.Apply(getDiscoveredWorkloadResult => getDiscoveredWorkloadResult.Name)), * DisplayName = "Example Service Full", * Description = "Register service for testing", * Attributes = new Gcp.Apphub.Inputs.WorkloadAttributesArgs * { * Environment = new Gcp.Apphub.Inputs.WorkloadAttributesEnvironmentArgs * { * Type = "STAGING", * }, * Criticality = new Gcp.Apphub.Inputs.WorkloadAttributesCriticalityArgs * { * Type = "MISSION_CRITICAL", * }, * BusinessOwners = new[] * { * new Gcp.Apphub.Inputs.WorkloadAttributesBusinessOwnerArgs * { * DisplayName = "Alice", * Email = "[email protected]", * }, * }, * DeveloperOwners = new[] * { * new Gcp.Apphub.Inputs.WorkloadAttributesDeveloperOwnerArgs * { * DisplayName = "Bob", * Email = "[email protected]", * }, * }, * OperatorOwners = new[] * { * new Gcp.Apphub.Inputs.WorkloadAttributesOperatorOwnerArgs * { * DisplayName = "Charlie", * Email = "[email protected]", * }, * }, * }, * }); * }); * ``` * ```go * package main * import ( * "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/apphub" * "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute" * "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations" * "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects" * "github.com/pulumi/pulumi-std/sdk/go/std" * "github.com/pulumi/pulumi-time/sdk/go/time" * "github.com/pulumi/pulumi/sdk/v3/go/pulumi" * ) * func main() { * pulumi.Run(func(ctx *pulumi.Context) error { * application, err := apphub.NewApplication(ctx, "application", &apphub.ApplicationArgs{ * Location: pulumi.String("us-central1"), * ApplicationId: pulumi.String("example-application-1"), * Scope: &apphub.ApplicationScopeArgs{ * Type: pulumi.String("REGIONAL"), * }, * }) * if err != nil { * return err * } * serviceProject, err := organizations.NewProject(ctx, "service_project", &organizations.ProjectArgs{ * ProjectId: pulumi.String("project-1"), * Name: pulumi.String("Service Project"), * OrgId: pulumi.String("123456789"), * BillingAccount: pulumi.String("000000-0000000-0000000-000000"), * }) * if err != nil { * return err * } * // Enable Compute API * _, err = projects.NewService(ctx, "compute_service_project", &projects.ServiceArgs{ * Project: serviceProject.ProjectId, * Service: pulumi.String("compute.googleapis.com"), * }) * if err != nil { * return err * } * _, err = time.NewSleep(ctx, "wait_120s", &time.SleepArgs{ * CreateDuration: "120s", * }) * if err != nil { * return err * } * _, err = apphub.NewServiceProjectAttachment(ctx, "service_project_attachment", &apphub.ServiceProjectAttachmentArgs{ * ServiceProjectAttachmentId: serviceProject.ProjectId, * }) * if err != nil { * return err * } * // VPC network * ilbNetwork, err := compute.NewNetwork(ctx, "ilb_network", &compute.NetworkArgs{ * Name: pulumi.String("l7-ilb-network"), * Project: serviceProject.ProjectId, * AutoCreateSubnetworks: pulumi.Bool(false), * }) * if err != nil { * return err * } * // backend subnet * ilbSubnet, err := compute.NewSubnetwork(ctx, "ilb_subnet", &compute.SubnetworkArgs{ * Name: pulumi.String("l7-ilb-subnet"), * Project: serviceProject.ProjectId, * IpCidrRange: pulumi.String("10.0.1.0/24"), * Region: pulumi.String("us-central1"), * Network: ilbNetwork.ID(), * }) * if err != nil { * return err * } * // instance template * instanceTemplate, err := compute.NewInstanceTemplate(ctx, "instance_template", &compute.InstanceTemplateArgs{ * NetworkInterfaces: compute.InstanceTemplateNetworkInterfaceArray{ * &compute.InstanceTemplateNetworkInterfaceArgs{ * AccessConfigs: compute.InstanceTemplateNetworkInterfaceAccessConfigArray{ * nil, * }, * Network: ilbNetwork.ID(), * Subnetwork: ilbSubnet.ID(), * }, * }, * Name: pulumi.String("l7-ilb-mig-template"), * Project: serviceProject.ProjectId, * MachineType: pulumi.String("e2-small"), * Tags: pulumi.StringArray{ * pulumi.String("http-server"), * }, * Disks: compute.InstanceTemplateDiskArray{ * &compute.InstanceTemplateDiskArgs{ * SourceImage: pulumi.String("debian-cloud/debian-10"), * AutoDelete: pulumi.Bool(true), * Boot: pulumi.Bool(true), * }, * }, * Metadata: pulumi.Map{ * "startup-script": pulumi.Any(`#! /bin/bash * set -euo pipefail * export DEBIAN_FRONTEND=noninteractive * apt-get update * apt-get install -y nginx-light jq * NAME=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname") * IP=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip") * METADATA=$(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])') * cat < /var/www/html/index.html *
 * Name: $NAME
 * IP: $IP
 * Metadata: $METADATA
 * 
* EOF * `), * }, * }) * if err != nil { * return err * } * mig, err := compute.NewRegionInstanceGroupManager(ctx, "mig", &compute.RegionInstanceGroupManagerArgs{ * Name: pulumi.String("l7-ilb-mig1"), * Project: serviceProject.ProjectId, * Region: pulumi.String("us-central1"), * Versions: compute.RegionInstanceGroupManagerVersionArray{ * &compute.RegionInstanceGroupManagerVersionArgs{ * InstanceTemplate: instanceTemplate.ID(), * Name: pulumi.String("primary"), * }, * }, * BaseInstanceName: pulumi.String("vm"), * TargetSize: pulumi.Int(2), * }) * if err != nil { * return err * } * // Discovered workload * catalog_workload := std.ReplaceOutput(ctx, std.ReplaceOutputArgs{ * Text: mig.InstanceGroup, * Search: pulumi.String("https://www.googleapis.com/compute/v1"), * Replace: pulumi.String("//compute.googleapis.com"), * }, nil).ApplyT(func(invoke std.ReplaceResult) (apphub.GetDiscoveredWorkloadResult, error) { * return apphub.GetDiscoveredWorkloadOutput(ctx, apphub.GetDiscoveredWorkloadOutputArgs{ * Location: "us-central1", * WorkloadUri: invoke.Result, * }, nil), nil * }).(apphub.GetDiscoveredWorkloadResultOutput) * _, err = time.NewSleep(ctx, "wait_120s_for_resource_ingestion", &time.SleepArgs{ * CreateDuration: "120s", * }) * if err != nil { * return err * } * _, err = apphub.NewWorkload(ctx, "example", &apphub.WorkloadArgs{ * Location: pulumi.String("us-central1"), * ApplicationId: application.ApplicationId, * WorkloadId: mig.Name, * DiscoveredWorkload: catalog_workload.ApplyT(func(catalog_workload apphub.GetDiscoveredWorkloadResult) (*string, error) { * return &catalog_workload.Name, nil * }).(pulumi.StringPtrOutput), * DisplayName: pulumi.String("Example Service Full"), * Description: pulumi.String("Register service for testing"), * Attributes: &apphub.WorkloadAttributesArgs{ * Environment: &apphub.WorkloadAttributesEnvironmentArgs{ * Type: pulumi.String("STAGING"), * }, * Criticality: &apphub.WorkloadAttributesCriticalityArgs{ * Type: pulumi.String("MISSION_CRITICAL"), * }, * BusinessOwners: apphub.WorkloadAttributesBusinessOwnerArray{ * &apphub.WorkloadAttributesBusinessOwnerArgs{ * DisplayName: pulumi.String("Alice"), * Email: pulumi.String("[email protected]"), * }, * }, * DeveloperOwners: apphub.WorkloadAttributesDeveloperOwnerArray{ * &apphub.WorkloadAttributesDeveloperOwnerArgs{ * DisplayName: pulumi.String("Bob"), * Email: pulumi.String("[email protected]"), * }, * }, * OperatorOwners: apphub.WorkloadAttributesOperatorOwnerArray{ * &apphub.WorkloadAttributesOperatorOwnerArgs{ * DisplayName: pulumi.String("Charlie"), * Email: pulumi.String("[email protected]"), * }, * }, * }, * }) * 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.apphub.Application; * import com.pulumi.gcp.apphub.ApplicationArgs; * import com.pulumi.gcp.apphub.inputs.ApplicationScopeArgs; * import com.pulumi.gcp.organizations.Project; * import com.pulumi.gcp.organizations.ProjectArgs; * import com.pulumi.gcp.projects.Service; * import com.pulumi.gcp.projects.ServiceArgs; * import com.pulumi.time.sleep; * import com.pulumi.time.SleepArgs; * import com.pulumi.gcp.apphub.ServiceProjectAttachment; * import com.pulumi.gcp.apphub.ServiceProjectAttachmentArgs; * import com.pulumi.gcp.compute.Network; * import com.pulumi.gcp.compute.NetworkArgs; * import com.pulumi.gcp.compute.Subnetwork; * import com.pulumi.gcp.compute.SubnetworkArgs; * import com.pulumi.gcp.compute.InstanceTemplate; * import com.pulumi.gcp.compute.InstanceTemplateArgs; * import com.pulumi.gcp.compute.inputs.InstanceTemplateNetworkInterfaceArgs; * import com.pulumi.gcp.compute.inputs.InstanceTemplateDiskArgs; * import com.pulumi.gcp.compute.RegionInstanceGroupManager; * import com.pulumi.gcp.compute.RegionInstanceGroupManagerArgs; * import com.pulumi.gcp.compute.inputs.RegionInstanceGroupManagerVersionArgs; * import com.pulumi.gcp.apphub.ApphubFunctions; * import com.pulumi.gcp.apphub.inputs.GetDiscoveredWorkloadArgs; * import com.pulumi.gcp.apphub.Workload; * import com.pulumi.gcp.apphub.WorkloadArgs; * import com.pulumi.gcp.apphub.inputs.WorkloadAttributesArgs; * import com.pulumi.gcp.apphub.inputs.WorkloadAttributesEnvironmentArgs; * import com.pulumi.gcp.apphub.inputs.WorkloadAttributesCriticalityArgs; * 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 application = new Application("application", ApplicationArgs.builder() * .location("us-central1") * .applicationId("example-application-1") * .scope(ApplicationScopeArgs.builder() * .type("REGIONAL") * .build()) * .build()); * var serviceProject = new Project("serviceProject", ProjectArgs.builder() * .projectId("project-1") * .name("Service Project") * .orgId("123456789") * .billingAccount("000000-0000000-0000000-000000") * .build()); * // Enable Compute API * var computeServiceProject = new Service("computeServiceProject", ServiceArgs.builder() * .project(serviceProject.projectId()) * .service("compute.googleapis.com") * .build()); * var wait120s = new Sleep("wait120s", SleepArgs.builder() * .createDuration("120s") * .build()); * var serviceProjectAttachment = new ServiceProjectAttachment("serviceProjectAttachment", ServiceProjectAttachmentArgs.builder() * .serviceProjectAttachmentId(serviceProject.projectId()) * .build()); * // VPC network * var ilbNetwork = new Network("ilbNetwork", NetworkArgs.builder() * .name("l7-ilb-network") * .project(serviceProject.projectId()) * .autoCreateSubnetworks(false) * .build()); * // backend subnet * var ilbSubnet = new Subnetwork("ilbSubnet", SubnetworkArgs.builder() * .name("l7-ilb-subnet") * .project(serviceProject.projectId()) * .ipCidrRange("10.0.1.0/24") * .region("us-central1") * .network(ilbNetwork.id()) * .build()); * // instance template * var instanceTemplate = new InstanceTemplate("instanceTemplate", InstanceTemplateArgs.builder() * .networkInterfaces(InstanceTemplateNetworkInterfaceArgs.builder() * .accessConfigs() * .network(ilbNetwork.id()) * .subnetwork(ilbSubnet.id()) * .build()) * .name("l7-ilb-mig-template") * .project(serviceProject.projectId()) * .machineType("e2-small") * .tags("http-server") * .disks(InstanceTemplateDiskArgs.builder() * .sourceImage("debian-cloud/debian-10") * .autoDelete(true) * .boot(true) * .build()) * .metadata(Map.of("startup-script", """ * #! /bin/bash * set -euo pipefail * export DEBIAN_FRONTEND=noninteractive * apt-get update * apt-get install -y nginx-light jq * NAME=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname") * IP=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip") * METADATA=$(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])') * cat < /var/www/html/index.html *
 * Name: $NAME
 * IP: $IP
 * Metadata: $METADATA
 * 
* EOF * """)) * .build()); * var mig = new RegionInstanceGroupManager("mig", RegionInstanceGroupManagerArgs.builder() * .name("l7-ilb-mig1") * .project(serviceProject.projectId()) * .region("us-central1") * .versions(RegionInstanceGroupManagerVersionArgs.builder() * .instanceTemplate(instanceTemplate.id()) * .name("primary") * .build()) * .baseInstanceName("vm") * .targetSize(2) * .build()); * // Discovered workload * final var catalog-workload = ApphubFunctions.getDiscoveredWorkload(GetDiscoveredWorkloadArgs.builder() * .location("us-central1") * .workloadUri(StdFunctions.replace().applyValue(invoke -> invoke.result())) * .build()); * var wait120sForResourceIngestion = new Sleep("wait120sForResourceIngestion", SleepArgs.builder() * .createDuration("120s") * .build()); * var example = new Workload("example", WorkloadArgs.builder() * .location("us-central1") * .applicationId(application.applicationId()) * .workloadId(mig.name()) * .discoveredWorkload(catalog_workload.applyValue(catalog_workload -> catalog_workload.name())) * .displayName("Example Service Full") * .description("Register service for testing") * .attributes(WorkloadAttributesArgs.builder() * .environment(WorkloadAttributesEnvironmentArgs.builder() * .type("STAGING") * .build()) * .criticality(WorkloadAttributesCriticalityArgs.builder() * .type("MISSION_CRITICAL") * .build()) * .businessOwners(WorkloadAttributesBusinessOwnerArgs.builder() * .displayName("Alice") * .email("[email protected]") * .build()) * .developerOwners(WorkloadAttributesDeveloperOwnerArgs.builder() * .displayName("Bob") * .email("[email protected]") * .build()) * .operatorOwners(WorkloadAttributesOperatorOwnerArgs.builder() * .displayName("Charlie") * .email("[email protected]") * .build()) * .build()) * .build()); * } * } * ``` * ```yaml * resources: * application: * type: gcp:apphub:Application * properties: * location: us-central1 * applicationId: example-application-1 * scope: * type: REGIONAL * serviceProject: * type: gcp:organizations:Project * name: service_project * properties: * projectId: project-1 * name: Service Project * orgId: '123456789' * billingAccount: 000000-0000000-0000000-000000 * # Enable Compute API * computeServiceProject: * type: gcp:projects:Service * name: compute_service_project * properties: * project: ${serviceProject.projectId} * service: compute.googleapis.com * wait120s: * type: time:sleep * name: wait_120s * properties: * createDuration: 120s * serviceProjectAttachment: * type: gcp:apphub:ServiceProjectAttachment * name: service_project_attachment * properties: * serviceProjectAttachmentId: ${serviceProject.projectId} * wait120sForResourceIngestion: * type: time:sleep * name: wait_120s_for_resource_ingestion * properties: * createDuration: 120s * example: * type: gcp:apphub:Workload * properties: * location: us-central1 * applicationId: ${application.applicationId} * workloadId: ${mig.name} * discoveredWorkload: ${["catalog-workload"].name} * displayName: Example Service Full * description: Register service for testing * attributes: * environment: * type: STAGING * criticality: * type: MISSION_CRITICAL * businessOwners: * - displayName: Alice * email: [email protected] * developerOwners: * - displayName: Bob * email: [email protected] * operatorOwners: * - displayName: Charlie * email: [email protected] * # VPC network * ilbNetwork: * type: gcp:compute:Network * name: ilb_network * properties: * name: l7-ilb-network * project: ${serviceProject.projectId} * autoCreateSubnetworks: false * # backend subnet * ilbSubnet: * type: gcp:compute:Subnetwork * name: ilb_subnet * properties: * name: l7-ilb-subnet * project: ${serviceProject.projectId} * ipCidrRange: 10.0.1.0/24 * region: us-central1 * network: ${ilbNetwork.id} * # instance template * instanceTemplate: * type: gcp:compute:InstanceTemplate * name: instance_template * properties: * networkInterfaces: * - accessConfigs: * - {} * network: ${ilbNetwork.id} * subnetwork: ${ilbSubnet.id} * name: l7-ilb-mig-template * project: ${serviceProject.projectId} * machineType: e2-small * tags: * - http-server * disks: * - sourceImage: debian-cloud/debian-10 * autoDelete: true * boot: true * metadata: * startup-script: | * #! /bin/bash * set -euo pipefail * export DEBIAN_FRONTEND=noninteractive * apt-get update * apt-get install -y nginx-light jq * NAME=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname") * IP=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip") * METADATA=$(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])') * cat < /var/www/html/index.html *
 *           Name: $NAME
 *           IP: $IP
 *           Metadata: $METADATA
 *           
* EOF * mig: * type: gcp:compute:RegionInstanceGroupManager * properties: * name: l7-ilb-mig1 * project: ${serviceProject.projectId} * region: us-central1 * versions: * - instanceTemplate: ${instanceTemplate.id} * name: primary * baseInstanceName: vm * targetSize: 2 * variables: * # Discovered workload * catalog-workload: * fn::invoke: * Function: gcp:apphub:getDiscoveredWorkload * Arguments: * location: us-central1 * workloadUri: * fn::invoke: * Function: std:replace * Arguments: * text: ${mig.instanceGroup} * search: https://www.googleapis.com/compute/v1 * replace: //compute.googleapis.com * Return: result * ``` * * ## Import * Workload can be imported using any of these accepted formats: * * `projects/{{project}}/locations/{{location}}/applications/{{application_id}}/workloads/{{workload_id}}` * * `{{project}}/{{location}}/{{application_id}}/{{workload_id}}` * * `{{location}}/{{application_id}}/{{workload_id}}` * When using the `pulumi import` command, Workload can be imported using one of the formats above. For example: * ```sh * $ pulumi import gcp:apphub/workload:Workload default projects/{{project}}/locations/{{location}}/applications/{{application_id}}/workloads/{{workload_id}} * ``` * ```sh * $ pulumi import gcp:apphub/workload:Workload default {{project}}/{{location}}/{{application_id}}/{{workload_id}} * ``` * ```sh * $ pulumi import gcp:apphub/workload:Workload default {{location}}/{{application_id}}/{{workload_id}} * ``` * @property applicationId Part of `parent`. Full resource name of a parent Application. Example: projects/{HOST_PROJECT_ID}/locations/{LOCATION}/applications/{APPLICATION_ID} * @property attributes Consumer provided attributes. * Structure is documented below. * @property description User-defined description of a Workload. * @property discoveredWorkload Immutable. The resource name of the original discovered workload. * @property displayName User-defined name for the Workload. * @property location Part of `parent`. Full resource name of a parent Application. Example: projects/{HOST_PROJECT_ID}/locations/{LOCATION}/applications/{APPLICATION_ID} * @property project The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. * @property workloadId The Workload identifier. * - - - */ public data class WorkloadArgs( public val applicationId: Output? = null, public val attributes: Output? = null, public val description: Output? = null, public val discoveredWorkload: Output? = null, public val displayName: Output? = null, public val location: Output? = null, public val project: Output? = null, public val workloadId: Output? = null, ) : ConvertibleToJava { override fun toJava(): com.pulumi.gcp.apphub.WorkloadArgs = com.pulumi.gcp.apphub.WorkloadArgs.builder() .applicationId(applicationId?.applyValue({ args0 -> args0 })) .attributes(attributes?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) })) .description(description?.applyValue({ args0 -> args0 })) .discoveredWorkload(discoveredWorkload?.applyValue({ args0 -> args0 })) .displayName(displayName?.applyValue({ args0 -> args0 })) .location(location?.applyValue({ args0 -> args0 })) .project(project?.applyValue({ args0 -> args0 })) .workloadId(workloadId?.applyValue({ args0 -> args0 })).build() } /** * Builder for [WorkloadArgs]. */ @PulumiTagMarker public class WorkloadArgsBuilder internal constructor() { private var applicationId: Output? = null private var attributes: Output? = null private var description: Output? = null private var discoveredWorkload: Output? = null private var displayName: Output? = null private var location: Output? = null private var project: Output? = null private var workloadId: Output? = null /** * @param value Part of `parent`. Full resource name of a parent Application. Example: projects/{HOST_PROJECT_ID}/locations/{LOCATION}/applications/{APPLICATION_ID} */ @JvmName("iycivcsrhtveaigm") public suspend fun applicationId(`value`: Output) { this.applicationId = value } /** * @param value Consumer provided attributes. * Structure is documented below. */ @JvmName("tdqnaboydpkjhmxt") public suspend fun attributes(`value`: Output) { this.attributes = value } /** * @param value User-defined description of a Workload. */ @JvmName("scnnqrmjgmdilohl") public suspend fun description(`value`: Output) { this.description = value } /** * @param value Immutable. The resource name of the original discovered workload. */ @JvmName("lxfaqevclsbxigfk") public suspend fun discoveredWorkload(`value`: Output) { this.discoveredWorkload = value } /** * @param value User-defined name for the Workload. */ @JvmName("roetsqfafohekoqg") public suspend fun displayName(`value`: Output) { this.displayName = value } /** * @param value Part of `parent`. Full resource name of a parent Application. Example: projects/{HOST_PROJECT_ID}/locations/{LOCATION}/applications/{APPLICATION_ID} */ @JvmName("bqkbnhbhqmmgigmx") public suspend fun location(`value`: Output) { this.location = value } /** * @param value The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. */ @JvmName("htawvsgqtwysnomy") public suspend fun project(`value`: Output) { this.project = value } /** * @param value The Workload identifier. * - - - */ @JvmName("rqeeqnfxoqikcuan") public suspend fun workloadId(`value`: Output) { this.workloadId = value } /** * @param value Part of `parent`. Full resource name of a parent Application. Example: projects/{HOST_PROJECT_ID}/locations/{LOCATION}/applications/{APPLICATION_ID} */ @JvmName("edhorynratbjvpna") public suspend fun applicationId(`value`: String?) { val toBeMapped = value val mapped = toBeMapped?.let({ args0 -> of(args0) }) this.applicationId = mapped } /** * @param value Consumer provided attributes. * Structure is documented below. */ @JvmName("noyprqpincqercsd") public suspend fun attributes(`value`: WorkloadAttributesArgs?) { val toBeMapped = value val mapped = toBeMapped?.let({ args0 -> of(args0) }) this.attributes = mapped } /** * @param argument Consumer provided attributes. * Structure is documented below. */ @JvmName("mhojpklevbduetlc") public suspend fun attributes(argument: suspend WorkloadAttributesArgsBuilder.() -> Unit) { val toBeMapped = WorkloadAttributesArgsBuilder().applySuspend { argument() }.build() val mapped = of(toBeMapped) this.attributes = mapped } /** * @param value User-defined description of a Workload. */ @JvmName("wdmgwyieveulipoy") public suspend fun description(`value`: String?) { val toBeMapped = value val mapped = toBeMapped?.let({ args0 -> of(args0) }) this.description = mapped } /** * @param value Immutable. The resource name of the original discovered workload. */ @JvmName("ilrafpylbppkmswc") public suspend fun discoveredWorkload(`value`: String?) { val toBeMapped = value val mapped = toBeMapped?.let({ args0 -> of(args0) }) this.discoveredWorkload = mapped } /** * @param value User-defined name for the Workload. */ @JvmName("aeblkbsriqyooapa") public suspend fun displayName(`value`: String?) { val toBeMapped = value val mapped = toBeMapped?.let({ args0 -> of(args0) }) this.displayName = mapped } /** * @param value Part of `parent`. Full resource name of a parent Application. Example: projects/{HOST_PROJECT_ID}/locations/{LOCATION}/applications/{APPLICATION_ID} */ @JvmName("rpiqxsvdulifdaax") public suspend fun location(`value`: String?) { val toBeMapped = value val mapped = toBeMapped?.let({ args0 -> of(args0) }) this.location = mapped } /** * @param value The ID of the project in which the resource belongs. * If it is not provided, the provider project is used. */ @JvmName("adjuqqkhnurjvoov") public suspend fun project(`value`: String?) { val toBeMapped = value val mapped = toBeMapped?.let({ args0 -> of(args0) }) this.project = mapped } /** * @param value The Workload identifier. * - - - */ @JvmName("drfqkoxmioypture") public suspend fun workloadId(`value`: String?) { val toBeMapped = value val mapped = toBeMapped?.let({ args0 -> of(args0) }) this.workloadId = mapped } internal fun build(): WorkloadArgs = WorkloadArgs( applicationId = applicationId, attributes = attributes, description = description, discoveredWorkload = discoveredWorkload, displayName = displayName, location = location, project = project, workloadId = workloadId, ) }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy