标签: terraform-provider-aws

Terraform AWS 提供商错误:属性值不可配置。无法为“acl”配置值:其值将自动决定

就在今天,每当我运行时terraform apply,我都会看到类似这样的错误:Can\'t configure a value for "lifecycle_rule": its value will be decided automatically based on the result of applying this configuration.

\n

昨天还在工作。

\n

以下是我运行的命令:terraform init && terraform apply

\n

以下是初始化的提供者插件列表:

\n
- Finding latest version of hashicorp/archive...\n- Finding latest version of hashicorp/aws...\n- Finding latest version of hashicorp/null...\n- Installing hashicorp/null v3.1.0...\n- Installed hashicorp/null v3.1.0 (signed by HashiCorp)\n- Installing hashicorp/archive v2.2.0...\n- Installed hashicorp/archive v2.2.0 (signed by HashiCorp)\n- Installing hashicorp/aws v4.0.0...\n- Installed hashicorp/aws v4.0.0 (signed by HashiCorp)\n
Run Code Online (Sandbox Code Playgroud)\n …

amazon-s3 amazon-web-services terraform terraform-provider-aws

47
推荐指数
3
解决办法
3万
查看次数

Terraform - 如何在条件运算符中使用条件创建的资源的输出?

我有一个情况,如果用户不提供 vpc id,我必须创建 aws_vpc 资源。之后,我应该使用该 VPC 创建资源。

现在,我在创建资源时应用条件aws_vpc。例如,仅当existing_vpc为 false 时才创建 VPC:

count                = "${var.existing_vpc ? 0 : 1}"
Run Code Online (Sandbox Code Playgroud)

接下来,例如,我必须在 VPC 中创建节点。如果existing_vpc为 true,则使用var.vpc_id,否则使用从资源计算出的 VPC ID aws_vpc

但是,问题是,如果existing_vpc为 true,aws_vpc则不会创建新资源,并且三元条件无论如何都会尝试检查资源是否aws_vpc正在创建。如果没有创建,terraform 就会出错。

在 上使用条件运算符时出现错误的示例aws_subnet

Resource 'aws_subnet.xyz-subnet' not found for variable 'aws_subnet.xyz-subnet.id'
Run Code Online (Sandbox Code Playgroud)

导致错误的代码是:

subnet_id = "${var.existing_vpc ? var.subnet_id : aws_subnet.xyz-subnet.id}"
Run Code Online (Sandbox Code Playgroud)

如果两者相互依赖,我们如何创建条件资源并根据它们为其他配置分配值?

terraform terraform-provider-aws

29
推荐指数
2
解决办法
2万
查看次数

aws_iam_policy 和 aws_iam_role_policy 之间的区别

我有一个aws_iam_role想要添加策略的项目。通常,我会创建一个策略aws_iam_role并将其附加到角色aws_iam_role_policy_attachment

然而,我看过一些文档,aws_iam_role_policy在我看来,它似乎做了同样的事情。

我是正确的还是我错过了细微的差别?

amazon-web-services amazon-iam terraform-provider-aws terraform0.14.7

20
推荐指数
1
解决办法
1万
查看次数

安装提供程序“aws”时出错:openpgp:未知实体签名

我正在使用 terraform 版本 0.11.13,今天下午我在terraform init步骤中收到以下错误这是否意味着我必须升级 terraform 版本,aws 提供程序是否弃用了此版本?

完整日志:

Successfully configured the backend "s3"! Terraform will automatically
use this backend unless the backend configuration changes.

