我正在编写一些Terraform代码以在AWS API Gateway中置备资源。
到目前为止,我已经设法做到这一点……
resource "aws_api_gateway_rest_api" "skel" {
name = "${var.api_name}"
description = "This is a very basic request method"
}
################### Attachments
resource "aws_api_gateway_resource" "attachments" {
rest_api_id = "${aws_api_gateway_rest_api.skel.id}"
parent_id = "${aws_api_gateway_rest_api.skel.root_resource_id}"
path_part = "attachments"
}
resource "aws_api_gateway_method" "AttachMethod" {
rest_api_id = "${aws_api_gateway_rest_api.skel.id}"
resource_id = "${aws_api_gateway_resource.attachments.id}"
http_method = "GET"
authorization = "NONE"
}
resource "aws_api_gateway_method" "AttachOptionsMethod" {
rest_api_id = "${aws_api_gateway_rest_api.skel.id}"
resource_id = "${aws_api_gateway_resource.attachments.id}"
http_method = "OPTIONS"
authorization = "NONE"
}
但这占用了600多行,我想使其灵活一些,以便我可以在其他项目中使用它。
是否有某种方法可以遍历变量以创建资源和方法,或者我有点乐观。
非常感谢。
尼尔