- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我定义了以下简单的管道:
image:
name: hashicorp/terraform:light
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
variables:
PLAN: dbrest.tfplan
STATE: dbrest.tfstate
cache:
paths:
- .terraform
before_script:
- terraform --version
- terraform init
stages:
- validate
- build
- deploy
- destroy
validate:
stage: validate
script:
- terraform validate
plan:
stage: build
script:
- terraform plan -state=$STATE -out=$PLAN
artifacts:
name: plan
paths:
- $PLAN
- $STATE
apply:
stage: deploy
environment:
name: production
script:
- terraform apply -state=$STATE -input=false $PLAN
- terraform state show aws_instance.bastion
dependencies:
- plan
when: manual
only:
- master
destroy:
stage: destroy
environment:
name: production
script:
- terraform destroy -state=$STATE -auto-approve
dependencies:
- apply
when: manual
only:
- master
当我运行它时,一切都非常成功 - 但 destroy
阶段实际上并没有破坏我在 apply
阶段创建的环境。这是我所看到的:
Running with gitlab-runner 10.5.0 (80b03db9)
on ip-10-74-163-110 5cf66672
Using Docker executor with image hashicorp/terraform:light ...
Pulling docker image hashicorp/terraform:light ...
Using docker image sha256:5d5c9faad78b96bb84555a584fe729260d7ff7d3fb973e105690ddc0dab48fb5 for hashicorp/terraform:light ...
Running on runner-5cf66672-project-1136-concurrent-0 via ip-10-197-79-116...
Fetching changes...
Removing .terraform/
Removing dbrest.tfplan
Removing dbrest.tfstate
HEAD is now at f798b05 Update .gitlab-ci.yml
Checking out f798b05a as master...
Skipping Git submodules setup
Checking cache for default-1...
Successfully extracted cache
$ terraform --version
Terraform v0.12.13
+ provider.aws v2.34.0
$ terraform init
Initializing the backend...
Initializing provider plugins...
The following providers do not have any version constraints in configuration,
so the latest version was installed.
To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.
* provider.aws: version = "~> 2.34"
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
$ terraform destroy -state=$STATE -auto-approve
Destroy complete! Resources: 0 destroyed.
Creating cache default-1...
.terraform: found 5 matching files
Created cache
Job succeeded
很明显,我调用 terraform destroy
的方式缺少了一些东西,但我不知道是什么 - 有人可以解释一下吗?
最佳答案
您没有正确地从 apply
作业传递状态,因为您没有像 plan
-> apply< 那样设置工件
。您的申请
工作应如下所示:
apply:
stage: deploy
environment:
name: production
script:
- terraform apply -state=$STATE -input=false $PLAN
- terraform state show aws_instance.bastion
artifacts:
name: apply
paths:
- $STATE
dependencies:
- plan
when: manual
only:
- master
但是,更好的解决方案是不在这里使用基于文件的状态,而是使用正确的 remote state (例如 S3 如果您使用的是 AWS),或者稍后当多个用户(包括 CI 作为潜在的自并发用户)运行 Terraform 时,您将会遇到大量问题。这使您可以利用state locking并且还允许对状态文件进行版本控制,以防 Terraform 操作期间出现问题,例如将状态作为重构的一部分移动。
关于terraform - 亚特实验室 CI : terraform destroy doesn't destroy?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58728425/
我有两个类(class): parent 和 child child : belongs_to :parent 和 家长 has_many :children, :dependent => :dest
我有这个模型 class XmlImport ["text/xml"] end :event_import_records 条目正在被销毁。但是 :events 不是。 has_many throu
我定义了以下简单的管道: image: name: hashicorp/terraform:light entrypoint: - '/usr/bin/env' - 'PATH
我定义了以下简单的管道: image: name: hashicorp/terraform:light entrypoint: - '/usr/bin/env' - 'PATH
在我们的应用程序中,我们覆盖了 ActiveRecord destroy 方法,以便我们的记录不会被删除(因此用户可以取消删除)。像这样: def destroy self.is_deleted
我有一个笔记模型,具有以下关联 注意.rb has_many :note_categories, :dependent => :destroy has_many :categories, :throu
我是一名 Python 初学者。尝试制作一个新按钮来关闭窗口。我收到错误消息: Exception in Tkinter callback Traceback (most recent call la
我在我的应用程序中添加了评论功能,到目前为止一切正常,直到出现此错误。我所做的是添加了删除评论功能。当我启动服务器时一切正常,但在我单击“删除”按钮后问题出现了。 错误信息 undefined loc
Rails,def destroy,没有响应 destroy.js.erb 这是我的方法: # DELETE /Groups/1 # DELETE /Groups/1.xml def de
假设我有一个 MyClass 对象的集合 MyCollection。 Set MyCollection = Nothing 是否调用每个包含的对象的析构函数,或者我应该单独设置每个对象 = Nothi
我正在尝试使用 Node.js、Express 和 Mongodb 构建 REST API。我正在使用 mongodb npm 包连接到数据库,下面是我的 sever.js 文件代码 var expr
我有一个小问题,我有以下两个模型: class CriticalProcess :destroy has_many :roles, :through => :authorizations a
我正在使用 ng2-toastr 并收到以下错误 https://www.npmjs.com/package/ng2-toastr Attempt to use a destroyed view: d
基本信息: 系统: # cat /proc/version Linux version 3.10.0-514.2.2.el7.x86_64 (builder@kbuilder.dev.centos.o
一 点睛 destroy 用于销毁 ThreadGroup,该方法只是针对一个没有任何 active 线程的 group 进行一次 destroy 标记,调用该方法的直接结果是在父 group 中将自
我开始注意到 Scope::Guard 的一些奇怪之处。 . 如果我取消定义 $guard变量作为 sub 中的最后一个语句,守卫的 sub 得到 比我预期的要晚打电话。 如果我不取消它,或者如果我做
我正在构建一个提供打开和关闭它的服务的模式。该模式有一个控制关闭按钮的小 Controller ,以及进入模式内容的模板的 $compile。 那个模板就是一个组件,当然,那个组件有一个 Contro
一直在文件馆和网上寻找答案,但没有真正找到答案,只是零零碎碎。似乎有很多建议的帖子,但没有一个有答案。 我有一个使用范围的复杂指令:true。它实际上是我正在尝试为其编写清理代码的 ng-grid 最
给定以下 Delphi 代码,Foo 在 FormClose 上是 Free,但 TFoo.Destroy 是没有被调用 - 因此 Bar 没有被 Free'd,导致内存泄漏? 我是否在这里错过了一些
https://docs.angularjs.org/guide/directive By listening to this event, you can remove event listener
我是一名优秀的程序员,十分优秀!