Terraform-provider-aws: 3.14.0 Regression: Error: InvalidParameter: 1 validation error(s) found. - minimum field size of 1, ListTargetsByRuleInput.EventBusName.

Created on 6 Nov 2020  ยท  30Comments  ยท  Source: hashicorp/terraform-provider-aws

Looks like 3.14.0 has a regression.

My code deployment process which runs every couple hours just started failing today. I also noticed that an hour ago 3.14 of this package was released. I'm getting a bunch of these errors when I run a plan operation. This is blocking my deployments. I'll try and specify the old version of this package in my code but you should try and resolve this quickly.

Error: InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, ListTargetsByRuleInput.EventBusName.

image

image

bug regression serviccloudwatchevents

Most helpful comment

Update: Specifying 3.13.0 let my Terraform Plan command and deployment work.

provider "aws" {
  version = "3.13.0"
  region  = var.region
}

All 30 comments

Update: Specifying 3.13.0 let my Terraform Plan command and deployment work.

provider "aws" {
  version = "3.13.0"
  region  = var.region
}

I also experience this issue with version 3.14.0

Same issue

we're having the same failure with 3.14.0 and using aws_cloudwatch_event_target

seems to be this update: https://github.com/hashicorp/terraform-provider-aws/pull/15799

Same.
From what I can tell it appears to be the 'aws_cloudwatch_event_target' which is supposed to have a default value for 'event_bus_name' but instead throws an error.

15799

I have the same error

Error: InvalidParameter: 1 validation error(s) found.

ย  | - minimum field size of 1, ListTargetsByRuleInput.EventBusName.
ย  | ย 

Same error here guys....

Error: InvalidParameter: 1 validation error(s) found.

  • minimum field size of 1, ListTargetsByRuleInput.EventBusName.

Error: InvalidParameter: 1 validation error(s) found.

  • minimum field size of 1, ListTargetsByRuleInput.EventBusName.

I have the same error

Error: InvalidParameter: 1 validation error(s) found.

ย  | - minimum field size of 1, ListTargetsByRuleInput.EventBusName.
ย  |

I have pinned the previous version for now

