1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. storage
  5. ObjectACL
Google Cloud v8.27.1 published on Friday, Apr 25, 2025 by Pulumi

gcp.storage.ObjectACL

Explore with Pulumi AI

Authoritatively manages the access control list (ACL) for an object in a Google Cloud Storage (GCS) bucket. Removing a gcp.storage.ObjectACL sets the acl to the private predefined ACL.

For more information see the official documentation and API.

Want fine-grained control over object ACLs? Use gcp.storage.ObjectAccessControl to control individual role entity pairs.

Example Usage

Create an object ACL with one owner and one reader.

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

const image_store = new gcp.storage.Bucket("image-store", {
    name: "image-store-bucket",
    location: "EU",
});
const image = new gcp.storage.BucketObject("image", {
    name: "image1",
    bucket: image_store.name,
    source: new pulumi.asset.FileAsset("image1.jpg"),
});
const image_store_acl = new gcp.storage.ObjectACL("image-store-acl", {
    bucket: image_store.name,
    object: image.outputName,
    roleEntities: [
        "OWNER:user-my.email@gmail.com",
        "READER:group-mygroup",
    ],
});
Copy
import pulumi
import pulumi_gcp as gcp

image_store = gcp.storage.Bucket("image-store",
    name="image-store-bucket",
    location="EU")
image = gcp.storage.BucketObject("image",
    name="image1",
    bucket=image_store.name,
    source=pulumi.FileAsset("image1.jpg"))
