1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. storage
  5. ObjectAccessControl
Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi

gcp.storage.ObjectAccessControl

Explore with Pulumi AI

gcp logo
Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi

    The ObjectAccessControls resources represent the Access Control Lists (ACLs) for objects within Google Cloud Storage. ACLs let you specify who has access to your data 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 ObjectAccessControl, see:

    Example Usage

    Storage Object Access Control Public Object

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const bucket = new gcp.storage.Bucket("bucket", {
        name: "static-content-bucket",
        location: "US",
    });
    const object = new gcp.storage.BucketObject("object", {
        name: "public-object",
        bucket: bucket.name,
        source: new pulumi.asset.FileAsset("../static/img/header-logo.png"),
    });
    const publicRule = new gcp.storage.ObjectAccessControl("public_rule", {
        object: object.outputName,
        bucket: bucket.name,
        role: "READER",
        entity: "allUsers",
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    bucket = gcp.storage.Bucket("bucket",
        name="static-content-bucket",
        location="US")
    object = gcp.storage.BucketObject("object",
        name="public-object",
        bucket=bucket.name,
        source=pulumi.FileAsset("../static/img/header-logo.png"))
    public_rule = gcp.storage.ObjectAccessControl("public_rule",
        object=object.output_name,
        bucket=bucket.name,
        role="READER",
        entity="allUsers")
    
    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 {
    		bucket, err := storage.NewBucket(ctx, "bucket", &storage.BucketArgs{
    			Name:     pulumi.String("static-content-bucket"),
    			Location: pulumi.String("US"),
    		})
    		if err != nil {
    			return err
    		}
    		object, err := storage.NewBucketObject(ctx, "object", &storage.BucketObjectArgs{
    			Name:   pulumi.String("public-object"),
    			Bucket: bucket.Name,
    			Source: pulumi.NewFileAsset("../static/img/header-logo.png"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = storage.NewObjectAccessControl(ctx, "public_rule", &storage.ObjectAccessControlArgs{
    			Object: object.OutputName,
    			Bucket: bucket.Name,
    			Role:   pulumi.String("READER"),
    			Entity: pulumi.String("allUsers"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var bucket = new Gcp.Storage.Bucket("bucket", new()
        {
            Name = "static-content-bucket",
            Location = "US",
        });
    
        var @object = new Gcp.Storage.BucketObject("object", new()
        {
            Name = "public-object",
            Bucket = bucket.Name,
            Source = new FileAsset("../static/img/header-logo.png"),
        });
    
        var publicRule = new Gcp.Storage.ObjectAccessControl("public_rule", new()
        {
            Object = @object.OutputName,
            Bucket = bucket.Name,
            Role = "READER",
            Entity = "allUsers",
        });
    
    });
    
    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.ObjectAccessControl;
    import com.pulumi.gcp.storage.ObjectAccessControlArgs;
    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 bucket = new Bucket("bucket", BucketArgs.builder()
                .name("static-content-bucket")
                .location("US")
                .build());
    
            var object = new BucketObject("object", BucketObjectArgs.builder()
                .name("public-object")
                .bucket(bucket.name())
                .source(new FileAsset("../static/img/header-logo.png"))
                .build());
    
            var publicRule = new ObjectAccessControl("publicRule", ObjectAccessControlArgs.builder()
                .object(object.outputName())
                .bucket(bucket.name())
                .role("READER")
                .entity("allUsers")
                .build());
    
        }
    }
    
    resources:
      publicRule:
        type: gcp:storage:ObjectAccessControl
        name: public_rule
        properties:
          object: ${object.outputName}
          bucket: ${bucket.name}
          role: READER
          entity: allUsers
      bucket:
        type: gcp:storage:Bucket
        properties:
          name: static-content-bucket
          location: US
      object:
        type: gcp:storage:BucketObject
        properties:
          name: public-object
          bucket: ${bucket.name}
          source:
            fn::FileAsset: ../static/img/header-logo.png
    

    Create ObjectAccessControl Resource

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

    Constructor syntax

    new ObjectAccessControl(name: string, args: ObjectAccessControlArgs, opts?: CustomResourceOptions);
    @overload
    def ObjectAccessControl(resource_name: str,
                            args: ObjectAccessControlArgs,
                            opts: Optional[ResourceOptions] = None)
    
    @overload
    def ObjectAccessControl(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            bucket: Optional[str] = None,
                            entity: Optional[str] = None,
                            object: Optional[str] = None,
                            role: Optional[str] = None)
    func NewObjectAccessControl(ctx *Context, name string, args ObjectAccessControlArgs, opts ...ResourceOption) (*ObjectAccessControl, error)
    public ObjectAccessControl(string name, ObjectAccessControlArgs args, CustomResourceOptions? opts = null)
    public ObjectAccessControl(String name, ObjectAccessControlArgs args)
    public ObjectAccessControl(String name, ObjectAccessControlArgs args, CustomResourceOptions options)
    
    type: gcp:storage:ObjectAccessControl
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args ObjectAccessControlArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ObjectAccessControlArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ObjectAccessControlArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ObjectAccessControlArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ObjectAccessControlArgs
    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 objectAccessControlResource = new Gcp.Storage.ObjectAccessControl("objectAccessControlResource", new()
    {
        Bucket = "string",
        Entity = "string",
        Object = "string",
        Role = "string",
    });
    
    example, err := storage.NewObjectAccessControl(ctx, "objectAccessControlResource", &storage.ObjectAccessControlArgs{
    	Bucket: pulumi.String("string"),
    	Entity: pulumi.String("string"),
    	Object: pulumi.String("string"),
    	Role:   pulumi.String("string"),
    })
    
    var objectAccessControlResource = new ObjectAccessControl("objectAccessControlResource", ObjectAccessControlArgs.builder()
        .bucket("string")
        .entity("string")
        .object("string")
        .role("string")
        .build());
    
    object_access_control_resource = gcp.storage.ObjectAccessControl("objectAccessControlResource",
        bucket="string",
        entity="string",
        object="string",
        role="string")
    
    const objectAccessControlResource = new gcp.storage.ObjectAccessControl("objectAccessControlResource", {
        bucket: "string",
        entity: "string",
        object: "string",
        role: "string",
    });
    
    type: gcp:storage:ObjectAccessControl
    properties:
        bucket: string
        entity: string
        object: string
        role: string
    

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

    Bucket string
    The name of the bucket.
    Entity 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
    Object string
    The name of the object to apply the access control to.
    Role string
    The access permission for the entity. Possible values are: OWNER, READER.


    Bucket string
    The name of the bucket.
    Entity 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
    Object string
    The name of the object to apply the access control to.
    Role string
    The access permission for the entity. Possible values are: OWNER, READER.


    bucket String
    The name of the bucket.
    entity 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
    object String
    The name of the object to apply the access control to.
    role String
    The access permission for the entity. Possible values are: OWNER, READER.


    bucket string
    The name of the bucket.
    entity 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
    object string
    The name of the object to apply the access control to.
    role string
    The access permission for the entity. Possible values are: OWNER, READER.


    bucket str
    The name of the bucket.
    entity str
    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
    object str
    The name of the object to apply the access control to.
    role str
    The access permission for the entity. Possible values are: OWNER, READER.


    bucket String
    The name of the bucket.
    entity 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
    object String
    The name of the object to apply the access control to.
    role String
    The access permission for the entity. Possible values are: OWNER, READER.


    Outputs

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

    Domain string
    The domain associated with the entity.
    Email string
    The email address associated with the entity.
    EntityId string
    The ID for the entity
    Generation int
    The content generation of the object, if applied to an object.
    Id string
    The provider-assigned unique ID for this managed resource.
    ProjectTeams List<ObjectAccessControlProjectTeam>
    The project team associated with the entity Structure is documented below.
    Domain string
    The domain associated with the entity.
    Email string
    The email address associated with the entity.
    EntityId string
    The ID for the entity
    Generation int
    The content generation of the object, if applied to an object.
    Id string
    The provider-assigned unique ID for this managed resource.
    ProjectTeams []ObjectAccessControlProjectTeam
    The project team associated with the entity Structure is documented below.
    domain String
    The domain associated with the entity.
    email String
    The email address associated with the entity.
    entityId String
    The ID for the entity
    generation Integer
    The content generation of the object, if applied to an object.
    id String
    The provider-assigned unique ID for this managed resource.
    projectTeams List<ObjectAccessControlProjectTeam>
    The project team associated with the entity Structure is documented below.
    domain string
    The domain associated with the entity.
    email string
    The email address associated with the entity.
    entityId string
    The ID for the entity
    generation number
    The content generation of the object, if applied to an object.
    id string
    The provider-assigned unique ID for this managed resource.
    projectTeams ObjectAccessControlProjectTeam[]
    The project team associated with the entity Structure is documented below.
    domain str
    The domain associated with the entity.
    email str
    The email address associated with the entity.
    entity_id str
    The ID for the entity
    generation int
    The content generation of the object, if applied to an object.
    id str
    The provider-assigned unique ID for this managed resource.
    project_teams Sequence[ObjectAccessControlProjectTeam]
    The project team associated with the entity Structure is documented below.
    domain String
    The domain associated with the entity.
    email String
    The email address associated with the entity.
    entityId String
    The ID for the entity
    generation Number
    The content generation of the object, if applied to an object.
    id String
    The provider-assigned unique ID for this managed resource.
    projectTeams List<Property Map>
    The project team associated with the entity Structure is documented below.

    Look up Existing ObjectAccessControl Resource

    Get an existing ObjectAccessControl 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?: ObjectAccessControlState, opts?: CustomResourceOptions): ObjectAccessControl
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            bucket: Optional[str] = None,
            domain: Optional[str] = None,
            email: Optional[str] = None,
            entity: Optional[str] = None,
            entity_id: Optional[str] = None,
            generation: Optional[int] = None,
            object: Optional[str] = None,
            project_teams: Optional[Sequence[ObjectAccessControlProjectTeamArgs]] = None,
            role: Optional[str] = None) -> ObjectAccessControl
    func GetObjectAccessControl(ctx *Context, name string, id IDInput, state *ObjectAccessControlState, opts ...ResourceOption) (*ObjectAccessControl, error)
    public static ObjectAccessControl Get(string name, Input<string> id, ObjectAccessControlState? state, CustomResourceOptions? opts = null)
    public static ObjectAccessControl get(String name, Output<String> id, ObjectAccessControlState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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 string
    The name of the bucket.
    Domain string
    The domain associated with the entity.
    Email string
    The email address associated with the entity.
    Entity 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
    EntityId string
    The ID for the entity
    Generation int
    The content generation of the object, if applied to an object.
    Object string
    The name of the object to apply the access control to.
    ProjectTeams List<ObjectAccessControlProjectTeam>
    The project team associated with the entity Structure is documented below.
    Role string
    The access permission for the entity. Possible values are: OWNER, READER.


    Bucket string
    The name of the bucket.
    Domain string
    The domain associated with the entity.
    Email string
    The email address associated with the entity.
    Entity 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
    EntityId string
    The ID for the entity
    Generation int
    The content generation of the object, if applied to an object.
    Object string
    The name of the object to apply the access control to.
    ProjectTeams []ObjectAccessControlProjectTeamArgs
    The project team associated with the entity Structure is documented below.
    Role string
    The access permission for the entity. Possible values are: OWNER, READER.


    bucket String
    The name of the bucket.
    domain String
    The domain associated with the entity.
    email String
    The email address associated with the entity.
    entity 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
    entityId String
    The ID for the entity
    generation Integer
    The content generation of the object, if applied to an object.
    object String
    The name of the object to apply the access control to.
    projectTeams List<ObjectAccessControlProjectTeam>
    The project team associated with the entity Structure is documented below.
    role String
    The access permission for the entity. Possible values are: OWNER, READER.


    bucket string
    The name of the bucket.
    domain string
    The domain associated with the entity.
    email string
    The email address associated with the entity.
    entity 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
    entityId string
    The ID for the entity
    generation number
    The content generation of the object, if applied to an object.
    object string
    The name of the object to apply the access control to.
    projectTeams ObjectAccessControlProjectTeam[]
    The project team associated with the entity Structure is documented below.
    role string
    The access permission for the entity. Possible values are: OWNER, READER.


    bucket str
    The name of the bucket.
    domain str
    The domain associated with the entity.
    email str
    The email address associated with the entity.
    entity str
    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 str
    The ID for the entity
    generation int
    The content generation of the object, if applied to an object.
    object str
    The name of the object to apply the access control to.
    project_teams Sequence[ObjectAccessControlProjectTeamArgs]
    The project team associated with the entity Structure is documented below.
    role str
    The access permission for the entity. Possible values are: OWNER, READER.


    bucket String
    The name of the bucket.
    domain String
    The domain associated with the entity.
    email String
    The email address associated with the entity.
    entity 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
    entityId String
    The ID for the entity
    generation Number
    The content generation of the object, if applied to an object.
    object String
    The name of the object to apply the access control to.
    projectTeams List<Property Map>
    The project team associated with the entity Structure is documented below.
    role String
    The access permission for the entity. Possible values are: OWNER, READER.


    Supporting Types

    ObjectAccessControlProjectTeam, ObjectAccessControlProjectTeamArgs

    ProjectNumber string
    The project team associated with the entity
    Team string
    The team. Possible values are: editors, owners, viewers.
    ProjectNumber string
    The project team associated with the entity
    Team string
    The team. Possible values are: editors, owners, viewers.
    projectNumber String
    The project team associated with the entity
    team String
    The team. Possible values are: editors, owners, viewers.
    projectNumber string
    The project team associated with the entity
    team string
    The team. Possible values are: editors, owners, viewers.
    project_number str
    The project team associated with the entity
    team str
    The team. Possible values are: editors, owners, viewers.
    projectNumber String
    The project team associated with the entity
    team String
    The team. Possible values are: editors, owners, viewers.

    Import

    ObjectAccessControl can be imported using any of these accepted formats:

    • {{bucket}}/{{object}}/{{entity}}

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

    $ pulumi import gcp:storage/objectAccessControl:ObjectAccessControl default {{bucket}}/{{object}}/{{entity}}
    

    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.
    gcp logo
    Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi