Modify the Program
Now that your storage account 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.
cat <<EOT > index.html
<html>
<body>
<h1>Hello, Pulumi!</h1>
</body>
</html>
EOTNow that you have your new index.html with some content, you can enable static website support, upload index.html to a storage container, and retrieve a public URL through the use of resource properties. These properties can be used to define dependencies between related resources or to retrieve property values for further processing.
To start, open index.ts and add the following right after the storage account creation:
// Enable static website support
const staticWebsite = new storage.StorageAccountStaticWebsite("staticWebsite", {
accountName: storageAccount.name,
resourceGroupName: resourceGroup.name,
indexDocument: "index.html",
});The static website resource leverages the storage account and resource group names defined previously in your program.
Now use all of these cloud resources, and a local FileAsset resource, to upload index.html into your storage container.
// Upload the file
const indexHtml = new storage.Blob("index.html", {
resourceGroupName: resourceGroup.name,
accountName: storageAccount.name,
containerName: staticWebsite.containerName,
source: new pulumi.asset.FileAsset("index.html"),
contentType: "text/html",
});Finally, at the end of index.ts, export the resulting storage container's endpoint URL to stdout for easy access:
// Web endpoint to the website
export const staticEndpoint = storageAccount.primaryEndpoints.web;Now that you have declared how you want your resources to be provisioned, it is time to deploy these remaining changes.