image_store_acl = gcp.storage.ObjectACL("image-store-acl",
    bucket=image_store.name,
    object=image.output_name,
    role_entities=[
        "OWNER:user-my.email@gmail.com",
        "READER:group-mygroup",
    ])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		image_store, err := storage.NewBucket(ctx, "image-store", &storage.BucketArgs{
			Name:     pulumi.String("image-store-bucket"),
			Location: pulumi.String("EU"),
		})
		if err != nil {
			return err
		}
		image, err := storage.NewBucketObject(ctx, "image", &storage.BucketObjectArgs{
			Name:   pulumi.String("image1"),
			Bucket: image_store.Name,
			Source: pulumi.NewFileAsset("image1.jpg"),
		})
		if err != nil {
			return err
		}
		_, err = storage.NewObjectACL(ctx, "image-store-acl", &storage.ObjectACLArgs{
			Bucket: image_store.Name,
			Object: image.OutputName,
			RoleEntities: pulumi.StringArray{
				pulumi.String("OWNER:user-my.email@gmail.com"),
				pulumi.String("READER:group-mygroup"),
			},
		})
		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 image_store = new Gcp.Storage.Bucket("image-store", new()
    {
        Name = "image-store-bucket",
        Location = "EU",
    });

    var image = new Gcp.Storage.BucketObject("image", new()
    {
        Name = "image1",
        Bucket = image_store.Name,
        Source = new FileAsset("image1.jpg"),
    });

    var image_store_acl = new Gcp.Storage.ObjectACL("image-store-acl", new()
    {
        Bucket = image_store.Name,
        Object = image.OutputName,
        RoleEntities = new[]
        {
            "OWNER:user-my.email@gmail.com",
            "READER:group-mygroup",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import com.pulumi.gcp.storage.BucketObject;
import com.pulumi.gcp.storage.BucketObjectArgs;
import com.pulumi.gcp.storage.ObjectACL;
import com.pulumi.gcp.storage.ObjectACLArgs;
import com.pulumi.asset.FileAsset;
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 image_store = new Bucket("image-store", BucketArgs.builder()
            .name("image-store-bucket")
            .location("EU")
            .build());

        var image = new BucketObject("image", BucketObjectArgs.builder()
            .name("image1")
            .bucket(image_store.name())
            .source(new FileAsset("image1.jpg"))
            .build());

        var image_store_acl = new ObjectACL("image-store-acl", ObjectACLArgs.builder()
            .bucket(image_store.name())
            .object(image.outputName())
            .roleEntities(            
                "OWNER:user-my.email@gmail.com",
                "READER:group-mygroup")
            .build());

    }
}
Copy
resources:
  image-store:
    type: gcp:storage:Bucket
    properties:
      name: image-store-bucket
      location: EU
  image:
    type: gcp:storage:BucketObject
    properties:
      name: image1
      bucket: ${["image-store"].name}
      source:
        fn::FileAsset: image1.jpg
  image-store-acl:
    type: gcp:storage:ObjectACL
    properties:
      bucket: ${["image-store"].name}
      object: ${image.outputName}
      roleEntities:
        - OWNER:user-my.email@gmail.com
        - READER:group-mygroup
Copy

Create ObjectACL Resource

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

Constructor syntax

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

@overload
def ObjectACL(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              bucket: Optional[str] = None,
              object: Optional[str] = None,
              predefined_acl: Optional[str] = None,
              role_entities: Optional[Sequence[str]] = None)
func NewObjectACL(ctx *Context, name string, args ObjectACLArgs, opts ...ResourceOption) (*ObjectACL, error)
public ObjectACL(string name, ObjectACLArgs args, CustomResourceOptions? opts = null)
public ObjectACL(String name, ObjectACLArgs args)
public ObjectACL(String name, ObjectACLArgs args, CustomResourceOptions options)
type: gcp:storage:ObjectACL
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. ObjectACLArgs
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. ObjectACLArgs
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. ObjectACLArgs
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. ObjectACLArgs
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. ObjectACLArgs
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 objectACLResource = new Gcp.Storage.ObjectACL("objectACLResource", new()
{
    Bucket = "string",
    Object = "string",
    PredefinedAcl = "string",
    RoleEntities = new[]
    {
        "string",
    },
});
Copy
example, err := storage.NewObjectACL(ctx, "objectACLResource", &storage.ObjectACLArgs{
	Bucket:        pulumi.String("string"),
	Object:        pulumi.String("string"),
	PredefinedAcl: pulumi.String("string"),
	RoleEntities: pulumi.StringArray{
		pulumi.String("string"),
	},
})
Copy
var objectACLResource = new ObjectACL("objectACLResource", ObjectACLArgs.builder()
    .bucket("string")
    .object("string")
    .predefinedAcl("string")
    .roleEntities("string")
    .build());
Copy
object_acl_resource = gcp.storage.ObjectACL("objectACLResource",
    bucket="string",
    object="string",
    predefined_acl="string",
    role_entities=["string"])
Copy
const objectACLResource = new gcp.storage.ObjectACL("objectACLResource", {
    bucket: "string",
    object: "string",
    predefinedAcl: "string",
    roleEntities: ["string"],
});
Copy
type: gcp:storage:ObjectACL
properties:
    bucket: string
    object: string
    predefinedAcl: string
    roleEntities:
        - string
Copy

ObjectACL 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 ObjectACL resource accepts the following input properties:

Bucket
This property is required.
Changes to this property will trigger replacement.
string
The name of the bucket the object is stored in.
Object
This property is required.
Changes to this property will trigger replacement.
string
The name of the object to apply the acl to.


PredefinedAcl string
The "canned" predefined ACL to apply. Must be set if role_entity is not.
RoleEntities List<string>
List of role/entity pairs in the form ROLE:entity. See GCS Object ACL documentation for more details. Must be set if predefined_acl is not.
Bucket
This property is required.
Changes to this property will trigger replacement.
string
The name of the bucket the object is stored in.
Object
This property is required.
Changes to this property will trigger replacement.
string
The name of the object to apply the acl to.


PredefinedAcl string
The "canned" predefined ACL to apply. Must be set if role_entity is not.
RoleEntities []string
List of role/entity pairs in the form ROLE:entity. See GCS Object ACL documentation for more details. Must be set if predefined_acl is not.
bucket
This property is required.
Changes to this property will trigger replacement.
String
The name of the bucket the object is stored in.
object
This property is required.
Changes to this property will trigger replacement.
String
The name of the object to apply the acl to.


predefinedAcl String
The "canned" predefined ACL to apply. Must be set if role_entity is not.
roleEntities List<String>
List of role/entity pairs in the form ROLE:entity. See GCS Object ACL documentation for more details. Must be set if predefined_acl is not.
bucket
This property is required.
Changes to this property will trigger replacement.
string
The name of the bucket the object is stored in.
object
This property is required.
Changes to this property will trigger replacement.
string
The name of the object to apply the acl to.


predefinedAcl string
The "canned" predefined ACL to apply. Must be set if role_entity is not.
roleEntities string[]
List of role/entity pairs in the form ROLE:entity. See GCS Object ACL documentation for more details. Must be set if predefined_acl is not.
bucket
This property is required.
Changes to this property will trigger replacement.
str
The name of the bucket the object is stored in.
object
This property is required.
Changes to this property will trigger replacement.
str
The name of the object to apply the acl to.


predefined_acl str
The "canned" predefined ACL to apply. Must be set if role_entity is not.
role_entities Sequence[str]
List of role/entity pairs in the form ROLE:entity. See GCS Object ACL documentation for more details. Must be set if predefined_acl is not.
bucket
This property is required.
Changes to this property will trigger replacement.
String
The name of the bucket the object is stored in.
object
This property is required.
Changes to this property will trigger replacement.
String
The name of the object to apply the acl to.


predefinedAcl String
The "canned" predefined ACL to apply. Must be set if role_entity is not.
roleEntities List<String>
List of role/entity pairs in the form ROLE:entity. See GCS Object ACL documentation for more details. Must be set if predefined_acl is not.

Outputs

All input properties are implicitly available as output properties. Additionally, the ObjectACL 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 ObjectACL Resource

Get an existing ObjectACL 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?: ObjectACLState, opts?: CustomResourceOptions): ObjectACL
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        bucket: Optional[str] = None,
        object: Optional[str] = None,
        predefined_acl: Optional[str] = None,
        role_entities: Optional[Sequence[str]] = None) -> ObjectACL
