Expand description
Creates a new bucket in Google cloud storage service (GCS). Once a bucket has been created, its location can’t be changed.
For more information see the official documentation and API.
Note: If the project id is not set on the resource or in the provider block it will be dynamically determined which will require enabling the compute api.
§Example Usage
§Creating A Private Bucket In Standard Storage, In The EU Region. Bucket Configured As Static Website And CORS Configurations
resources:
static-site:
type: gcp:storage:Bucket
properties:
name: image-store.com
location: EU
forceDestroy: true
uniformBucketLevelAccess: true
website:
mainPageSuffix: index.html
notFoundPage: 404.html
cors:
- origins:
- http://image-store.com
methods:
- GET
- HEAD
- PUT
- POST
- DELETE
responseHeaders:
- '*'
maxAgeSeconds: 3600
§Life Cycle Settings For Storage Bucket Objects
resources:
auto-expire:
type: gcp:storage:Bucket
properties:
name: auto-expiring-bucket
location: US
forceDestroy: true
lifecycleRules:
- condition:
age: 3
action:
type: Delete
- condition:
age: 1
action:
type: AbortIncompleteMultipartUpload
§Life Cycle Settings For Storage Bucket Objects With Send_age_if_zero
Disabled
When creating a life cycle condition that does not also include an age
field, a default age
of 0 will be set. Set the send_age_if_zero
flag to false
to prevent this and avoid any potentially unintended interactions.
resources:
no-age-enabled:
type: gcp:storage:Bucket
properties:
name: no-age-enabled-bucket
location: US
forceDestroy: true
lifecycleRules:
- action:
type: Delete
condition:
daysSinceNoncurrentTime: 3
sendAgeIfZero: false
§Enabling Public Access Prevention
resources:
auto-expire:
type: gcp:storage:Bucket
properties:
name: no-public-access-bucket
location: US
forceDestroy: true
publicAccessPrevention: enforced
§Import
Storage buckets can be imported using the name
or project/name
. If the project is not
passed to the import command it will be inferred from the provider block or environment variables.
If it cannot be inferred it will be queried from the Compute API (this will fail if the API is
not enabled).
-
{{project_id}}/{{bucket}}
-
{{bucket}}
When using the pulumi import
command, Storage buckets can be imported using one of the formats above. For example:
$ pulumi import gcp:storage/bucket:Bucket default {{bucket}}
$ pulumi import gcp:storage/bucket:Bucket default {{project_id}}/{{bucket}}
false
in state. If you’ve set it to true
in config, run pulumi up
to
update the value set in state. If you delete this resource before updating the
value, objects in the bucket will not be destroyed.
Structs§
- Use builder syntax to set the inputs and finish with
build_struct()
.
Functions§
- Registers a new resource with the given unique name and arguments