假设我有一个公共托管区域名称example.com.
。我使用以下 Terraform 代码根据文档的名称动态获取托管区域 ID 。
data "aws_route53_zone" "main" {
name = "example.com." # Notice the dot!!!
private_zone = false
}
Run Code Online (Sandbox Code Playgroud)
在terraform plan
它出现此错误期间:
Error refreshing state: 1 error(s) occurred:
* data.aws_route53_zone.main: no matching Route53Zone found
Run Code Online (Sandbox Code Playgroud)
是否有我应该报告的错误或我遗漏了什么?
我之前在该us-east-1
区域中创建了一个存储桶,其中包含我要在其他区域部署的Lambda代码.当我在us-west-2
区域中尝试使用相同代码的Terraform部署时,我收到以下错误:
Error creating Lambda function: InvalidParameterValueException: Error occurred while GetObject. S3 Error Code: PermanentRedirect. S3 Error Message: The bucket is in this region: us-east-1. Please use this region to retry the request
Run Code Online (Sandbox Code Playgroud)
我认为无法在Terraform的aws_lambda_function
资源中指定S3存储桶的区域.
使用Terraform,是否可以在一个区域中提供S3存储桶,以提供可在其他区域部署的Lambda代码?
我试图使用Terraform自动化应用程序网关的部署已经有些长时间了,但是它失败并显示一条错误消息。我确保所有协议设置都为HTTPS。但是,我怀疑PFX证书是否有些混乱。
是否由于失败而未提供身份验证证书?在网络上进行了大量尝试以获得解决方案,但是对此没有提及。
Terraform代码:
# Create a resource group
resource "azurerm_resource_group" "rg" {
name = "my-rg-application-gateway-12345"
location = "West US"
}
# Create a application gateway in the web_servers resource group
resource "azurerm_virtual_network" "vnet" {
name = "my-vnet-12345"
resource_group_name = "${azurerm_resource_group.rg.name}"
address_space = ["10.254.0.0/16"]
location = "${azurerm_resource_group.rg.location}"
}
resource "azurerm_subnet" "sub1" {
name = "my-subnet-1"
resource_group_name = "${azurerm_resource_group.rg.name}"
virtual_network_name = "${azurerm_virtual_network.vnet.name}"
address_prefix = "10.254.0.0/24"
}
resource "azurerm_subnet" "sub2" {
name = "my-subnet-2"
resource_group_name = "${azurerm_resource_group.rg.name}"
virtual_network_name = "${azurerm_virtual_network.vnet.name}"
address_prefix = "10.254.2.0/24" …
Run Code Online (Sandbox Code Playgroud) 我已经保存terraform plan -out=my-plan
并打算将其保存到源代码管理中,并进一步注入到自定义工具中,以进行摄取和执行测试等。
但是,的文件内容my-plan
混乱,我想知道使用的编码是什么。
否则,有没有办法另存my-plan
为人类可读的文本格式?
我想设置一个 Terraform 模块,根据 Terraforms策略分配示例将策略分配给 Azure 资源。
为了分配允许位置策略,我想将允许位置列表作为字符串列表从 variables.tf 文件传递到 main.tf,在那里执行分配。
#Allowed Locations Policy Assignment
resource "azurerm_policy_assignment" "allowedlocations" {
name = "allowed-locations"
scope = var.scope_allowedlocations
policy_definition_id = var.policy_allowedlocations.id
description = "This policy enables you to restrict the locations."
display_name = "Allowed Locations"
parameters = <<PARAMETERS
{
"allowedLocations": {
"value": ${var.listofallowedlocations}
}
}
PARAMETERS
}
Run Code Online (Sandbox Code Playgroud)
# Scope of the Allowed Locations policy
variable "scope_allowedlocations" {
description = "The scope of the allowed locations assignment."
default = …
Run Code Online (Sandbox Code Playgroud) 由于域已经存在,我将该区域导入到我的配置中:
resource "aws_route53_zone" "example_hosted_zone" {
name = "example.club"
}
Run Code Online (Sandbox Code Playgroud)
53号公路记录:
resource "aws_route53_record" "us-battasks" {
zone_id = aws_route53_zone.example_hosted_zone.zone_id
name = "us-battasks"
type = "CNAME"
ttl = "60"
records = [aws_lb.restricted_access_lb.id]
}
resource "aws_route53_record" "us-battasksapi" {
zone_id = aws_route53_zone.example_hosted_zone.zone_id
name = "us-battasksapi"
type = "CNAME"
ttl = "60"
records = [aws_lb.restricted_access_lb.id]
}
Run Code Online (Sandbox Code Playgroud)
Terraform 计划显示它将创建资源,但当我应用时,我收到以下错误:
Error: [ERR]: Error building changeset: InvalidChangeBatch: [Invalid Resource Record: FATAL problem: DomainLabelTooLong (Domain label is too long) encountered with 'arn:aws:elasticloadbalancing:us-east-1:221124075124:loadbalancer', Unparseable CNAME encountered]
status code: 400, request id: …
Run Code Online (Sandbox Code Playgroud) amazon-web-services amazon-route53 terraform terraform-provider-aws
我想知道某个种子值是否更适合于一个norm dist数据样本,而不是一个倾斜的集合.我知道在相同的数据上使用相同的种子将获得相同的随机生成的记录,我只是想知道种子1-10是否更好是一个负偏斜的数据范围,90-100在正偏斜上更好.
Terraform允许您使用选项username
和定义Postgres主用户和密码password
。但是没有设置应用程序postgres用户的选项,您将如何做?
我有以下Terraform代码使用新的任务定义来更新服务:
resource "aws_ecs_task_definition" "app_definition" {
family = "my-family"
container_definitions = "${data.template_file.task_definition.rendered}"
network_mode = "bridge"
}
resource "aws_ecs_service" "app_service" {
name = "my-service"
cluster = "my-cluster"
task_definition = "${aws_ecs_task_definition.app_definition.arn}"
desired_count = "1"
iam_role = "my-iam-role"
}
Run Code Online (Sandbox Code Playgroud)
更新我的服务时,我的任务定义的上一个修订版本无效。结果,在尝试在ECS控制台中手动回滚到以前的版本时,无法选择它:
Error: No active task definition found
Run Code Online (Sandbox Code Playgroud)
理想情况下,我希望保持最近的X版本处于活动状态,以便在出现问题时始终可以通过控制台手动回滚。
我该如何实现?
我要让Terraform在另一个需要MFA的帐户中担任IAM角色真是太糟糕了。这是我的设置
AWS配置
[default]
region = us-west-2
output = json
[profile GEHC-000]
region = us-west-2
output = json
....
[profile GEHC-056]
source_profile = GEHC-000
role_arn = arn:aws:iam::~069:role/hc/hc-master
mfa_serial = arn:aws:iam::~183:mfa/username
external_id = ~069
Run Code Online (Sandbox Code Playgroud)
AWS凭证
[default]
aws_access_key_id = xxx
aws_secret_access_key = xxx
[GEHC-000]
aws_access_key_id = same as above
aws_secret_access_key = same as above
Run Code Online (Sandbox Code Playgroud)
分配给IAM用户的策略
STS政策
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AssumeRole",
"Effect": "Allow",
"Action": [
"sts:AssumeRole"
],
"Resource": [
"arn:aws:iam::*:role/hc/hc-master"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
用户政策
{
"Statement": [
{
"Action": …
Run Code Online (Sandbox Code Playgroud) amazon-web-services amazon-iam terraform terraform-provider-aws
terraform ×9
azure ×2
amazon-ecs ×1
amazon-iam ×1
aws-lambda ×1
docker ×1
json ×1
policy ×1
r ×1
random ×1
random-seed ×1
rds ×1