Authoritatively manages metadata common to all instances for a project in GCE. For more information see the official documentation and API.
resource "google_compute_project_metadata" "default" {
metadata = {
foo = "bar"
fizz = "buzz"
"13" = "42"
}
}
/*
A key set in project metadata is propagated to every instance in the project.
This resource configuration is prone to causing frequent diffs as Google adds SSH Keys when the SSH Button is pressed in the console.
It is better to use OS Login instead.
*/
resource "google_compute_project_metadata" "my_ssh_key" {
metadata = {
ssh-keys = <<EOF
dev:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILg6UtHDNyMNAh0GjaytsJdrUxjtLy3APXqZfNZhvCeT dev
foo:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILg6UtHDNyMNAh0GjaytsJdrUxjtLy3APXqZfNZhvCeT bar
EOF
}
}
dev:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILg6UtHDNyMNAh0GjaytsJdrUxjtLy3APXqZfNZhvCeT dev
foo:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILg6UtHDNyMNAh0GjaytsJdrUxjtLy3APXqZfNZhvCeT bar
EOF
}
}
The following arguments are supported:
metadata
- (Required) A series of key value pairs.project
- (Optional) The ID of the project in which the resource belongs. If it
is not provided, the provider project is used.In addition to the arguments listed above, the following computed attributes are exported:
id
- an identifier for the resource with format {{project}}
This resource provides the following Timeouts configuration options: configuration options:
create
- Default is 4 minutes (also used for update).delete
- Default is 4 minutes.Project metadata can be imported using the project ID:
{{project_id}}
In Terraform v1.5.0 and later, use an import
block to import project metadata using one of the formats above. For example:
import {
id = "{{project_id}}"
to = google_compute_project_metadata.default
}
When using the terraform import
command, project metadata can be imported using one of the formats above. For example:
$ terraform import google_compute_project_metadata.default {{project_id}}