[1mInitializing provider plugins...
- Checking for available provider plugins on https://releases.hashicorp.com...

Error installing provider "aws": openpgp: signature made by unknown entity.

Terraform analyses the configuration and state and automatically downloads
plugins for the providers used. However, when attempting to download this
plugin an unexpected error occured.

This may be caused if for some …
Run Code Online (Sandbox Code Playgroud)

provider amazon-web-services terraform terraform-provider-aws terraform0.11

20
推荐指数
4
解决办法
1万
查看次数

Terraform 13,根据另一个变量的值验证变量

有没有办法实现以下逻辑

variable "environment" {
  description = "The environment this will be run in can only be set to [preprod|test|prod]"
  type        = string
  default     = "test"
  validation {
    condition     = can(regex("^(prod|preprod|test)$", var.environment))
    error_message = "The environment variable can only be set to [prod|preprod|test]."
  }
}

variable "fet_code" {
  description = "Set the feature code"
  type        = string
  default     = ""
  validation {
    condition     = var.environment == "test" && length(var.fet_code) != 3
    error_message = "The environment has been set to 'test' but …
Run Code Online (Sandbox Code Playgroud)

terraform terraform-provider-aws

18
推荐指数
3
解决办法
2万
查看次数

当 REGIONAL 处于活动状态时,无法为 EDGE 导入证书

我正在尝试将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,所以找不到错误的意义......

terraform aws-api-gateway terraform-provider-aws

17
推荐指数
1
解决办法
3163
查看次数

如何查找 AMI 的适用实例类型列表

ami-0fd3c3c68a2a8066fap-south-1Region 中使用http://cloud-images.ubuntu.com/locator/ec2/,但无法对此使用 t2.micro 实例类型。

Error: Error launching source instance: InvalidParameterValue: The architecture 'x86_64' of the specified instance type does not match the architecture 'arm64' of the specified AMI. Specify an instance type and an AMI that have matching architectures, and try again. You can use 'describe-instance-types' or 'describe-images' to discover the architecture of the instance type or AMI.
Run Code Online (Sandbox Code Playgroud)

在尝试使用 terraform 启动实例之前,如何查找 AMI 的适用实例类型列表

amazon-ec2 amazon-web-services terraform terraform-provider-aws amazon-ami

16
推荐指数
1
解决办法
2万
查看次数

如何在 Terraform 中使用 AWS 提供的 lambda 层?

我正在尝试在 AWS Lambda 层上运行 python 函数,但我没有找到有关 terraform 的任何文档来使用 AWS 提供的 lambda 层。如何使用 AWS 提供的 lambda 层 AWSLambda-Python27-SciPy1x和运行时Python 2.7

#----compute/lambda.tf----
data "archive_file" "lambda_zip" {
    type          = "zip"
    source_file   = "index.py"
    output_path   = "check_foo.zip"
}

resource "aws_lambda_function" "check_foo" {
  filename         = "check_foo.zip"
  function_name    = "checkFoo"
  role             = "${aws_iam_role.iam_for_lambda_tf.arn}"
  handler          = "index.handler"
  source_code_hash = "${data.archive_file.lambda_zip.output_base64sha256}"

  # i want to use lambda layer - AWSLambda-Python27-SciPy1x and run this function on it
  runtime          = "python2.7"
}
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-lambda terraform terraform-provider-aws

15
推荐指数
1
解决办法
1万
查看次数

使用 terraform 将 docker 镜像推送到 ECR

使用 terraform 将公共映像从 Dockerhub(或只是自定义映像)拉取并重新加载到 ECR。我在想类似的事情

# Create ECR repository
resource "aws_ecr_repository" "ecr_repo" {
  name                 = var.ecr_name
}
# Docker image
resource "null_resource" "docker_hub" {
        ......
        ......
  depends_on = [aws_ecr_repository.ecr_repo]
}
Run Code Online (Sandbox Code Playgroud)

基本上创建一个 ECR 存储库,然后上传图像...我是 terrform 的新手,并且在这方面花费了大量时间。所以任何事情都会有所帮助。谢谢

docker dockerhub terraform terraform-provider-aws

15
推荐指数
2
解决办法
3万
查看次数

Terraform lambda 函数验证异常

我正在尝试在 Terraform (v 0.13.0) 中设置我当前的基础设施。我只是从迁移现有的 lambda 函数开始。我已使用以下代码尝试将 .net core 3.1 中的现有 lambda 函数上传到 AWS(provider v.3.0)。我手动部署没有问题,但这显然不是目标。

这是 IAM 角色:

resource "aws_iam_role" "role_lambda" {
  name = "roleLambda"

  assume_role_policy = <<POLICY
  {
    "Version": "2012-10-17",
    "Statement": [
      {
        "Action": "sts:AssumeRole",
        "Principal": {
          "Service": "lambda.amazonaws.com"
        },
        "Effect": "Allow",
        "Sid": ""
      }
    ]
  }
  POLICY
  }
Run Code Online (Sandbox Code Playgroud)

在函数下方(注意我混淆了一些值):

resource "aws_lambda_function" "lambda_tf" {
  function_name     = "LambdaTFTest"
  role              = aws_iam_role.role_lambda.arn
  handler           = "Lambda::Lambda.Function::FunctionHandler"
  runtime           = "dotnetcore3.1"
  s3_bucket         = "arn:aws:s3:::xxxx-xxxxxx"
  s3_key            = "Lambda.zip"
  s3_object_version = "XxXxXxXxXxXxXxXxXxXxXxXxXxXx"
}
Run Code Online (Sandbox Code Playgroud)

但是,我不断收到此错误作为输出,但没有更多详细信息:

Error: Error …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-lambda terraform terraform-provider-aws

14
推荐指数
3
解决办法
3万
查看次数