【问题标题】:Update AWS stack with CF template使用 CF 模板更新 AWS 堆栈
【发布时间】:2021-02-20 00:47:25
【问题描述】:

希望大家注意安全!

我有一个托管在 AWS Beanstalk 上的 Ruby on Rails 应用程序。我正在使用 CloudFormation 模板来更新任何堆栈,例如 Ruby 版本、Linux 平台升级等。

我正在尝试升级,Linux 框升级到 2.11.7Ruby 升级到 2.6.6,然后 ElasticSearch 升级到 7.4

我在 CloudFormation YML 模板中进行这些更改,然后我运行 aws cloudformation update-stack 命令来应用这些更改。

虽然更改需要时间,但我不小心点击了 Web AWS 控制台中的 重建环境,所有之前配置的设置,如 SQS负载均衡器 等,已被新设置取代。

现在,每当我尝试执行 update-stack 命令时,它都会失败并出现以下错误:

2020-06-09 15:25:44 UTC+0530
WARN
Environment health has transitioned from Info to Degraded. Command failed on all instances. 
Incorrect application version found on all instances. Expected version "code-pipeline-xxxxxxxxxx" (deployment 2377). Application update failed 40 seconds ago and took 79 seconds.

2020-06-09 15:25:03 UTC+0530    
INFO
The environment was reverted to the previous configuration setting.

2020-06-09 15:24:44 UTC+0530    
INFO
Environment health has transitioned from Ok to Info. Application update in progress on 1 instance. 0 out of 1 instance completed (running for 39 seconds).

2020-06-09 15:24:30 UTC+0530    
ERROR
During an aborted deployment, some instances may have deployed the new application version. 
To ensure all instances are running the same version, re-deploy the appropriate application version.

2020-06-09 15:24:30 UTC+0530    
ERROR
Failed to deploy application.

2020-06-09 15:24:30 UTC+0530    
ERROR
Unsuccessful command execution on instance id(s) 'i-xxxxxxxxxx'. Aborting the operation.

2020-06-09 15:24:30 UTC+0530    
INFO
Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].

2020-06-09 15:24:30 UTC+0530    
ERROR
[Instance: i-xxxxxxxxxx] Command failed on instance. Return code: 18 Output: (TRUNCATED)...g: the running version of Bundler (1.16.0) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. Your Ruby version is 2.6.6, but your Gemfile specified 2.6.5. Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

2020-06-09 15:24:19 UTC+0530    
INFO
Deploying new version to instance(s).

2020-06-09 15:23:45 UTC+0530    
INFO
Updating environment developWeb's configuration settings.

2020-06-09 15:23:36 UTC+0530    
INFO
Environment update is starting.

我可以确认我设置了 Ruby-2.6.6。我不确定它是从哪里获取旧版 Ruby 的?

有什么办法可以解决这个问题吗?或强制应用模板更改?

对此的任何帮助将不胜感激。

[更新]:当我尝试从 Rails 控制台连接到 ElasticSearch 时,我得到:

Faraday::ConnectionFailed: Failed to open TCP connection to old-elasticsearch-host-name.es.amazonaws.com:80 (Hostname not known: old-elasticsearch-host-name.es.amazonaws.com)
from /opt/rubies/ruby-2.6.6/lib/ruby/2.6.0/net/http.rb:949:in `rescue in block in connect'
Caused by SocketError: Failed to open TCP connection to old-elasticsearch-host-name.es.amazonaws.com:80 (Hostname not known: old-elasticsearch-host-name.es.amazonaws.com)
from /opt/rubies/ruby-2.6.6/lib/ruby/2.6.0/net/http.rb:949:in `rescue in block in connect'
Caused by Resolv::ResolvError: no address for old-elasticsearch-host-name.es.amazonaws.com
from /opt/rubies/ruby-2.6.6/lib/ruby/2.6.0/resolv.rb:94:in `getaddress'

elasticsearch 实例的新 URL 不同,但它仍然从ELASTICSEARCH_HOST ENV 变量中获取旧 URL。

来自我的 CF 模板的信息:

我现在可以根据要求提供信息。请标记我以查看我在 CF 模板中的内容

【问题讨论】:

  • 我想知道 AWS Beanstalk 是否由 CloudFormation 管理。也许你可以分享你的模板?
  • 您的堆栈更新现在处于什么状态?
  • @Marcin 你的意思是?从 AWS 控制台,我的 web 和 worker env 都处于红色状态
  • 我的意思是 CloudFormation 堆栈。我了解您在堆栈中进行了一些更新,但同时您在 cloudformio 堆栈之外修改了资源?所以堆栈更新失败了?
  • @Marcin 是的,我在堆栈中做了一些更新,执行了 CF update-stack 命令,然后我重建了环境(这是我在 CF 堆栈之外进行的,即从 AWS 控制台)和从这一步开始,每次我尝试运行 update-stack 命令时都会失败

标签: ruby amazon-web-services amazon-cloudformation


【解决方案1】:

这是一个配置问题。

每当我运行aws update-stack 命令时,它都会进入 s3 并拉取 zip(源代码的)代码,并且在 Gemfile 中该邮政编码的 ruby​​ 版本设置为 2.6.5。

所以,我上传了源代码的新副本,然后执行了 update-stack 命令,它成功了

【讨论】:

    猜你喜欢
    • 2023-02-15
    • 1970-01-01
    • 1970-01-01
    • 2017-05-07
    • 2022-01-16
    • 2023-01-29
    • 2019-05-17
    • 2019-02-03
    • 2021-12-29
    相关资源
    最近更新 更多