Vit*_*nko 2 amazon-web-services node.js amazon-elastic-beanstalk
我目前的部署过程:
我是否可以仅使用AWS SDK(nodeJS)将代码部署到EB实例?
Vit*_*nko 13
发现自己.您需要将ZIP文件上传到S3.然后,您需要为EB Application创建应用程序版本(使用唯一标签和ZIP文件所在的S3Key).然后,您需要使用新的Versionlabel更新EB环境(如果需要,请不要忘记指定Node start脚本).
也许这段代码对某人有用:
var aws = require('aws-sdk');
var s3 = new aws.S3();
var eb = new aws.ElasticBeanstalk();
var zipFileName = 'myCodeZipArchive.zip';
var appName = 'app-name';
var envName = 'env-name';
var s3bucket = 'my-app-source-bucket';
var label = `${appName}_${envName}_${new Date().toISOString()}`;
s3.upload({
Bucket: s3bucket,
Key: label,
Body: fs.createReadStream(zipFileName)
}).promise().then(() => eb.createApplicationVersion({
ApplicationName: appName,
VersionLabel: label,
SourceBundle: {
S3Bucket: s3bucket,
S3Key: label
}
}).promise()).then(() => eb.updateEnvironment({
ApplicationName: appName,
EnvironmentName: envName,
OptionSettings: [{
Namespace: 'aws:elasticbeanstalk:container:nodejs',
OptionName: 'NodeCommand',
Value: 'npm start'
}],
VersionLabel: label
}).promise());
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
426 次 |
最近记录: |