Package: pulumi-synced-folder
synced-folderA Pulumi component that synchronizes a local folder to Amazon S3, Azure Blob Storage, or Google Cloud Storage.InstallingThe component is available in these Pulumi-supported languages:JavaScript/TypeScript:@pulumi/synced-folderPython:pulumi_synced_folderGo:github.com/pulumi/pulumi-synced-folder/sdk/go/synced-folder.NET:Pulumi.SyncedFolderYAMLUsing the componentGiven a cloud-storage bucket and the path to a local folder, the component synchronizes files from the folder to the bucket, deleting any files in the destination bucket that don't exist locally. It does this in one of two ways:By managing each file as an individual Pulumi resource (aws.s3.BucketObject,azure.storage.Blob, orgcp.storage.BucketObject). This is the component's default behavior.By delegating sync responsibility to a cloud provider CLI (e.g.,aws,az, orgcloud/gsutil). This behavior is enabled by setting themanagedObjectsinput property tofalseand ensuring the relevant CLI tool is installed alongsidepulumi.The former approach — having Pulumi manage your resources for you — is generally preferable, but in some cases, for example  a website consisting of thousands of files, it may not be the best fit. This component lets you choose the approach that works best for you, without having to brek out of your Pulumi program or workflow.Below are a few examples in Pulumi YAML, each of which assumes the existence of asitefolder containing one or more files to be uploaded. See theexamplesfolder for additional languages and scenarios.Sync to an S3 bucketHere, a local folder,./site, is pushed to Amazon S3, its contents managed as individuals3.BucketObjects:name:synced-folder-examples-aws-yamlruntime:yamldescription:An example of using the synced-folder component.resources:s3-bucket:type:aws:s3:Bucketproperties:acl:public-readwebsite:indexDocument:index.htmlerrorDocument:error.html# 👇synced-bucket-folder:type:synced-folder:index:S3BucketFolderproperties:path:./sitebucketName:${s3-bucket.bucket}acl:public-readoutputs:url:http://${s3-bucket.websiteEndpoint}Sync to an Azure Blob Storage containerHere, the folder's contents are synced to an Azure Blob Storage container, but instead of managing each file as anazure.storage.Blob, the component invokes the Azure CLI (specifically theaz storage blob synccommand) withPulumi Command. The optionalmanagedObjectsproperty lets you configure this behavior on a folder-by-folder basis.name:synced-folder-examples-azure-yamlruntime:yamldescription:An example of using the synced-folder component in YAML.resources:resource-group:type:azure-native:resources:ResourceGroupstorage:type:azure-native:storage:StorageAccountproperties:resourceGroupName:${resource-group.name}kind:StorageV2sku:name:Standard_LRSwebsite:type:azure-native:storage:StorageAccountStaticWebsiteproperties:resourceGroupName:${resource-group.name}accountName:${storage.name}indexDocument:index.htmlerror404Document:error.html# 👇synced-azure-blob-folder:type:synced-folder:index:AzureBlobFolderproperties:path:./siteresourceGroupName:${resource-group.name}storageAccountName:${storage.name}containerName:${website.containerName}managedObjects:false# 👈  Sync files with the Azure CLI.outputs:url:${storage.primaryEndpoints.web}Sync to a Google Cloud Storage bucketHere,./siteis synced to a Google Cloud Storage bucket.name:synced-folder-examples-google-cloud-yamlruntime:yamldescription:An example of using the synced-folder component in YAML.resources:gcp-bucket:type:gcp:storage:Bucketproperties:location:USwebsite:mainPageSuffix:index.htmlnotFoundPage:error.htmlgcp-bucket-iam-binding:type:gcp:storage:BucketIAMBindingproperties:bucket:${gcp-bucket.name}role:roles/storage.objectViewermembers:-allUsers# 👇synced-google-cloud-folder:type:synced-folder:index:GoogleCloudFolderproperties:path:./sitebucketName:${gcp-bucket.name}outputs:url:https://storage.googleapis.com/${gcp-bucket.name}/index.htmlConfigurationThe following input properties are common to all three resource types:PropertyTypeDescriptionpathstringThe path (relative or fully-qualified) to the folder containing the files to be synced. Required.managedObjectsbooleanWhether to have Pulumi manage files as individual cloud resources. Defaults totrue. See below for details.Additional resource-specific properties are listed below.S3BucketFolderpropertiesPropertyTypeDescriptionbucketNamestringThe name of the S3 bucket to sync to (e.g.,my-bucketins3://my-bucket). Required.aclstringThe AWSCanned ACLto apply to each file (e.g.,public-read). Required.AzureBlobFolderpropertiesPropertyTypeDescriptioncontainerNamestringThe name of the Azure storage container to sync to. Required.storageAccountNamestringThe name of the Azure storage account that the container belongs to. Required.resourceGroupNamestringThe name of the Azure resource group that the storage account belongs to. Required.GoogleCloudFolderpropertiesPropertyTypeDescriptionbucketNamestringThe name of the Google Cloud Storage bucket to sync to (e.g.,my-bucketings://my-bucket). Required.NotesUsing themanagedObjectspropertyBy default, the component manages your files as individual Pulumi cloud resources, but you can opt out of this behavior by setting the component'smanagedObjectsproperty tofalse. When you do this, the component assumes you've installed the appropriate CLI tool —aws,az, orgcloud/gsutil, depending on the cloud — and uses theCommandprovider to issue commands on that tool directly. Files are one-way synchronized only (local to remote), and files that exist remotely but not locally are deleted. All files are deleted from remote storage onpulumi destroy.The component does not yet support switching seamlessly betweenmanagedObjects: trueandmanagedObjects: false, however, so if you find after deploying a given folder with managed objects that you'd prefer to use unmanaged objects instead (or vice-versa), we recommend creating a second bucket/storage container and folder and removing the first. You can generally do this within the scope of a single program update. For example:# ...resources:# The original bucket and synced-folder resources, using managed file objects.## my-first-bucket:#   type: aws:s3:Bucket#   properties:#     acl: public-read#     website:#       indexDocument: index.html#       errorDocument: error.html## my-first-synced-folder:#   type: synced-folder:index:S3BucketFolder#   properties:#     path: ./stuff#     bucketName: ${my-first-bucket.bucket}#     acl: public-read# A new bucket and synced-folder using unmanaged file objects.changed-my-mind-bucket:type:aws:s3:Bucketproperties:acl:public-readwebsite:indexDocument:index.htmlerrorDocument:error.htmlchanged-my-mind-synced-folder:type:synced-folder:index:S3BucketFolderproperties:path:./stuffbucketName:${changed-my-mind-bucket.bucket}acl:public-readmanagedObjects:falseoutputs:# An updated program reference pointing to the new bucket.url:http://${changed-my-mind-bucket.websiteEndpoint}