简体   繁体   English

Terraform:AWS Inspector 计划失败

[英]Terraform: AWS Inspector plan fails

I am using terraform to manage AWS infrastructure.我正在使用 terraform 来管理 AWS 基础设施。 I am completely new to AWS and terraform and the information is overwhelming.我对 AWS 和 terraform 完全陌生,而且信息非常丰富。

I am trying to enable the service AWS Inspector though terraform using the following code:我正在尝试使用以下代码通过 terraform 启用服务 AWS Inspector:

resource "aws_inspector_assessment_template" "example" {
  name       = "example"
#   target_arn = aws_inspector_assessment_target.example.arn
  duration   = 3600

#   rules_package_arns = [
#     "arn:aws:inspector:us-west-2:758058086616:rulespackage/0-9hgA516p",
#     "arn:aws:inspector:us-west-2:758058086616:rulespackage/0-H5hpSawc",
#     "arn:aws:inspector:us-west-2:758058086616:rulespackage/0-JJOtZiqQ",
#     "arn:aws:inspector:us-west-2:758058086616:rulespackage/0-vg5GGHSD",
#   ]
}

But all I am getting is the following error:但我得到的只是以下错误:

Error: Missing required argument

  on aws_inspector.tf line 1, in resource "aws_inspector_assessment_template" "example":
   1: resource "aws_inspector_assessment_template" "example" {

The argument "rules_package_arns" is required, but no definition was found.


Error: Missing required argument

  on aws_inspector.tf line 1, in resource "aws_inspector_assessment_template" "example":
   1: resource "aws_inspector_assessment_template" "example" {

The argument "target_arn" is required, but no definition was found.

This is obviously because I commented out target_arn and rules_package_arns .这显然是因为我注释掉了target_arnrules_package_arns

The thing is I don't understand what these variables are and what values to give the.问题是我不明白这些变量是什么以及要给出什么值。 Could you please help me figure this out?你能帮我解决这个问题吗?

You shouldn't comment out all the required parts.不应该注释掉所有必需的部分。 Thus your error.因此你的错误。

You also have to create aws_inspector_assessment_target , and can use aws_inspector_rules_packages to get the ARNs that you require.您还必须创建aws_inspector_assessment_target ,并且可以使用aws_inspector_rules_packages来获取您需要的 ARN。 Having these resources you can reference them in your aws_inspector_assessment_template .拥有这些资源,您可以在aws_inspector_assessment_template中引用它们。

An example is TF docs :一个例子是TF 文档

# Declare the data source
data "aws_inspector_rules_packages" "rules" {}

# e.g. Use in aws_inspector_assessment_template
resource "aws_inspector_resource_group" "group" {
  tags = {
    test = "test"
  }
}

resource "aws_inspector_assessment_target" "assessment" {
  name               = "test"
  resource_group_arn = aws_inspector_resource_group.group.arn
}

resource "aws_inspector_assessment_template" "assessment" {
  name       = "Test"
  target_arn = aws_inspector_assessment_target.assessment.arn
  duration   = "60"

  rules_package_arns = data.aws_inspector_rules_packages.rules.arns
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 简单的 AWS Lambda Terraform 计划失败并出现 ValidationException 错误 400 - Simple AWS Lambda Terraform plan fails with ValidationException Error 400 Terraform 计划 AWS 未经授权的问题 - Terraform plan AWS Unauthorized issue 没有AWS凭证的Terraform运行计划 - Terraform run plan without AWS credentials Github 操作恢复/销毁 terraform Terraform 计划创建的 AWS 基础设施 - Github Actions revert/destroy terraform AWS infrastructure created by Terraform Plan Terraform AWS CloudTrail 配置失败 - Terraform AWS CloudTrail configurations fails 无法将 AWS API 网关使用计划引用为 Terraform 中的数据源 - Unable to reference an AWS API Gateway Usage Plan as a data source in Terraform 导入 aws 资源后 Terraform 计划显示差异 - Terraform plan shows differences after importing the aws resources 在没有互联网访问的 AWS 实例上运行 terraform 计划/初始化 - Run terraform plan/init on AWS instance without internet access 在同一计划中将Terraform应用于两个不同的AWS账户 - Applying Terraform On Two Different AWS Accounts In the Same Plan 应用 terraform 计划在 AWS 中创建 VPC 终端节点时出错 - Error applying terraform plan to create VPC endpoint in AWS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM