Can we compress the directory and push to S3 in z...
# general
b
Can we compress the directory and push to S3 in zip format?
g
You can compress a directory and push it up as an archive using
FileArchive
(https://www.pulumi.com/docs/intro/concepts/assets-archives/#archives)
Note that a folder may be passed to
FileArchive
to construct an archive from the contents of that folder. Also, both assets (single files) and archives (folders containing files) can be combined as part of building up an
AssetArchive
.
👍 1
b
how can we use FileArchive to convert folder to a zip ? @great-queen-39697
g
as the docs explain, you pass the directory path as a string to the
FileArchive()
call. For example, if my folder is in the same directory as my code and is called
folder
, I would code the following in Python:
Copy code
pulumi.FileArchive('./folder')
b
right, but it didnt pushed to S3 as .zip
how to push as zip only ?
g
ahh, I see what you're asking. Apologies. I don't know of a way to tell that call a specific output, so I'd use the compression library for your language of choice to compress the file, and then I'd pass that .zip file with
FileArchive
. So, for Python:
Copy code
shutil.make_archive('myzip', 'zip', './folder')
....
pulumi.FileArchive('myzip.zip')
👍 1
b
Thanks
🙌 1