GCSCreateBucketOperator

Google

Creates a new bucket. Google Cloud Storage uses a flat namespace, so you can’t create a bucket with a name that is already in use.

View Source

Last Updated: May. 7, 2021

Access Instructions

Install the Google provider package into your Airflow environment.

Import the module into your DAG file and instantiate it with your desired params.

Parameters

bucket_namestrThe name of the bucket. (templated)
resourcedictAn optional dict with parameters for creating the bucket. For information on available parameters, see Cloud Storage API doc: https://cloud.google.com/storage/docs/json_api/v1/buckets/insert
storage_classstrThis defines how objects in the bucket are stored and determines the SLA and the cost of storage (templated). Values includeMULTI_REGIONALREGIONALSTANDARDNEARLINECOLDLINE.If this value is not specified when the bucket is created, it will default to STANDARD.
locationstrThe location of the bucket. (templated) Object data for objects in the bucket resides in physical storage within this region. Defaults to US.
project_idstrThe ID of the Google Cloud Project. (templated)
labelsdictUser-provided labels, in key/value pairs.
gcp_conn_idstr(Optional) The connection ID used to connect to Google Cloud.
google_cloud_storage_conn_idstr(Deprecated) The connection ID used to connect to Google Cloud. This parameter has been deprecated. You should pass the gcp_conn_id parameter instead.
delegate_tostrThe account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have domain-wide delegation enabled.
impersonation_chainUnion[str, Sequence[str]]Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

Documentation

Creates a new bucket. Google Cloud Storage uses a flat namespace, so you can’t create a bucket with a name that is already in use.

See also

For more information, see Bucket Naming Guidelines: https://cloud.google.com/storage/docs/bucketnaming.html#requirements

The following Operator would create a new bucket test-bucket with MULTI_REGIONAL storage class in EU region

CreateBucket = GoogleCloudStorageCreateBucketOperator( task_id='CreateNewBucket', bucket_name='test-bucket', storage_class='MULTI_REGIONAL', location='EU', labels={'env': 'dev', 'team': 'airflow'}, gcp_conn_id='airflow-conn-id' )

Was this page helpful?