gcp_storage_bucket - Creates a GCP Bucket

New in version 2.6.

Synopsis

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 Choices/Defaults Comments
acl
Access controls on the bucket.
project_team
The project team associated with the entity.
project_number
The project team associated with the entity.
team
    Choices:
  • editors
  • owners
  • viewers
The team.
domain
The domain associated with the entity.
bucket
required
The name of the bucket.
entity_id
The ID for the entity.
entity
required
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 [email protected] would be [email protected]
To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com.
role
    Choices:
  • OWNER
  • READER
  • WRITER
The access permission for the entity.
id
The ID of the access-control entry.
email
The email address associated with the entity.
auth_kind
required
    Choices:
  • machineaccount
  • serviceaccount
  • application
The type of credential used.
cors
The bucket's Cross-Origin Resource Sharing (CORS) configuration.
origin
The list of Origins eligible to receive CORS response headers.
Note: "*" is permitted in the list of origins, and means "any Origin".
response_header
The list of HTTP headers other than the simple response headers to give permission for the user-agent to share across domains.
max_age_seconds
The value, in seconds, to return in the Access-Control-Max-Age header used in preflight responses.
method
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".
default_object_acl
(added in 2.7)
Default access controls to apply to new objects when no ACL is provided.
project_team
The project team associated with the entity.
project_number
The project team associated with the entity.
team
    Choices:
  • editors
  • owners
  • viewers
The team.
domain
The domain associated with the entity.
generation
The content generation of the object, if applied to an object.
object
The name of the object, if applied to an object.
bucket
required
The name of the bucket.
entity_id
The ID for the entity.
entity
required
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 [email protected] would be [email protected]
To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com.
email
The email address associated with the entity.
role
    Choices:
  • OWNER
  • READER
The access permission for the entity.
id
The ID of the access-control entry.
lifecycle
The bucket's lifecycle configuration.
rule
A lifecycle management rule, which is made of an action to take and the condition(s) under which the action will be taken.
action
The action to take.
storage_class
Target storage class. Required iff the type of the action is SetStorageClass.
type
    Choices:
  • Delete
  • SetStorageClass
Type of the action. Currently, only Delete and SetStorageClass are supported.
condition
The condition(s) under which the action will be taken.
num_newer_versions
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.
matches_storage_class
Objects having any of the storage classes specified by this condition will be matched. Values include MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, STANDARD, and DURABLE_REDUCED_AVAILABILITY.
is_live
bool
    Choices:
  • no
  • yes
Relevant only for versioned objects. If the value is true, this condition matches live objects; if the value is false, it matches archived objects.
created_before
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.
age_days
Age of an object (in days). This condition is satisfied when an object reaches the specified age.
location
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.
logging
The bucket's logging configuration, which defines the destination bucket and optional name prefix for the current bucket's logs.
log_bucket
The destination bucket where the current bucket's logs should be placed.
log_object_prefix
A prefix for log object names.
metageneration
The metadata generation of this bucket.
name
The name of the bucket.
owner
The owner of the bucket. This is always the project team's owner group.
entity_id
The ID for the entity.
entity
The entity, in the form project-owner-projectId.
predefined_default_object_acl
    Choices:
  • authenticatedRead
  • bucketOwnerFullControl
  • bucketOwnerRead
  • private
  • projectPrivate
  • publicRead
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.
- "bucketOwnerFullControl": Object owner gets OWNER access, and project team owners get OWNER access.
- "bucketOwnerRead": Object owner gets OWNER access, and project team owners get READER access.
- "private": Object owner gets OWNER access.
- "projectPrivate": Object owner gets OWNER access, and project team members get access according to their roles.
- "publicRead": Object owner gets OWNER access, and allUsers get READER access.
project Default:
None
A valid API project identifier.
scopes
Array of scopes to be used.
service_account_email
An optional service account email address if machineaccount is selected and the user does not wish to use the default email.
service_account_file
The path of a Service Account JSON file if serviceaccount is selected as type.
state
    Choices:
  • present ←
  • absent
Whether the given object should exist in GCP
storage_class
    Choices:
  • MULTI_REGIONAL
  • REGIONAL
  • STANDARD
  • NEARLINE
  • COLDLINE
  • DURABLE_REDUCED_AVAILABILITY
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, 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.
versioning
The bucket's versioning configuration.
enabled
bool
    Choices:
  • no
  • yes
While set to true, versioning is fully enabled for this bucket.
website
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.
main_page_suffix
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.
not_found_page
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.

Notes