provider "aws" {
  version = "~> 3.13.0"
  region  = var.aws_region

and it works

Skipping 3.14.0 fixes my failing pipelines - and should allow for next version up

provider "aws" {
  version = "~> 3.0,!= 3.14.0"
  region  = var.aws_region

What's the root cause? What's to change in TF code?

@hostmit You can pin aws provider version

The bug is not triggered by the unit tests, could someone having an example that triggers it post it so it can be reproduced?

Root cause is:

resource"aws_lambda_permission""my-lambda-perms" {โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹
statement_id  ="AllowExecutionFromCloudWatchEventsI"
action        ="lambda:InvokeFunction"
function_name =aws_lambda_function.my-lambda-functions.function_name
principal     ="events.amazonaws.com"
}โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹

I changed it to:

resource"aws_lambda_permission""my-lambda-perms" {โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹
statement_id  ="AllowExecutionFromCloudWatchEventsI"
action        ="lambda:InvokeFunction"
function_name =aws_lambda_function.my-lambda-functions.function_name
source_arn    =aws_cloudwatch_event_rule.config_my_event.arn
qualifier     =aws_lambda_alias.my-lambda-alias.name
}โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹

Which includes the source_arn that should be there according to docs.. and also added the qualifier..
and I removed 3 things in the state to clean up the state to allow it to run:
tf state rm module.avm-baseline.aws_cloudwatch_event_target.config_my_event_target
tf state rm module.avm-baseline.aws_lambda_function.my-lambda-functions
tf state rm module.avm-baseline.aws_lambda_permission.my-lambda-perms

to force redeploy

Same issue here. fixed the provider version to "3.13.0"

It seems the problem is linked to state migration from 3.13.x to 3.14.0

Simple example to reproduce:

terraform {
  required_version = ">= 0.12"
}

provider "aws" {
  region  = "eu-central-1"
  version = "3.13.0"
}

resource "aws_cloudwatch_event_rule" "cloudwatch_event_is_alive" {
  name                = "cer-is_alive"
  description         = "Trigger lambda is alive every 1 minutes"
  schedule_expression = "rate(1 minute)"
  is_enabled          = true
}

resource "aws_cloudwatch_event_target" "cloudwatch_event_target_is_alive" {
  rule      = aws_cloudwatch_event_rule.cloudwatch_event_is_alive.name
  target_id = "lambda_is_alive"
  arn       = aws_lambda_function.test_lambda.arn
}

resource "aws_lambda_permission" "allow_cloudwatch_event_to_call_lamdba_is_alive" {
  statement_id  = "AllowExecutionFromCloudWatch"
  action        = "lambda:InvokeFunction"
  function_name = aws_lambda_function.test_lambda.arn
  principal     = "events.amazonaws.com"
  source_arn    = aws_cloudwatch_event_rule.cloudwatch_event_is_alive.arn
}

resource "aws_iam_role" "iam_for_lambda" {
  name = "iam_for_lambda"

  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "lambda.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF
}

resource "aws_lambda_function" "test_lambda" {
  filename      = "exports.zip"
  function_name = "lambda_function_name"
  role          = aws_iam_role.iam_for_lambda.arn
  handler       = "exports.test"

  source_code_hash = data.archive_file.init.output_base64sha256

  runtime = "python3.8"
}

data "archive_file" "init" {
  type        = "zip"
  source_file = local_file.foo.filename
  output_path = "exports.zip"

  depends_on = [local_file.foo]
}

resource "local_file" "foo" {
  content  = "def test(): pass"
  filename = "exports.py"
}
$ terraform init
$ terraform apply -auto-approve

Change version = "3.13.0" to version = "3.14.0"

$ terraform init
$ terraform plan
aws_iam_role.iam_for_lambda: Refreshing state... [id=iam_for_lambda]
aws_cloudwatch_event_rule.cloudwatch_event_is_alive: Refreshing state... [id=cer-is_alive]
aws_lambda_function.test_lambda: Refreshing state... [id=lambda_function_name]
aws_lambda_permission.allow_cloudwatch_event_to_call_lamdba_is_alive: Refreshing state... [id=AllowExecutionFromCloudWatch]
aws_cloudwatch_event_target.cloudwatch_event_target_is_alive: Refreshing state... [id=cer-is_alive-lambda_is_alive]

Error: InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, ListTargetsByRuleInput.EventBusName.

Applying from scratch in 3.14.0 works.

Marking as 3.15.0, but we may release as 3.14.1.

I have been looking at the differences between the two state file version - the one where the error would be - and the one after I removed the conflicting entries from state and re-ran the workspace in TFE. There is no real change that shows a clear reason why this would happen. some objects are NULL in old state

Skipping 3.14.0 fixes my failing pipelines - and should allow for next version up

provider "aws" {
  version = "~> 3.0,!= 3.14.0"
  region  = var.aws_region

This worked for me too.

If we are going to do the pinning we would need to change this and re-run potentially 300 workspaces.

Happening to me as well, without lambdas nor cloudwatch-event resources. Error is thrown somewhere around refreshing of aws_route53_record resources. Falling back to 3.13.0 fixes it.

Seems related to some names length. Provider 3.14 works perfectly fine for my resources with shorter names, fails for the same code but a few letters more in the name.
(fine) glue-crawler-event-compressed-sns-topic-dev
(fine) glue-crawler-event-compressed-sns-topic-test
(fail) glue-crawler-event-compressed-sns-topic-research
(fail) glue-crawler-event-compressed-sns-topic-staging
edit: it seems that 3.14 is failing for other envs too

The resources that I am creating in the module are aws_cloudwatch_event_rule, aws_cloudwatch_event_target, and aws_sns_topic

@bflad this is occurring for us on more then just Cloudwatch Event Target - seeing the error on multiple resources.

Cloudwatch events
route53 refresh
Action=GetSubscriptionAttributes&SubscriptionArn
SSM data source

@tburow can you please show the Terraform CLI output?

@tburow can you please show the Terraform CLI output?

disreguard - I think im getting scrambled up in teh debug output - I clearly see the event ones - the deeper down the list of the output the more scrabled/interleaved the errors and its not as clear.

@tburow no worries. Hopefully a lot of that confusion will clear up when we go through the effort of https://github.com/hashicorp/terraform-provider-aws/issues/15892, which will enforce error messages from the AWS Go SDK to include some additional context, e.g. in this case error reading CloudWatch Events Target (ID): {ERROR}

The fix for this has been merged and will release with version 3.14.1 of the Terraform AWS Provider, in the next 20-30 minutes. ๐Ÿ‘

2020-11-06T18:00:19.451Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: 2020/11/06 18:00:19 [DEBUG] [aws-sdk-go] DEBUG: Request sns/GetSubscriptionAttributes Details:
2020-11-06T18:00:19.451Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: ---[ REQUEST POST-SIGN ]-----------------------------
2020-11-06T18:00:19.451Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: POST / HTTP/1.1
2020-11-06T18:00:19.451Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: Host: sns.us-east-1.amazonaws.com
2020-11-06T18:00:19.451Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: User-Agent: aws-sdk-go/1.35.19 (go1.14.5; linux; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.12.28 (+https://www.terraform.io)
2020-11-06T18:00:19.451Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: Content-Length: 169
2020-11-06T18:00:19.451Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: Authorization: REDACTED
2020-11-06T18:00:19.451Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: Content-Type: application/x-www-form-urlencoded; charset=utf-8
2020-11-06T18:00:19.451Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: X-Amz-Date: 20201106T180019Z
2020-11-06T18:00:19.451Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: Accept-Encoding: gzip
2020-11-06T18:00:19.451Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: Action=GetSubscriptionAttributes&SubscriptionArn=arn%3Aaws%3Asns%3Aus-east-1%3A050439152187%3Araves-dev-glacier%REDACTED&Version=2010-03-31
2020-11-06T18:00:19.451Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: -----------------------------------------------------
2020-11-06T18:00:19.452Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: 2020/11/06 18:00:19 [DEBUG] [aws-sdk-go] DEBUG: Validate Request events/ListTargetsByRule failed, not retrying, error InvalidParameter: 1 validation error(s) found.
2020-11-06T18:00:19.452Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: - minimum field size of 1, ListTargetsByRuleInput.EventBusName.
2020-11-06T18:00:19.452Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: 2020/11/06 18:00:19 [DEBUG] [aws-sdk-go] DEBUG: Build Request events/ListTargetsByRule failed, not retrying, error InvalidParameter: 1 validation error(s) found.
2020-11-06T18:00:19.452Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: - minimum field size of 1, ListTargetsByRuleInput.EventBusName.
2020-11-06T18:00:19.452Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: 2020/11/06 18:00:19 [DEBUG] [aws-sdk-go] DEBUG: Sign Request events/ListTargetsByRule failed, not retrying, error InvalidParameter: 1 validation error(s) found.
2020-11-06T18:00:19.452Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: - minimum field size of 1, ListTargetsByRuleInput.EventBusName.
2020-11-06T18:00:19.452Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: 2020/11/06 18:00:19 [DEBUG] [aws-sdk-go] DEBUG: Validate Request events/ListTargetsByRule failed, not retrying, error InvalidParameter: 1 validation error(s) found.
2020-11-06T18:00:19.452Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: - minimum field size of 1, ListTargetsByRuleInput.EventBusName.
2020-11-06T18:00:19.452Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: 2020/11/06 18:00:19 [DEBUG] [aws-sdk-go] DEBUG: Build Request events/ListTargetsByRule failed, not retrying, error InvalidParameter: 1 validation error(s) found.
2020-11-06T18:00:19.452Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: - minimum field size of 1, ListTargetsByRuleInput.EventBusName.
2020-11-06T18:00:19.452Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: 2020/11/06 18:00:19 [DEBUG] [aws-sdk-go] DEBUG: Sign Request events/ListTargetsByRule failed, not retrying, error InvalidParameter: 1 validation error(s) found.
2020-11-06T18:00:19.452Z [DEBUG] plugin.terraform-provider-aws_v3.14.0_x5: - minimum field size of 1, ListTargetsByRuleInput.EventBusName.
~

This has been released in version 3.14.1 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

Confirm new version (3.14.1) fixed it for us. Thanks for jumping on this quickly team!

Was this page helpful?
0 / 5 - 0 ratings