如何通过CodeBuild从AWS S3下载文件

huangapple go评论69阅读模式
英文:

How to download files from AWS S3 via CodeBuild

问题

我有一个在AWS中构建的项目,它从GitHub获取一个自动化项目并运行它。我们用于上传到UI的所有文件当前都保存在项目的存储库中。我不喜欢这样,因为文件大约有300 - 400 MB,这太多了。我的想法是在构建项目之前使用CodeBuild Buildspec从AWS S3下载文件到服务器上。这种做法可行吗?

我对CodeBuild不太了解,所以我希望能得到一些指导。如果整个想法不可行,我将不得不使用项目设置,但在尝试下载文件时可能会出现很多问题。

英文:

I have a build in AWS who get an Automation Project from GitHub and runs it. All the files that we are using to upload to the UI are currently saved to the repo of the project. I don't like it as it is about 300 - 400 MB, and that is a lot. My idea is to use the CodeBuild Buildspec and download the files from AWS S3 to the server before the broject is build. Is this possible at all?

I am new the the CodeBuild so I prefer some guidance. If the whole idea is not possible, I will have to use the project SetUp but there are a lot of things that can break while trying to download the files.

答案1

得分: 2

有多种方法可以做到这一点,但一般来说,您必须生成一个 buildspec.yaml 文件,指导 AWS CodeBuild 执行您想要的操作。

AWS 文档实际上非常好,有很多示例。

这个示例 主要从S3下载源代码,次要从Github下载其他源代码。这可能符合您的用例。

还可以查看其他示例,它们可能有助于生成 buildspec.yaml 文件。

如果没有适合的示例,您仍然可以运行正常的bash命令并执行 aws s3 sync 或类似的操作。

英文:

There are multiple ways to do this, but in general you have to generate a buildspec.yaml that instructs AWS CodeBuild to do what you want.

The AWS Documentation is actually pretty good, there are a lot of examples.

This one downloads the source primiarily from S3 and secondary sources from Github. This might fit your use case.

Have a look at the other examples as well, they might help generating the buildspec.yaml

If none fits, you will still be able to run normal bash commands and do aws s3 sync or something similar.

答案2

得分: 2

以下是已翻译的部分:

在最后,只需添加一行代码来构建:

aws s3 cp s3://{folderPath} {path to download} --recursive

这将逐个下载文件夹中的所有文件,并等待它们全部下载完毕。

英文:

At the end it was just one row that had to be added in the build:

  aws s3 cp s3://{folderPath} {path to download} --recursive

This will download all files from the folder whatever you need them one by one and will wait for all to download.

huangapple
  • 本文由 发表于 2023年2月18日 02:05:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/75487837.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定