Note

  • For authentication, you can set service_account_file using the GCP_SERVICE_ACCOUNT_FILE env variable.
  • For authentication, you can set service_account_email using the GCP_SERVICE_ACCOUNT_EMAIL env variable.
  • For authentication, you can set auth_kind using the GCP_AUTH_KIND env variable.
  • For authentication, you can set scopes using the GCP_SCOPES env variable.
  • Environment variables values will only be used if the playbook values are not set.
  • The service_account_email and service_account_file options are mutually exclusive.

Examples

- name: create a bucket
  gcp_storage_bucket:
      name: ansible-storage-module
      project: "test_project"
      auth_kind: "service_account"
      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 Returned Description
acl
complex
success
Access controls on the bucket.

  project_team
complex
success
The project team associated with the entity.

    project_number
str
success
The project team associated with the entity.

    team
str
success
The team.

  domain
str
success
The domain associated with the entity.

  bucket
dict
success
The name of the bucket.

  entity_id
str
success
The ID for the entity.

  entity
str
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 [email protected] would be [email protected]
To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com.

  role
str
success
The access permission for the entity.

  id
str
success
The ID of the access-control entry.

  email
str
success
The email address associated with the entity.

cors
complex
success
The bucket's Cross-Origin Resource Sharing (CORS) configuration.

  origin
list
success
The list of Origins eligible to receive CORS response headers.
Note: "*" is permitted in the list of origins, and means "any Origin".

  response_header
list
success
The list of HTTP headers other than the simple response headers to give permission for the user-agent to share across domains.

  max_age_seconds
int
success
The value, in seconds, to return in the Access-Control-Max-Age header used in preflight responses.

  method
list
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".

default_object_acl
complex
success
Default access controls to apply to new objects when no ACL is provided.

  project_team
complex
success
The project team associated with the entity.

    project_number
str
success
The project team associated with the entity.

    team
str
success
The team.

  domain
str
success
The domain associated with the entity.

  generation
int
success
The content generation of the object, if applied to an object.

  object
str
success
The name of the object, if applied to an object.

  bucket
dict
success
The name of the bucket.

  entity_id
str
success
The ID for the entity.

  entity
str
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 [email protected] would be [email protected]
To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com.

  email
str
success
The email address associated with the entity.

  role
str
success
The access permission for the entity.

  id
str
success
The ID of the access-control entry.

id
str
success
The ID of the bucket. For buckets, the id and name properities are the same.

lifecycle
complex
success
The bucket's lifecycle configuration.

  rule
complex
success
A lifecycle management rule, which is made of an action to take and the condition(s) under which the action will be taken.

    action
complex
success
The action to take.

      storage_class
str
success
Target storage class. Required iff the type of the action is SetStorageClass.

      type
str
success
Type of the action. Currently, only Delete and SetStorageClass are supported.

    condition
complex
success
The condition(s) under which the action will be taken.

      num_newer_versions
int
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.

      matches_storage_class
list
success
Objects having any of the storage classes specified by this condition will be matched. Values include MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, STANDARD, and DURABLE_REDUCED_AVAILABILITY.

      is_live
bool
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.

      created_before
str
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.

      age_days
int
success
Age of an object (in days). This condition is satisfied when an object reaches the specified age.

location
str
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.

logging
complex
success
The bucket's logging configuration, which defines the destination bucket and optional name prefix for the current bucket's logs.

  log_bucket
str
success
The destination bucket where the current bucket's logs should be placed.

  log_object_prefix
str
success
A prefix for log object names.

metageneration
int
success
The metadata generation of this bucket.

name
str
success
The name of the bucket.

owner
complex
success
The owner of the bucket. This is always the project team's owner group.

  entity_id
str
success
The ID for the entity.

  entity
str
success
The entity, in the form project-owner-projectId.

predefined_default_object_acl
str
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.
- "bucketOwnerFullControl": Object owner gets OWNER access, and project team owners get OWNER access.
- "bucketOwnerRead": Object owner gets OWNER access, and project team owners get READER access.
- "private": Object owner gets OWNER access.
- "projectPrivate": Object owner gets OWNER access, and project team members get access according to their roles.
- "publicRead": Object owner gets OWNER access, and allUsers get READER access.

project
str
success
A valid API project identifier.

project_number
int
success
The project number of the project the bucket belongs to.

storage_class
str
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, 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.

time_created
str
success
The creation time of the bucket in RFC 3339 format.

updated
str
success
The modification time of the bucket in RFC 3339 format.

versioning
complex
success
The bucket's versioning configuration.

  enabled
bool
success
While set to true, versioning is fully enabled for this bucket.

website
complex
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.

  main_page_suffix
str
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.

  not_found_page
str
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.



Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Maintenance

This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.

For a list of other modules that are also maintained by the Ansible Community, see here.

Author

  • Google Inc. (@googlecloudplatform)

Hint

If you notice any issues in this documentation you can edit this document to improve it.