1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. ProjectMetadataItem
Google Cloud v8.25.1 published on Wednesday, Apr 9, 2025 by Pulumi

gcp.compute.ProjectMetadataItem

Explore with Pulumi AI

Manages a single key/value pair on metadata common to all instances for a project in GCE. Using gcp.compute.ProjectMetadataItem lets you manage a single key/value setting in the provider rather than the entire project metadata map.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const _default = new gcp.compute.ProjectMetadataItem("default", {
    key: "my_metadata",
    value: "my_value",
});
Copy
import pulumi
import pulumi_gcp as gcp

default = gcp.compute.ProjectMetadataItem("default",
    key="my_metadata",
    value="my_value")
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewProjectMetadataItem(ctx, "default", &compute.ProjectMetadataItemArgs{
			Key:   pulumi.String("my_metadata"),
			Value: pulumi.String("my_value"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var @default = new Gcp.Compute.ProjectMetadataItem("default", new()
    {
        Key = "my_metadata",
        Value = "my_value",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.ProjectMetadataItem;
import com.pulumi.gcp.compute.ProjectMetadataItemArgs;
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 ProjectMetadataItem("default", ProjectMetadataItemArgs.builder()
            .key("my_metadata")
            .value("my_value")
            .build());

    }
}
Copy
resources:
  default:
    type: gcp:compute:ProjectMetadataItem
    properties:
      key: my_metadata
      value: my_value
Copy

Create ProjectMetadataItem Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new ProjectMetadataItem(name: string, args: ProjectMetadataItemArgs, opts?: CustomResourceOptions);
@overload
def ProjectMetadataItem(resource_name: str,
                        args: ProjectMetadataItemArgs,
                        opts: Optional[ResourceOptions] = None)

@overload
def ProjectMetadataItem(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        key: Optional[str] = None,
                        value: Optional[str] = None,
                        project: Optional[str] = None)
func NewProjectMetadataItem(ctx *Context, name string, args ProjectMetadataItemArgs, opts ...ResourceOption) (*ProjectMetadataItem, error)
public ProjectMetadataItem(string name, ProjectMetadataItemArgs args, CustomResourceOptions? opts = null)
public ProjectMetadataItem(String name, ProjectMetadataItemArgs args)
public ProjectMetadataItem(String name, ProjectMetadataItemArgs args, CustomResourceOptions options)
type: gcp:compute:ProjectMetadataItem
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

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

Constructor example

The following reference example uses placeholder values for all input properties.

var projectMetadataItemResource = new Gcp.Compute.ProjectMetadataItem("projectMetadataItemResource", new()
{
    Key = "string",
    Value = "string",
    Project = "string",
});
Copy
example, err := compute.NewProjectMetadataItem(ctx, "projectMetadataItemResource", &compute.ProjectMetadataItemArgs{
	Key:     pulumi.String("string"),
	Value:   pulumi.String("string"),
	Project: pulumi.String("string"),
})
Copy
var projectMetadataItemResource = new ProjectMetadataItem("projectMetadataItemResource", ProjectMetadataItemArgs.builder()
    .key("string")
    .value("string")
    .project("string")
    .build());
Copy
project_metadata_item_resource = gcp.compute.ProjectMetadataItem("projectMetadataItemResource",
    key="string",
    value="string",
    project="string")
Copy
const projectMetadataItemResource = new gcp.compute.ProjectMetadataItem("projectMetadataItemResource", {
    key: "string",
    value: "string",
    project: "string",
});
Copy
type: gcp:compute:ProjectMetadataItem
properties:
    key: string
    project: string
    value: string
Copy

ProjectMetadataItem Resource Properties

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

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The ProjectMetadataItem resource accepts the following input properties:

Key
This property is required.
Changes to this property will trigger replacement.
string
The metadata key to set.
Value This property is required. string
The value to set for the given metadata key.


Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Key
This property is required.
Changes to this property will trigger replacement.
string
The metadata key to set.
Value This property is required. string
The value to set for the given metadata key.


Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
key
This property is required.
Changes to this property will trigger replacement.
String
The metadata key to set.
value This property is required. String
The value to set for the given metadata key.


project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
key
This property is required.
Changes to this property will trigger replacement.
string
The metadata key to set.
value This property is required. string
The value to set for the given metadata key.


project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
key
This property is required.
Changes to this property will trigger replacement.
str
The metadata key to set.
value This property is required. str
The value to set for the given metadata key.


project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
key
This property is required.
Changes to this property will trigger replacement.
String
The metadata key to set.
value This property is required. String
The value to set for the given metadata key.


project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing ProjectMetadataItem Resource

Get an existing ProjectMetadataItem resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ProjectMetadataItemState, opts?: CustomResourceOptions): ProjectMetadataItem
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        key: Optional[str] = None,
        project: Optional[str] = None,
        value: Optional[str] = None) -> ProjectMetadataItem
func GetProjectMetadataItem(ctx *Context, name string, id IDInput, state *ProjectMetadataItemState, opts ...ResourceOption) (*ProjectMetadataItem, error)
public static ProjectMetadataItem Get(string name, Input<string> id, ProjectMetadataItemState? state, CustomResourceOptions? opts = null)
public static ProjectMetadataItem get(String name, Output<String> id, ProjectMetadataItemState state, CustomResourceOptions options)
resources:  _:    type: gcp:compute:ProjectMetadataItem    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Key Changes to this property will trigger replacement. string
The metadata key to set.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Value string
The value to set for the given metadata key.


Key Changes to this property will trigger replacement. string
The metadata key to set.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Value string
The value to set for the given metadata key.


key Changes to this property will trigger replacement. String
The metadata key to set.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
value String
The value to set for the given metadata key.


key Changes to this property will trigger replacement. string
The metadata key to set.
project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
value string
The value to set for the given metadata key.


key Changes to this property will trigger replacement. str
The metadata key to set.
project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
value str
The value to set for the given metadata key.


key Changes to this property will trigger replacement. String
The metadata key to set.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
value String
The value to set for the given metadata key.


Import

Project metadata items can be imported using the key, e.g.

  • {{key}}

  • projects/{{project}}/meta-data/{{key}}

When using the pulumi import command, project metadata items can be imported using one of the formats above. For example:

$ pulumi import gcp:compute/projectMetadataItem:ProjectMetadataItem default {{key}}
Copy
$ pulumi import gcp:compute/projectMetadataItem:ProjectMetadataItem default projects/{{project}}/meta-data/{{key}}
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Google Cloud (GCP) Classic pulumi/pulumi-gcp
License
Apache-2.0
Notes
This Pulumi package is based on the google-beta Terraform Provider.