跳到正文

Modify the Program ​

Now that your storage bucket is provisioned, let's add an object to it. First, from within your project directory, create a new index.html file with some content in it.

bash
cat <<EOT > index.html
<html>
    <body>
        <h1>Hello, Pulumi!</h1>
    </body>
</html>
EOT

Now that you have your new index.html with some content, open your program file and modify it to add the contents of your index.html file to your storage bucket.

To accomplish this, you will use Pulumi's FileAsset class to assign the content of the file to a new BucketObject.

In index.ts, create the BucketObject right after creating the bucket itself.

typescript
const bucketObject = new gcp.storage.BucketObject("index.html", {
    bucket: bucket.name,
    source: new pulumi.asset.FileAsset("index.html")
});

Notice how you provide the bucket you created earlier as an input to your new BucketObject. This is so Pulumi knows what storage bucket the object should live in.

Next, you'll deploy your changes.

文档内容翻译自 Pulumi 官方文档。