google.cloud.gcp_storage_bucket module – Creates a GCP Bucket
Note
This module is part of the google.cloud collection (version 1.0.2).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install google.cloud
.
To use it in a playbook, specify: google.cloud.gcp_storage_bucket
.
Synopsis
The Buckets resource represents a bucket in Google Cloud Storage. There is a single global namespace shared by all buckets. For more information, see Bucket Name Requirements.
Buckets contain objects which can be accessed by their own methods. In addition to the acl property, buckets contain bucketAccessControls, for use in fine-grained manipulation of an existing bucket’s access controls.
A bucket is always owned by the project team owners group.
Requirements
The below requirements are needed on the host that executes this module.
python >= 2.6
requests >= 2.18.4
google-auth >= 1.3.0
Parameters
Parameter |
Comments |
---|---|
Access controls on the bucket. |
|
The name of the bucket. This field represents a link to a Bucket resource in GCP. It can be specified in two ways. First, you can place a dictionary with key ‘name’ and value of your resource’s name Alternatively, you can add register: name-of-resource to a gcp_storage_bucket task and then set this bucket field to “{{ name-of-resource }}” |
|
The entity holding the permission, in one of the following forms: user-userId user-email group-groupId group-email domain-domain project-team-projectId allUsers allAuthenticatedUsers Examples: The user liz@example.com would be user-liz@example.com. The group example@googlegroups.com would be group-example@googlegroups.com. To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com. |
|
The ID for the entity. |
|
The project team associated with the entity. |
|
The project team associated with the entity. |
|
The team. Some valid choices include: “editors”, “owners”, “viewers” |
|
The access permission for the entity. Some valid choices include: “OWNER”, “READER”, “WRITER” |
|
The type of credential used. Choices:
|
|
The bucket’s Cross-Origin Resource Sharing (CORS) configuration. |
|
The value, in seconds, to return in the Access-Control-Max-Age header used in preflight responses. |
|
The list of HTTP methods on which to include CORS response headers, (GET, OPTIONS, POST, etc) Note: “*” is permitted in the list of methods, and means “any method”. |
|
The list of Origins eligible to receive CORS response headers. Note: “*” is permitted in the list of origins, and means “any Origin”. |
|
The list of HTTP headers other than the simple response headers to give permission for the user-agent to share across domains. |
|
Whether or not to automatically apply an eventBasedHold to new objects added to the bucket. Choices:
|
|
Default access controls to apply to new objects when no ACL is provided. |
|
The name of the bucket. This field represents a link to a Bucket resource in GCP. It can be specified in two ways. First, you can place a dictionary with key ‘name’ and value of your resource’s name Alternatively, you can add register: name-of-resource to a gcp_storage_bucket task and then set this bucket field to “{{ name-of-resource }}” |
|
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 . |
|
The name of the object, if applied to an object. |
|
The access permission for the entity. Some valid choices include: “OWNER”, “READER” |
|
Specifies which Ansible environment you’re running this module within. This should not be set unless you know what you’re doing. This only alters the User Agent string for any API requests. |
|
Labels applied to this bucket. A list of key->value pairs. |
|
The bucket’s lifecycle configuration. See https://developers.google.com/storage/docs/lifecycle for more information. |
|
A lifecycle management rule, which is made of an action to take and the condition(s) under which the action will be taken. |
|
The action to take. |
|
Target storage class. Required iff the type of the action is SetStorageClass. |
|
Type of the action. Currently, only Delete and SetStorageClass are supported. Some valid choices include: “Delete”, “SetStorageClass” |
|
The condition(s) under which the action will be taken. |
|
Age of an object (in days). This condition is satisfied when an object reaches the specified age. |
|
A date in RFC 3339 format with only the date part (for instance, “2013-01-15”). This condition is satisfied when an object is created before midnight of the specified date in UTC. |
|
Relevant only for versioned objects. If the value is true, this condition matches live objects; if the value is false, it matches archived objects. Choices:
|
|
Objects having any of the storage classes specified by this condition will be matched. Values include MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE, STANDARD, and DURABLE_REDUCED_AVAILABILITY. |
|
Relevant only for versioned objects. If the value is N, this condition is satisfied when there are at least N versions (including the live version) newer than this version of the object. |
|
The location of the bucket. Object data for objects in the bucket resides in physical storage within this region. Defaults to US. See the developer’s guide for the authoritative list. |
|
The bucket’s logging configuration, which defines the destination bucket and optional name prefix for the current bucket’s logs. |
|
The destination bucket where the current bucket’s logs should be placed. |
|
A prefix for log object names. |
|
The metadata generation of this bucket. |
|
The name of the bucket. |
|
The owner of the bucket. This is always the project team’s owner group. |
|
The entity, in the form project-owner-projectId. |
|
Apply a predefined set of default object access controls to this bucket. Acceptable values are: - “authenticatedRead”: Object owner gets OWNER access, and allAuthenticatedUsers get READER access.
Some valid choices include: “authenticatedRead”, “bucketOwnerFullControl”, “bucketOwnerRead”, “private”, “projectPrivate”, “publicRead” |
|
The Google Cloud Platform project to use. |
|
Array of scopes to be used |
|
The contents of a Service Account JSON file, either in a dictionary or as a JSON string that represents it. |
|
An optional service account email address if machineaccount is selected and the user does not wish to use the default email. |
|
The path of a Service Account JSON file if serviceaccount is selected as type. |
|
Whether the given object should exist in GCP Choices:
|
|
The bucket’s default storage class, used whenever no storageClass is specified for a newly-created object. This defines how objects in the bucket are stored and determines the SLA and the cost of storage. Values include MULTI_REGIONAL, REGIONAL, STANDARD, NEARLINE, COLDLINE, ARCHIVE, and DURABLE_REDUCED_AVAILABILITY. If this value is not specified when the bucket is created, it will default to STANDARD. For more information, see storage classes. Some valid choices include: “MULTI_REGIONAL”, “REGIONAL”, “STANDARD”, “NEARLINE”, “COLDLINE”, “ARCHIVE”, “DURABLE_REDUCED_AVAILABILITY” |
|
The bucket’s versioning configuration. |
|
While set to true, versioning is fully enabled for this bucket. Choices:
|
|
The bucket’s website configuration, controlling how the service behaves when accessing bucket contents as a web site. See the Static Website Examples for more information. |
|
If the requested object path is missing, the service will ensure the path has a trailing ‘/’, append this suffix, and attempt to retrieve the resulting object. This allows the creation of index.html objects to represent directory pages. |
|
If the requested object path is missing, and any mainPageSuffix object is missing, if applicable, the service will return the named object from this bucket as the content for a 404 Not Found result. |
Examples
- name: create a bucket
google.cloud.gcp_storage_bucket:
name: ansible-storage-module
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Access controls on the bucket. Returned: success |
|
The name of the bucket. Returned: success |
|
The domain associated with the entity. Returned: success |
|
The email address associated with the entity. Returned: success |
|
The entity holding the permission, in one of the following forms: user-userId user-email group-groupId group-email domain-domain project-team-projectId allUsers allAuthenticatedUsers Examples: The user liz@example.com would be user-liz@example.com. The group example@googlegroups.com would be group-example@googlegroups.com. To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com. Returned: success |
|
The ID for the entity. Returned: success |
|
The ID of the access-control entry. Returned: success |
|
The project team associated with the entity. Returned: success |
|
The project team associated with the entity. Returned: success |
|
The team. Returned: success |
|
The access permission for the entity. Returned: success |
|
The bucket’s Cross-Origin Resource Sharing (CORS) configuration. Returned: success |
|
The value, in seconds, to return in the Access-Control-Max-Age header used in preflight responses. Returned: success |
|
The list of HTTP methods on which to include CORS response headers, (GET, OPTIONS, POST, etc) Note: “*” is permitted in the list of methods, and means “any method”. Returned: success |
|
The list of Origins eligible to receive CORS response headers. Note: “*” is permitted in the list of origins, and means “any Origin”. Returned: success |
|
The list of HTTP headers other than the simple response headers to give permission for the user-agent to share across domains. Returned: success |
|
Whether or not to automatically apply an eventBasedHold to new objects added to the bucket. Returned: success |
|
Default access controls to apply to new objects when no ACL is provided. Returned: success |
|
The name of the bucket. Returned: success |
|
The domain associated with the entity. Returned: success |
|
The email address associated with the entity. Returned: success |
|
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 . Returned: success |
|
The ID for the entity. Returned: success |
|
The content generation of the object, if applied to an object. Returned: success |
|
The ID of the access-control entry. Returned: success |
|
The name of the object, if applied to an object. Returned: success |
|
The project team associated with the entity. Returned: success |
|
The project team associated with the entity. Returned: success |
|
The team. Returned: success |
|
The access permission for the entity. Returned: success |
|
The ID of the bucket. For buckets, the id and name properities are the same. Returned: success |
|
Labels applied to this bucket. A list of key->value pairs. Returned: success |
|
The bucket’s lifecycle configuration. See https://developers.google.com/storage/docs/lifecycle for more information. Returned: success |
|
A lifecycle management rule, which is made of an action to take and the condition(s) under which the action will be taken. Returned: success |
|
The action to take. Returned: success |
|
Target storage class. Required iff the type of the action is SetStorageClass. Returned: success |
|
Type of the action. Currently, only Delete and SetStorageClass are supported. Returned: success |
|
The condition(s) under which the action will be taken. Returned: success |
|
Age of an object (in days). This condition is satisfied when an object reaches the specified age. Returned: success |
|
A date in RFC 3339 format with only the date part (for instance, “2013-01-15”). This condition is satisfied when an object is created before midnight of the specified date in UTC. Returned: success |
|
Relevant only for versioned objects. If the value is true, this condition matches live objects; if the value is false, it matches archived objects. Returned: success |
|
Objects having any of the storage classes specified by this condition will be matched. Values include MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE, STANDARD, and DURABLE_REDUCED_AVAILABILITY. Returned: success |
|
Relevant only for versioned objects. If the value is N, this condition is satisfied when there are at least N versions (including the live version) newer than this version of the object. Returned: success |
|
The location of the bucket. Object data for objects in the bucket resides in physical storage within this region. Defaults to US. See the developer’s guide for the authoritative list. Returned: success |
|
The bucket’s logging configuration, which defines the destination bucket and optional name prefix for the current bucket’s logs. Returned: success |
|
The destination bucket where the current bucket’s logs should be placed. Returned: success |
|
A prefix for log object names. Returned: success |
|
The metadata generation of this bucket. Returned: success |
|
The name of the bucket. Returned: success |
|
The owner of the bucket. This is always the project team’s owner group. Returned: success |
|
The entity, in the form project-owner-projectId. Returned: success |
|
The ID for the entity. Returned: success |
|
Apply a predefined set of default object access controls to this bucket. Acceptable values are: - “authenticatedRead”: Object owner gets OWNER access, and allAuthenticatedUsers get READER access.
Returned: success |
|
A valid API project identifier. Returned: success |
|
The project number of the project the bucket belongs to. Returned: success |
|
The bucket’s default storage class, used whenever no storageClass is specified for a newly-created object. This defines how objects in the bucket are stored and determines the SLA and the cost of storage. Values include MULTI_REGIONAL, REGIONAL, STANDARD, NEARLINE, COLDLINE, ARCHIVE, and DURABLE_REDUCED_AVAILABILITY. If this value is not specified when the bucket is created, it will default to STANDARD. For more information, see storage classes. Returned: success |
|
The creation time of the bucket in RFC 3339 format. Returned: success |
|
The modification time of the bucket in RFC 3339 format. Returned: success |
|
The bucket’s versioning configuration. Returned: success |
|
While set to true, versioning is fully enabled for this bucket. Returned: success |
|
The bucket’s website configuration, controlling how the service behaves when accessing bucket contents as a web site. See the Static Website Examples for more information. Returned: success |
|
If the requested object path is missing, the service will ensure the path has a trailing ‘/’, append this suffix, and attempt to retrieve the resulting object. This allows the creation of index.html objects to represent directory pages. Returned: success |
|
If the requested object path is missing, and any mainPageSuffix object is missing, if applicable, the service will return the named object from this bucket as the content for a 404 Not Found result. Returned: success |
Authors
Google Inc. (@googlecloudplatform)