English 中文(简体)
Terraform中出现不支持的块类型错误
原标题:Getting Unsupported block type error in Terraform

我得到了与自动缩放组相关的不支持的块类型错误。具体来说,我得到了以下错误:

Error: Unsupported block type
│ 
│   on main.tf line 67, in resource "aws_autoscaling_group" "ASG_asg":
│   67:   scaling_policy {
│ 
│ Blocks of type "scaling_policy" are not expected here.

我的代码如下:

当CPU使用量超过一定限制时,我试图启用自动缩放。除了自动缩放之外,其他一切都在工作,因为它不断给出关于不需要的度量模块的错误。

问题回答

您必须将缩放策略(aws_autoscaling_policy)定义为依赖资源,而不是将其用作aws_autocaling_group的属性。您可以遵循此模式,并根据自己的上下文进行配置:

resource "aws_autoscaling_policy" "bat" {
  name                   = "foobar3-terraform-test"
  scaling_adjustment     = 4
  adjustment_type        = "ChangeInCapacity"
  cooldown               = 300
  autoscaling_group_name = aws_autoscaling_group.bar.name
}

resource "aws_autoscaling_group" "bar" {
  availability_zones        = ["us-east-1a"]
  name                      = "foobar3-terraform-test"
  max_size                  = 5
  min_size                  = 2
  health_check_grace_period = 300
  health_check_type         = "ELB"
  force_delete              = true
  launch_configuration      = aws_launch_configuration.foo.name
}




相关问题
SimpleDB vs Tokyo Cabinet

Has anybody compared SimpleDB and Tokyo Cabinet for performance and scalability? I m coding my project against SimpleDB at the moment and considering benchmarking TC, be nice if somebody had already ...

How to make visual studio 2008 deploy to ftp in ACTIVE mode?

I m using Amazon EC2 services and would like to publish my WCF application to this server using the visual studio 2008. Instead of opening so many ports on the amazon firewall, I ll use the ftp ACTIVE ...

Passenger and Rails on Scalr.net

I m having an issue with Passenger and Rails working together on my Scalr application server. I have Rails 2.3.5 installed and Passenger 2.2.7. I am running ruby 1.8.6 (patchlevel 111). Previous ...

Many users, many cpus, no delays. Good for cloud?

I wish to set up a CPU-intensive time-important query service for users on the internet. A usage scenario is described below. Is cloud computing the right way to go for such an implementation? If so, ...

Homemade cheap and cheerful clustering with MySQL+EC2?

I ve got a Java web service backed by MySQL + EC2 + EBS. For data integrity I ve looked into DRBD, MySQL cluster etc. but wonder if there isn t a simpler solution. I don t need high availability (can ...

What s a good way to collect logs from Amazon EC2 instances?

My app is hosted on an Amazon EC2 cluster. Each instance writes events to log files. I need to collect (and data mine) over these logs at the end of each day. What s a recommended way to collect these ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Need some help choosing between Amazon EC2 and VPS [closed]

At my company we are looking at hosting a blog and a CMS . We are still in the process of building the product and havent made it live yet. We are looking at some hosting options. We need to have ...

热门标签