我正在尝试将eu-central-1颁发的证书用于我的 apigateway,它是区域性的并且在同一区域工作。
我的地形代码如下:
//ACM Certificate
provider "aws" {
region = "eu-central-1"
alias = "eu-central-1"
}
resource "aws_acm_certificate" "certificate" {
provider = "aws.eu-central-1"
domain_name = "*.kumite.xyz"
validation_method = "EMAIL"
}
//Apigateway
resource "aws_api_gateway_rest_api" "kumite_writer_api" {
name = "kumite_writer_api"
endpoint_configuration {
types = ["REGIONAL"]
}
}
resource "aws_api_gateway_domain_name" "domain_name" {
certificate_arn = aws_acm_certificate.certificate.arn
domain_name = "recorder.kumite.xyz"
endpoint_configuration {
types = ["REGIONAL"]
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,我不断收到此错误:
错误:创建 API 网关域名时出错:BadRequestException:无法在 REGIONAL 处于活动状态时为 EDGE 导入证书。
我在这里缺少什么?我认为我的 ApiGateway 不是 EDGE 而是 REGIONAL,所以找不到错误的意义......
我正在为 编写某种包装模块azurerm_storage_account。
azurerm_storage_account有可选块
static_website {
index_document = string
error_404_document = string
}
Run Code Online (Sandbox Code Playgroud)
我想根据变量设置它,但我不太确定该怎么做?条件运算符实际上不适用于块(例如static_website = var.disable ? null : { .. })
或者块是否以这样的方式工作,如果我设置index_document和error_404_document,它与完全不设置块null相同?static_website
azurerm@2.x
TF@0.12.x
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) 我们正在研究Terraform作为管理基础设施的一种方式,它看起来非常有趣.
但是,目前我们的公司代理/防火墙terraform apply由于安全限制而导致失败.
在我们等待解决这些网络问题的同时,有什么方法可以在本地试验Terraform而无需连接到Azure或AWS?也许有Virtual Box?
这个AWS角色究竟做了什么?
最相关的比特似乎是:
"Action": "sts:AssumeRole",和
"Service": "ec2.amazonaws.com"
完整的角色在这里:
resource "aws_iam_role" "test_role" {
name = "test_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
Run Code Online (Sandbox Code Playgroud)
来自:https://www.terraform.io/docs/providers/aws/r/iam_role.html
我想为DynamoDB表创建一个具有多个(> 10)属性的Terraform配置.我没有必要将所有属性添加为global_secondary_index或作为索引
local_secondary_index.但是当我运行terraform plan命令时,我有下一个错误:
All attributes must be indexed. Unused attributes: ...
我在validateDynamoDbTableAttributes函数中的Terraform存储库中找到了验证检查.
但据我所知,最佳做法是each table in DynamoDB is limited to a maximum of five global secondary indexes and five local secondary indexes来自DynamoDB中二级索引的一般指南.
由于我有超过10个属性,因此对我来说这似乎是一个问题.
我想了解为什么必须索引所有属性以及如果您拥有大量属性该怎么做.
谢谢!
我正在将 AWS Lambda 代码作为 zip 文件上传到 S3 存储桶中。
我有一个为 S3 存储桶对象声明的资源:
resource "aws_s3_bucket_object" "source-code-object" {
bucket = "${aws_s3_bucket.my-bucket.id}"
key = "source-code.zip"
source = "lambda_source_code/source-code.zip"
etag = "${base64sha256(file("lambda_source_code/source-code.zip"))}"
}
Run Code Online (Sandbox Code Playgroud)
我还有一个数据声明来压缩我的代码:
data "archive_file" "source-code-zip" {
type = "zip"
source_file = "${path.module}/lambda_source_code/run.py"
output_path = "${path.module}/lambda_source_code/source-code.zip"
}
Run Code Online (Sandbox Code Playgroud)
输出terraform apply不断向我显示哈希值的更改:
~ aws_s3_bucket_object.source-code-object
etag: "old_hash" => "new_hash"
Run Code Online (Sandbox Code Playgroud)
即使我的源代码中没有任何更改。为什么会出现这种行为?我见过类似的帖子,其中 Lambda 的源代码不断变化,但我的 Lambda 实际上并没有每次都更新(在控制台中检查了上次更新时间)。但是,看起来确实在每个apply.
我正在 Azure 中部署 Web 应用程序,我想忽略对site_config块中scm_type属性的更改。
在部署期间,scm_type属性设置为None,稍后我们将在 Azure 门户中将其更改为不同的内容。
我当前的 TF 代码如下所示:
resource "azurerm_app_service" "web_app" {
count = length(var.app_names)
name = var.app_names[count.index]
location = data.azurerm_resource_group.app_resource_group.location
resource_group_name = data.azurerm_resource_group.app_resource_group.name
app_service_plan_id = azurerm_app_service_plan.app_plan.id
tags = var.tags
app_settings = var.app_settings[count.index]
site_config {
always_on = true
websockets_enabled = var.websockets_enabled[count.index]
use_32_bit_worker_process = var.use_32_bit_worker_process
scm_type = "None"
}
lifecycle {
ignore_changes = [
site_config.0.scm_type
]
}
}
Run Code Online (Sandbox Code Playgroud)
我希望 terraform 计划在基础设施更新期间忽略scm_type 的变化,但它试图将其恢复为None。来自地形计划输出的行:
~ scm_type …
我正在开发一个 terraform 项目。在其中,我想要一个文件包含许多变量。我希望可以从项目的任何模块访问这些变量。我已经查看了文档和 udemy 课程,但仍然不知道如何做到这一点。在 Terraform 中如何做到这一点?谢谢!
当我使用 terraform 创建 vpc 流日志模块到 s3 存储桶时,它会抛出如下错误:
An argument named "flow_log_destination_type" is not expected here.
An argument named "flow_log_destination_arn" is not expected here.
Run Code Online (Sandbox Code Playgroud)
在 Terraform 文档中,我可以看到要填写的详细信息,例如log_destination_type & log_destination_arn,并且我在 GitHub 上找到了一些文档,这些文档完全相同,但在尝试时它对我不起作用
产生以下错误:
Error: Unsupported argument
on main.tf line 52, in module "vpc_with_flow_logs_s3_bucket":
52: flow_log_destination_type = "s3"
An argument named "flow_log_destination_type" is not expected here.
Error: Unsupported argument
on main.tf line 53, in module "vpc_with_flow_logs_s3_bucket":
53: flow_log_destination_arn = "${aws_s3_bucket.terra-test2-lifecycle.arn}"
An argument named "flow_log_destination_arn" is not expected here.
Error: Unsupported argument …Run Code Online (Sandbox Code Playgroud)