2023-06-16 14:10:53 -07:00
---
title_tag: Deploy the Changes | Google Cloud
meta_desc: This page provides an overview of how deploy changes to a Google Cloud project.
title: Deploy changes
h1: "Pulumi & Google Cloud: Deploy changes"
weight: 7
menu:
clouds:
parent: google-cloud-get-started
identifier: gcp-deploy-changes
aliases:
- /docs/quickstart/gcp/deploy-changes/
- /docs/get-started/gcp/deploy-changes/
---
Now let's deploy your changes.
```bash
$ pulumi up
```
2023-08-04 10:59:33 -07:00
Pulumi will run the `preview` step of the update, which computes the minimally disruptive change to achieve the desired state described by the program:
2023-06-16 14:10:53 -07:00
```
2023-08-04 10:59:33 -07:00
Previewing update (dev)
2023-06-16 14:10:53 -07:00
2023-08-04 10:59:33 -07:00
Type Name Plan
pulumi:pulumi:Stack quickstart-dev
+ ├─ gcp:storage:BucketIAMBinding my-bucket-binding create
+ └─ gcp:storage:BucketObject index.html create
2023-06-16 14:10:53 -07:00
Resources:
2023-08-04 10:59:33 -07:00
+ 2 to create
2023-06-16 14:10:53 -07:00
2 unchanged
Do you want to perform this update?
> yes
no
details
```
2023-08-04 10:59:33 -07:00
Choosing `yes` will proceed with the update and write the `index.html` file to the bucket:
2023-06-16 14:10:53 -07:00
```
2023-08-04 10:59:33 -07:00
Updating (dev)
2023-06-16 14:10:53 -07:00
2023-08-04 10:59:33 -07:00
Type Name Status
pulumi:pulumi:Stack quickstart-dev
+ ├─ gcp:storage:BucketIAMBinding my-bucket-binding created (5s)
+ └─ gcp:storage:BucketObject index.html created (0.76s)
2023-06-16 14:10:53 -07:00
Outputs:
2023-08-04 10:59:33 -07:00
bucketName: "gs://my-bucket-daa12be"
2023-06-16 14:10:53 -07:00
Resources:
2023-08-04 10:59:33 -07:00
+ 2 created
2023-06-16 14:10:53 -07:00
2 unchanged
2023-08-04 10:59:33 -07:00
Duration: 8s
2023-06-16 14:10:53 -07:00
```
2023-08-04 10:59:33 -07:00
Once the update has completed, you can verify the object was created by checking the Google Cloud Console or running the following `gsutil` command:
2023-06-16 14:10:53 -07:00
{{< chooser language " javascript , typescript , python , go , csharp , java , yaml " > }}
{{% choosable language javascript %}}
```bash
$ gsutil ls $(pulumi stack output bucketName)
```
{{% /choosable %}}
{{% choosable language typescript %}}
```bash
$ gsutil ls $(pulumi stack output bucketName)
```
{{% /choosable %}}
{{% choosable language python %}}
```bash
$ gsutil ls $(pulumi stack output bucket_name)
```
{{% /choosable %}}
{{% choosable language go %}}
```bash
$ gsutil ls $(pulumi stack output bucketName)
```
{{% /choosable %}}
{{% choosable language csharp %}}
```bash
$ gsutil ls $(pulumi stack output bucketName)
```
{{% /choosable %}}
{{% choosable language java %}}
```bash
$ gsutil ls $(pulumi stack output bucketName)
```
{{% /choosable %}}
{{% choosable language yaml %}}
```bash
$ gsutil ls $(pulumi stack output bucketName)
```
{{% /choosable %}}
{{< / chooser > }}
Notice that your `index.html` file has been added to the bucket:
```bash
2023-08-04 10:59:33 -07:00
gs://my-bucket-daa12be/index.html-a52debd
2023-06-16 14:10:53 -07:00
```
{{% choosable language javascript %}}
2023-08-04 10:59:33 -07:00
Now that `index.html` exists in the bucket, modify the program to have the bucket serve the file as a static website.
2023-06-16 14:10:53 -07:00
2023-08-04 10:59:33 -07:00
To do that, update the bucket definition to configure its `website` property. Then, to align with Google Cloud Storage recommendations, set its uniform bucket-level access property to `true` :
2023-06-16 14:10:53 -07:00
```javascript
const bucket = new gcp.storage.Bucket("my-bucket", {
2023-08-01 14:02:11 +01:00
location: "US",
2023-06-16 14:10:53 -07:00
website: {
mainPageSuffix: "index.html"
},
uniformBucketLevelAccess: true
});
```
2023-08-04 10:59:33 -07:00
Finally, at the end of the file, export the website's public URL to make it easy to access:
2023-06-16 14:10:53 -07:00
```javascript
exports.bucketEndpoint = pulumi.concat("http://storage.googleapis.com/", bucket.name, "/", bucketObject.name);
```
{{% /choosable %}}
{{% choosable language typescript %}}
2023-08-04 10:59:33 -07:00
Now that `index.html` exists in the bucket, modify the program to have the bucket serve the file as a static website.
2023-06-16 14:10:53 -07:00
2023-08-04 10:59:33 -07:00
To do that, update the bucket definition to configure its `website` property. Then, to align with Google Cloud Storage recommendations, set its uniform bucket-level access property to `true` :
2023-06-16 14:10:53 -07:00
```typescript
const bucket = new gcp.storage.Bucket("my-bucket", {
2023-08-01 14:02:11 +01:00
location: "US",
2023-06-16 14:10:53 -07:00
website: {
mainPageSuffix: "index.html"
},
uniformBucketLevelAccess: true
});
```
2023-08-04 10:59:33 -07:00
Finally, at the end of the file, export the website's public URL to make it easy to access:
2023-06-16 14:10:53 -07:00
```typescript
export const bucketEndpoint = pulumi.concat("http://storage.googleapis.com/", bucket.name, "/", bucketObject.name);
```
{{% /choosable %}}
{{% choosable language python %}}
2023-08-04 10:59:33 -07:00
Now that `index.html` exists in the bucket, modify the program to have the bucket serve the file as a static website.
2023-06-16 14:10:53 -07:00
2023-08-04 10:59:33 -07:00
To do that, update the bucket definition to configure its `website` property. Then, to align with Google Cloud Storage recommendations, set its uniform bucket-level access property to `True` :
2023-06-16 14:10:53 -07:00
```python
2023-08-04 10:59:33 -07:00
bucket = storage.Bucket(
"my-bucket",
2023-08-01 14:02:11 +01:00
location="US",
2023-08-04 10:59:33 -07:00
website=storage.BucketWebsiteArgs(main_page_suffix="index.html"),
2023-06-16 14:10:53 -07:00
uniform_bucket_level_access=True,
)
```
2023-08-04 10:59:33 -07:00
Finally, at the end of the file, export the website's public URL to make it easy to access:
2023-06-16 14:10:53 -07:00
```python
2023-08-04 10:59:33 -07:00
pulumi.export(
"bucket_endpoint",
pulumi.Output.concat(
"http://storage.googleapis.com/", bucket.id, "/", bucket_object.name
),
2023-06-16 14:10:53 -07:00
)
```
{{% /choosable %}}
{{% choosable language go %}}
2023-08-04 10:59:33 -07:00
Now that `index.html` exists in the bucket, modify the program to have the bucket serve the file as a static website.
To do that, update the bucket definition to configure its `Website` property. Then, to align with Google Cloud Storage recommendations, set its uniform bucket-level access property to `true` :
2023-06-16 14:10:53 -07:00
```go
bucket, err := storage.NewBucket(ctx, "my-bucket", & storage.BucketArgs{
2023-08-01 14:02:11 +01:00
Location: pulumi.String("US"),
2023-06-16 14:10:53 -07:00
Website: storage.BucketWebsiteArgs{
MainPageSuffix: pulumi.String("index.html"),
},
UniformBucketLevelAccess: pulumi.Bool(true),
})
if err != nil {
return err
}
```
2023-08-04 10:59:33 -07:00
Finally, at the end of the file, export the website's public URL to make it easy to access.
2023-06-16 14:10:53 -07:00
```go
2023-08-04 10:59:33 -07:00
ctx.Export("bucketEndpoint", pulumi.Sprintf("http://storage.googleapis.com/%s/%s", bucket.Name, bucketObject.Name))
2023-06-16 14:10:53 -07:00
```
2023-08-04 10:59:33 -07:00
Be sure to change the variable name of the `BucketObject` from `_` to `bucketObject` in this step, or Go may fail to compile the program:
2023-06-16 14:10:53 -07:00
```go
bucketObject, err := storage.NewBucketObject(ctx, "index.html", & storage.BucketObjectArgs{
2023-08-04 10:59:33 -07:00
Bucket: bucket.Name,
Source: pulumi.NewFileAsset("index.html"),
2023-06-16 14:10:53 -07:00
})
```
{{% /choosable %}}
{{% choosable language csharp %}}
2023-08-04 10:59:33 -07:00
Now that `index.html` exists in the bucket, modify the program to have the bucket serve the file as a static website.
2023-06-16 14:10:53 -07:00
2023-08-04 10:59:33 -07:00
To do that, update the bucket definition to configure its `Website` property. Then, to align with Google Cloud Storage recommendations, set its uniform bucket-level access property to `true` :
2023-06-16 14:10:53 -07:00
```csharp
// Add this using statement
using Pulumi.Gcp.Storage.Inputs;
```
```csharp
var bucket = new Bucket("my-bucket", new BucketArgs
{
2023-08-01 14:02:11 +01:00
Location = "US",
2023-06-16 14:10:53 -07:00
Website = new BucketWebsiteArgs
{
MainPageSuffix = "index.html"
},
UniformBucketLevelAccess = true
});
```
2023-08-04 10:59:33 -07:00
Finally, at the end of the file, export the website's public URL to make it easy to access:
2023-06-16 14:10:53 -07:00
```csharp
return new Dictionary< string , object ? >
{
["bucketName"] = bucket.Url,
["bucketEndpoint"] = Output.Format($"http://storage.googleapis.com/{bucket.Name}/{bucketObject.Name}")
};
```
{{% /choosable %}}
{{% choosable language java %}}
2023-08-04 10:59:33 -07:00
Now that `index.html` exists in the bucket, modify the program to have the bucket serve the file as a static website.
2023-06-16 14:10:53 -07:00
2023-08-04 10:59:33 -07:00
To do that, add the `BucketWebsiteArgs` class to the list of imports, then update the bucket definition to configure its `website` property. To align with Google Cloud Storage recommendations, also set its uniform bucket-level access property to `true` :
2023-06-16 14:10:53 -07:00
```java
// ...
import com.pulumi.gcp.storage.inputs.BucketWebsiteArgs;
public class App {
public static void main(String[] args) {
Pulumi.run(ctx -> {
// Create an AWS resource (S3 Bucket)
2023-08-04 10:59:33 -07:00
var bucket = new Bucket("my-bucket", BucketArgs.builder()
.location("US")
.website(BucketWebsiteArgs.builder()
.mainPageSuffix("index.html")
.build())
.build());
2023-06-16 14:10:53 -07:00
//...
```
2023-08-04 10:59:33 -07:00
Finally, at the end of the file, export the website's public URL to make it easy to access:
2023-07-31 22:28:35 +01:00
```java
2023-08-04 10:59:33 -07:00
ctx.export("bucketEndpoint", Output.format("http://storage.googleapis.com/%s/%s", bucket.name(), bucketObject.name()));
2023-06-16 14:10:53 -07:00
```
{{% /choosable %}}
{{% choosable language yaml %}}
2023-08-04 10:59:33 -07:00
Now that `index.html` exists in the bucket, modify the program to have the bucket serve the file as a static website.
To do that, update the bucket definition to configure its `Website` property. Then, to align with Google Cloud Storage recommendations, set its uniform bucket-level access setting to `true` :
2023-06-16 14:10:53 -07:00
```yaml
resources:
my-bucket:
type: gcp:storage:Bucket
properties:
2023-08-04 10:59:33 -07:00
location: US
2023-06-16 14:10:53 -07:00
website:
mainPageSuffix: index.html
uniformBucketLevelAccess: true
```
2023-08-04 10:59:33 -07:00
Finally, at the end of the file, export the website's public URL to make it easy to access:
2023-06-16 14:10:53 -07:00
```yaml
# ...
outputs:
2023-08-04 10:59:33 -07:00
# ...
bucketEndpoint: http://storage.googleapis.com/${my-bucket.name}/${index-html.name}
2023-06-16 14:10:53 -07:00
```
{{% /choosable %}}
2023-08-04 10:59:33 -07:00
Give the stack one final update to apply these changes:
2023-06-16 14:10:53 -07:00
```bash
$ pulumi up
```
2023-08-04 10:59:33 -07:00
Again, you'll see a preview of the changes to be made:
2023-06-16 14:10:53 -07:00
```
2023-08-04 10:59:33 -07:00
Previewing update (dev)
2023-06-16 14:10:53 -07:00
2023-08-04 10:59:33 -07:00
Type Name Plan Info
pulumi:pulumi:Stack quickstart-dev
~ └─ gcp:storage:Bucket my-bucket update [diff: +website~uniformBucketLevelAccess]
2023-06-16 14:10:53 -07:00
Outputs:
2023-08-04 10:59:33 -07:00
+ bucketEndpoint: "http://storage.googleapis.com/my-bucket-daa12be/index.html-a52debd"
2023-06-16 14:10:53 -07:00
Resources:
~ 1 to update
2023-08-04 10:59:33 -07:00
3 unchanged
2023-06-16 14:10:53 -07:00
Do you want to perform this update?
> yes
no
details
```
2023-08-04 10:59:33 -07:00
Choose `yes` to deploy them:
2023-06-16 14:10:53 -07:00
```
2023-08-04 10:59:33 -07:00
Updating (dev)
Type Name Status Info
pulumi:pulumi:Stack quickstart-dev
~ └─ gcp:storage:Bucket my-bucket updated (1s) [diff: +website~uniformBucketLevelAccess]
2023-06-16 14:10:53 -07:00
Outputs:
2023-08-04 10:59:33 -07:00
+ bucketEndpoint: "http://storage.googleapis.com/my-bucket-daa12be/index.html-a52debd"
bucketName : "gs://my-bucket-daa12be"
2023-06-16 14:10:53 -07:00
Resources:
~ 1 updated
2023-08-04 10:59:33 -07:00
3 unchanged
2023-06-16 14:10:53 -07:00
2023-08-04 10:59:33 -07:00
Duration: 4s
2023-06-16 14:10:53 -07:00
```
2023-08-04 10:59:33 -07:00
When the deployment completes, you can check out your new static website at the URL under `Outputs` , or make a `curl` request and see the contents of `index.html` printed to the terminal:
2023-06-16 14:10:53 -07:00
{{% choosable language javascript %}}
```bash
$ curl $(pulumi stack output bucketEndpoint)
```
{{% /choosable %}}
{{% choosable language typescript %}}
```bash
$ curl $(pulumi stack output bucketEndpoint)
```
{{% /choosable %}}
{{% choosable language python %}}
```bash
$ curl $(pulumi stack output bucket_endpoint)
```
{{% /choosable %}}
{{% choosable language go %}}
```bash
$ curl $(pulumi stack output bucketEndpoint)
```
{{% /choosable %}}
{{% choosable language csharp %}}
```bash
$ curl $(pulumi stack output bucketEndpoint)
```
{{% /choosable %}}
{{% choosable language java %}}
```bash
$ curl $(pulumi stack output bucketEndpoint)
```
{{% /choosable %}}
{{% choosable language yaml %}}
```bash
$ curl $(pulumi stack output bucketEndpoint)
```
{{% /choosable %}}
And you should see:
```bash
< html >
< body >
< h1 > Hello, Pulumi!< / h1 >
< / body >
< / html >
```
Next you will destroy the resources.
{{< get-started-stepper > }}