Terraform 有没有办法在尝试创建资源之前检查 Google Cloud 中的资源是否存在?
我想检查作业期间我的 CircleCI CI/CD 管道中是否存在以下资源。我可以访问终端命令、bash 和 gcloud 命令。如果资源确实存在,我想使用它们。如果它们不存在,我想创建它们。我在 CircleCI 的 config.yml 中执行此逻辑,作为我可以访问终端命令和 bash 的步骤。我的目标是在需要时在 GCP 中创建必要的基础设施(资源),否则在创建后使用它们,而不会在 CI/CD 构建中出现 Terraform 错误。
如果我尝试创建已存在的资源,Terraform apply 将导致错误,提示“您已经拥有此资源”,现在我的 CI/CD 作业失败。
下面是描述我想要获取的资源的伪代码。
resource "google_artifact_registry_repository" "main" {
# this is the repo for hosting my Docker images
# it does not have a data source afaik because it is beta
}
Run Code Online (Sandbox Code Playgroud)
对于我的google_artifact_registry_repository资源。我的一种方法是使用数据源块执行 Terraform 应用并查看是否返回值。问题在于 google_artifact_registry_repository 没有数据源块。因此,我必须使用资源块创建此资源一次,之后的每个 CI/CD 构建都可以依赖它的存在。有没有解决方法可以读取它的存在?
resource "google_storage_bucket" "bucket" {
# bucket containing the folder below
}
resource "google_storage_bucket_object" …Run Code Online (Sandbox Code Playgroud) 我在 3.7.3 中使用了 jooq,现在我要升级到 jooq 3.12.0。我在生成的代码中看到编译错误。
使用 jooq 3.7.3 版,使用https://www.jooq.org/doc/3.7/manual/code-generation/custom-data-type-bindings/。我可以看到在生成的代码中使用了我的自定义数据绑定类(“MySqlJsonBinding”),并且生成的代码没有出现编译错误。
我的 jooq.xml 的一部分:
<customTypes>
<customType>
<name>JsonElement</name>
<type>com.google.gson.JsonElement</type>
<binding>jooq.MySqlJsonBinding</binding>
</customType>
</customTypes>
<forcedTypes>
<forcedType>
<name>JsonElement</name>
<expression>board_data</expression>
<types>JSON</types>
</forcedType>
</forcedTypes>
Run Code Online (Sandbox Code Playgroud)
生成的代码:没有编译错误
public final TableField<UserBoardRecord, JsonElement> BOARD_DATA = createField("board_data", org.jooq.impl.DefaultDataType.getDefaultDataType("json"), this, "", new MySqlJsonBinding());
Run Code Online (Sandbox Code Playgroud)
使用 jooq 3.12.0 版,以https://www.jooq.org/doc/latest/manual/code-generation/custom-data-type-bindings/为例。我在生成的代码中没有看到“MySqlJsonBinding”,所以我不确定它是否被包含在内。
我的 jooq.xml 的一部分:
<forcedTypes>
<forcedType>
<userType>com.google.gson.JsonElement</userType>
<binding>com.samplecompany.jooq.MySqlJsonBinding</binding>
<includeExpression>.*JSON.*</includeExpression>
<includeTypes>.*</includeTypes>
</forcedType>
</forcedTypes>
Run Code Online (Sandbox Code Playgroud)
生成的代码:没有编译错误,但没有 MySqlJsonBinding:
public final TableField<UserBoardRecord, JSON> BOARD_DATA = createField(DSL.name("board_data"), org.jooq.impl.SQLDataType.JSON, this, "");
Run Code Online (Sandbox Code Playgroud)
最后,我使用 3.12.0,尝试应用我用于 3.7.3 的方法。我确实得到了生成的代码,它确实包含 MySqlJsonBinding,但它有编译错误。
我的 jooq.xml 的一部分:
<forcedTypes> …Run Code Online (Sandbox Code Playgroud) 我的 HTML 页面的标题部分有一行由图标/文本/时间戳组成的行。我想让该行的图标和时间戳保持固定宽度,并且当浏览器调整大小时,我想通过显示省略号来减小文本 div(表格单元格)的大小。虽然我可以让省略号以固定宽度显示,但我希望文本 div(表格单元格)的宽度为 100%,直到浏览器变小,然后我希望此文本 div 变小并且省略号当这个 div 缩小时出现。
我可以使用媒体查询或动态调整大小的指令来解决这个问题,但我希望 HTML/CSS 可以解决它。
这可能吗?
这是一个示例: http: //jsfiddle.net/em83B/
<div style="display: table; table-layout: fixed;">
<div style="display: table-cell; background: pink; min-width: 60px;">
AAA
</div>
<div style="display: table-cell; background: yellow; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; min-width: 300px; max-width: 600px;">
This is the text I want to have truncated as the browser resizes
</div>
<div style="display: table-cell; background: lightblue; min-width: 100px;">
CCC
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我正在为我的MySQL数据库尝试Amazon Aurora.当我运行mysqldump时,我的数据库大约是600 GB.我有一个在本地运行的实例,一个在我的VPS中,一个在Aurora上(我在过去24小时内上传).
当我运行"从员工中选择sql_no_cache*"时 在这三种环境中的每一种环境中,我都看到Aurora需要更长的时间来返回超过100万条记录.我想尽可能地比较苹果和苹果.我在MySQL Workbench和终端上运行了这个查询.结果是本地大约3.5秒,Aurora上的VPS到214s.
在我放弃Aurora之前,任何想法为什么我都会看到这样的结果,我认为这种技术的性能比标准MySQL高5倍?正在查询我的Aurora数据库,就像我的MySQL数据库(使用Workbench或终端)对性能进行不切实际的测试一样?我是否需要进行一些进一步的配置或调整?
我相信Aurora很快,所以我一定做错了.如果从我的结尾查询这个很慢,那么我希望如果我的应用程序要查询它,它会是类似的.