func GetObjectACL(ctx *Context, name string, id IDInput, state *ObjectACLState, opts ...ResourceOption) (*ObjectACL, error)
public static ObjectACL Get(string name, Input<string> id, ObjectACLState? state, CustomResourceOptions? opts = null)
public static ObjectACL get(String name, Output<String> id, ObjectACLState state, CustomResourceOptions options)
resources:  _:    type: gcp:storage:ObjectACL    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:
Bucket Changes to this property will trigger replacement. string
The name of the bucket the object is stored in.
Object Changes to this property will trigger replacement. string
The name of the object to apply the acl to.


PredefinedAcl string
The "canned" predefined ACL to apply. Must be set if role_entity is not.
RoleEntities List<string>
List of role/entity pairs in the form ROLE:entity. See GCS Object ACL documentation for more details. Must be set if predefined_acl is not.
Bucket Changes to this property will trigger replacement. string
The name of the bucket the object is stored in.
Object Changes to this property will trigger replacement. string
The name of the object to apply the acl to.


PredefinedAcl string
The "canned" predefined ACL to apply. Must be set if role_entity is not.
RoleEntities []string
List of role/entity pairs in the form ROLE:entity. See GCS Object ACL documentation for more details. Must be set if predefined_acl is not.
bucket Changes to this property will trigger replacement. String
The name of the bucket the object is stored in.
object Changes to this property will trigger replacement. String
The name of the object to apply the acl to.


predefinedAcl String
The "canned" predefined ACL to apply. Must be set if role_entity is not.
roleEntities List<String>
List of role/entity pairs in the form ROLE:entity. See GCS Object ACL documentation for more details. Must be set if predefined_acl is not.
bucket Changes to this property will trigger replacement. string
The name of the bucket the object is stored in.
object Changes to this property will trigger replacement. string
The name of the object to apply the acl to.


predefinedAcl string
The "canned" predefined ACL to apply. Must be set if role_entity is not.
roleEntities string[]
List of role/entity pairs in the form ROLE:entity. See GCS Object ACL documentation for more details. Must be set if predefined_acl is not.
bucket Changes to this property will trigger replacement. str
The name of the bucket the object is stored in.
object Changes to this property will trigger replacement. str
The name of the object to apply the acl to.


predefined_acl str
The "canned" predefined ACL to apply. Must be set if role_entity is not.
role_entities Sequence[str]
List of role/entity pairs in the form ROLE:entity. See GCS Object ACL documentation for more details. Must be set if predefined_acl is not.
bucket Changes to this property will trigger replacement. String
The name of the bucket the object is stored in.
object Changes to this property will trigger replacement. String
The name of the object to apply the acl to.


predefinedAcl String
The "canned" predefined ACL to apply. Must be set if role_entity is not.
roleEntities List<String>
List of role/entity pairs in the form ROLE:entity. See GCS Object ACL documentation for more details. Must be set if predefined_acl is not.

Import

This resource does not support import.

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.