[英]How do I upload an updated JAR to an existing Java Elastic Beanstalk instance using the AWS CLI 2?
I have a Java Elastic Beanstalk instance set up manually through the web UI.我有一个通过 Web UI 手动设置的 Java Elastic Beanstalk 实例。
I can upload an updated JAR to it any time manually through the UI.我可以随时通过 UI 手动上传更新的 JAR。
How do I accomplish the same via the AWS CLI 2?如何通过 AWS CLI 2 完成相同的操作?
I use maven to build my JAR.我使用 maven 来构建我的 JAR。
mvn clean install
This generates the JAR my-app.jar
in the ./target
directory.这
my-app.jar
在./target
目录中生成 JAR my-app.jar
。
I then do the following然后我执行以下操作
export version=1.0-`date +"%Y%m%d-%H%M%S"`
This is an environment variable I'll use throughout the process.这是我将在整个过程中使用的环境变量。
Step 1. Upload the JAR to an S3 bucket步骤 1. 将 JAR 上传到 S3 存储桶
aws s3 cp ./target/my-app.jar s3://my-app.foo.bar/my-app-${version}.jar
Step 2. Create a Version of the Application in Elastic Beanstalk.步骤 2. 在 Elastic Beanstalk 中创建应用程序的一个版本。
This references the JAR uploaded to S3 in Step 1.这引用了在步骤 1 中上传到 S3 的 JAR。
aws elasticbeanstalk create-application-version \
--application-name my-app \
--version-label ${version} \
--source-bundle S3Bucket="my-app.foo.bar",S3Key="my-app-${version}.jar"
Step 3. Deploy the Version in Elastic Beanstalk步骤 3. 在 Elastic Beanstalk 中部署版本
aws elasticbeanstalk update-environment \
--application-name my-app \
--environment-name MyApp-env \
--version-label ${version}
The key points to note here are that;这里要注意的关键点是;
a) You don't deploy a JAR. a) 您不部署 JAR。 You deploy a Version.
您部署一个版本。 And the Version points to the JAR.
而版本指向 JAR。 This is distinct from (what you see) what you do through the UI, where you just upload the JAR and it gets deployed.
这不同于(您看到的)您通过 UI 执行的操作,在 UI 中您只需上传 JAR 并进行部署。
b) The source-bundle
of the Version points to the JAR. b) 版本的
source-bundle
指向 JAR。 Yes, although in the Java world, the word 'source' means something and a JAR is not source, in the Elastic Beanstalk world, the 'source' is your executable code是的,虽然在 Java 世界中,“源”这个词意味着某些东西,而 JAR 不是源,但在 Elastic Beanstalk 世界中,“源”是您的可执行代码
c) the JAR the Version points to has to be in S3. c) Version 指向的 JAR 必须在 S3 中。 That is where you upload your JAR.
这是您上传 JAR 的地方。
You do it in two sets :你分两组进行:
--version-label
for the version that you want to use.--version-label
。--version-label
from step 1.--version-label
。 Alternatively, you can use AWS EB CLI which is CLI tool specifically developed by AWS for EB.或者,您可以使用AWS EB CLI ,它是 AWS 专门为 EB 开发的 CLI 工具。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.