Google Cloud Storage Default Object Access Control
This page shows how to write Terraform for Cloud Storage Default Object Access Control and write them securely.
google_storage_default_object_access_control (Terraform)
The Default Object Access Control in Cloud Storage can be configured in Terraform with the resource name google_storage_default_object_access_control
. The following sections describe 2 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "google_storage_default_object_access_control" "private-rule" {
bucket = google_storage_bucket.stock-ticker-bucket.name
entity = "user-keith.blix@gmail.com"
role = "OWNER"
}
resource "google_storage_default_object_access_control" "public" {
bucket = module.bucket.name
role = "READER"
entity = "allUsers"
}
Parameters
-
bucket
required - string
The name of the bucket.
-
domain
optional computed - string
The domain associated with the entity.
-
email
optional computed - string
The email address associated with the entity.
-
entity
required - string
The entity holding the permission, in one of the following forms: user-[[userId]] user-[[email]] (such as "user-liz@example.com") group-[[groupId]] group-[[email]] (such as "group-example@googlegroups.com") domain-[[domain]] (such as "domain-example.com") project-team-[[projectId]] allUsers allAuthenticatedUsers
-
entity_id
optional computed - string
The ID for the entity
-
generation
optional computed - number
The content generation of the object, if applied to an object.
The name of the object, if applied to an object.
-
project_team
optional computed - list of object
The project team associated with the entity
-
project_number
- string -
team
- string -
role
required - string
The access permission for the entity. Possible values: ["OWNER", "READER"]
Explanation in Terraform Registry
The DefaultObjectAccessControls resources represent the Access Control Lists (ACLs) applied to a new object within a Google Cloud Storage bucket when no ACL was provided for that object. ACLs let you specify who has access to your bucket contents and to what extent. There are two roles that can be assigned to an entity: READERs can get an object, though the acl property will not be revealed. OWNERs are READERs, and they can get the acl property, update an object, and call all objectAccessControls methods on the object. The owner of an object is always an OWNER. For more information, see Access Control, with the caveat that this API uses READER and OWNER instead of READ and FULL_CONTROL. To get more information about DefaultObjectAccessControl, see:
- API documentation
- How-to Guides
Tips: Best Practices for The Other Google Cloud Storage Resources
In addition to the google_storage_bucket, Google Cloud Storage has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
google_storage_bucket
Ensure uniform bucket-level access of your GCS bucket is enabled
It is better to enable uniform bucket-level access of the GCS bucket. Uniform bucket-level access unifies and simplifies how you grant access to resources in the bucket.
Frequently asked questions
What is Google Cloud Storage Default Object Access Control?
Google Cloud Storage Default Object Access Control is a resource for Cloud Storage of Google Cloud Platform. Settings can be wrote in Terraform.
Where can I find the example code for the Google Cloud Storage Default Object Access Control?
For Terraform, the Blixk/basic_terraform_infrastructure and claudiobizzotto/terraform-v0.13-test-drive source code examples are useful. See the Terraform Example section for further details.