https://pulumi.com logo
Title
b

brave-doctor-12316

04/07/2022, 6:48 PM
Can we compress the directory and push to S3 in zip format?
g

great-queen-39697

04/07/2022, 7:12 PM
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

brave-doctor-12316

04/07/2022, 7:30 PM
how can we use FileArchive to convert folder to a zip ? @great-queen-39697
g

great-queen-39697

04/07/2022, 7:33 PM
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:
pulumi.FileArchive('./folder')
b

brave-doctor-12316

04/07/2022, 7:34 PM
right, but it didnt pushed to S3 as .zip
how to push as zip only ?
g

great-queen-39697

04/07/2022, 7:59 PM
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:
shutil.make_archive('myzip', 'zip', './folder')
....
pulumi.FileArchive('myzip.zip')
👍 1
b

brave-doctor-12316

04/07/2022, 9:06 PM
Thanks
🙌 1