deployment - 如何通过cloudformation部署opsworks应用程序?

标签 deployment aws-cloudformation aws-opsworks

在 cloudformation 模板中,我创建了一个 opsworks 堆栈、一个层、一个实例和一个应用程序。该模板通过食谱和脚本的厨师食谱来设置和配置实例。如何从模板自动部署应用程序,而无需手动单击堆栈内的部署?部署后,将执行说明书中定义的 Deloy 配方:

"MyLayer": {
    "Type": "AWS::OpsWorks::Layer",
    "DependsOn" : "OpsWorksServiceRole",
    "Properties": {
     "AutoAssignElasticIps" : false,
     "AutoAssignPublicIps" : true,
     "CustomRecipes" : {
       "Setup"     : ["cassandra::setup","awscli::setup","settings::setup"],
       "Deploy": ["imports::deploy"]
    },
     "CustomSecurityGroupIds" : { "Ref" : "SecurityGroupIds" },
     "EnableAutoHealing" : true,
     "InstallUpdatesOnBoot": false,
     "LifecycleEventConfiguration": {
       "ShutdownEventConfiguration": {
       "DelayUntilElbConnectionsDrained": false,
       "ExecutionTimeout": 120 }
     },
     "Name": "script-node",
     "Shortname" : "node",
     "StackId": { "Ref": "MyStack" },
     "Type": "custom",
     "UseEbsOptimizedInstances": true,
     "VolumeConfigurations": [ {
       "Iops": 10000,
       "MountPoint": "/dev/sda1",
       "NumberOfDisks": 1,
       "Size": 20,
       "VolumeType": "gp2"
     }]
  }
}

应用程序如下所示:enter image description here

有什么想法吗? 谢谢。

最佳答案

CreateDeployment API 调用会生成一个一次性事件,该事件会在 OpsWorks 堆栈中执行 Deploy 操作。我认为没有任何官方 CloudFormation 资源直接映射到此,但以下是有关如何在 CloudFormation 模板上下文中调用它的一些想法:

  • 写一个Custom Resource创建时调用 CreateDeployment(例如,通过适用于 Node.js 的 AWS 开发工具包)。
  • 添加AWS::CodePipeline::Pipeline将资源添加到配置为在部署阶段中部署 OpsWorks 应用程序的模板。请参阅Using AWS CodePipeline with AWS OpsWorks Stacks有关此集成的文档。 (虽然它是一个额外的服务 + 复杂性层,但我认为 CodePipeline 无论如何都是一个更好的抽象层,用于对应用程序堆栈中的部署操作进行建模。)

关于deployment - 如何通过cloudformation部署opsworks应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41258791/

相关文章:

django - git push Heroku main - 错误 : src refspec main does not match any

amazon-web-services - “GetObject 时发生错误。S3 错误代码 : PermanentRedirect. S3 错误消息:存储桶位于此区域:us-east-1

java - AWS Opsworks Java 应用程序服务器 403 错误

deployment - Capistrano 部署 :setup works but not deploy:check

deployment - Visual Studio-一键发布,Web部署,非dll文件问题

api - 在同一域中分离后端和前端应用程序?

ruby-on-rails - 在 ubuntu 14.04 上安装 rmagick gem

amazon-web-services - CloudFormation - 如何在服务中引用子网 ID

amazon-web-services - AWS cloudformation 域名和 API 映射

nginx - 根据某些查询参数的存在选择服务器 block