[英]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_arn
和rules_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.