Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: interface conversion: interface {} is nil, not string #7772

Closed
felipeclopes opened this issue Feb 28, 2019 · 3 comments
Closed

panic: interface conversion: interface {} is nil, not string #7772

felipeclopes opened this issue Feb 28, 2019 · 3 comments
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/cloudfront Issues and PRs that pertain to the cloudfront service.
Milestone

Comments

@felipeclopes
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

0.11.11

Terraform Configuration Files

variable "streams_lambda_function_name" {}
variable "subscription_rabbitmq_queue" {}
variable "subscription_rabbitmq_server" {}

##################################################################################
### Cleaner module
##################################################################################
module "cleaner" {
  source = "./base"

  path = "../dist/cleaner/"
  handler = "cleaner.handler"
  function_name = "cleaner"
  vpc_config = []
  memory_size = 512
  timeout = 600
  log_destination_arn = "${var.log_destination_arn}"
  alarms_topic_arn = "${var.alarms_topic_arn}"
  env = "${var.env}"
  extra_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [{
      "Effect": "Allow",
      "Action": ["lambda:*"],
      "Resource": "arn:aws:lambda:*"
    },
    {
      "Effect": "Allow",
      "Action": ["lambda:ListFunctions"],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": ["dynamodb:*"],
      "Resource": "arn:aws:dynamodb:*"
    }]
}
EOF
}

##################################################################################
### Alerting API Event Consumer
##################################################################################
resource "aws_cloudwatch_event_rule" "every_five_minutes" {
    name = "every-five-minutes"
    description = "Fires every five minutes"
    schedule_expression = "rate(5 minutes)"
}
module "alerting_api_event_consumer" {
  source = "./base"
  path = "../dist/alerting_api_event_consumer/"
  handler = "alerting_api_event_consumer.handler"
  function_name = "alerting-api-event-consumer"
  prefix = "mw-fhai-alerts"
  memory_size = 128
  timeout = 300
  log_destination_arn = "${var.log_destination_arn}"
  alarms_topic_arn = "${var.alarms_topic_arn}"
  env = "${var.env}"
  variables = {
    MI_INTEGRATION_LAMBDA =  "${var.mi_integration_function_name}"
    STREAM_API_LAMBDA = "${var.streams_lambda_function_name}"
    QUEUE_NAME = "${var.subscription_rabbitmq_queue}"
    RABBITMQ_SERVER = "${var.subscription_rabbitmq_server}"
  }
  vpc_config = [{
    subnet_ids = ["${var.subnet_mi}"],
    security_group_ids = ["${var.security_group_mi}"]
  }]
  extra_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [{
      "Effect": "Allow",
      "Action": ["lambda:*"],
      "Resource": "arn:aws:lambda:*"
    }]
}
EOF
}

resource "aws_cloudwatch_event_target" "call_alerting_api_event_consumer_every_five_minutes" {
    rule = "${aws_cloudwatch_event_rule.every_five_minutes.name}"
    target_id = "alerting_api_event_consumer"
    arn = "${module.alerting_api_event_consumer.arn}"
}

resource "aws_lambda_permission" "allow_cloudwatch_to_call_alerting_api_event_consumer" {
    statement_id = "AllowExecutionFromCloudWatch"
    action = "lambda:InvokeFunction"
    function_name = "${module.alerting_api_event_consumer.function_name}"
    principal = "events.amazonaws.com"
    source_arn = "${aws_cloudwatch_event_rule.every_five_minutes.arn}"
}

##################################################################################
### Payload Indexer
##################################################################################
module "payload-indexer" {
  source = "./base"
  path = "../dist/payload_indexer/"
  handler = "payload_indexer.handler"
  function_name = "payload-indexer"
  memory_size = 512
  timeout = 300
  log_destination_arn = "${var.log_destination_arn}"
  alarms_topic_arn = "${var.alarms_topic_arn}"
  env = "${var.env}"
  variables = {
    ENVIRONMENT =  "${var.env}"
  }
  policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [{
      "Effect": "Allow",
      "Action": ["es:ESHttpPost"],
      "Resource": "*"
    }]
}
EOF
}

Debug Output

Panic Output

https://www.dropbox.com/s/jaemufp07thhs2w/rodrigo_output_logs?dl=0

Expected Behavior

To run as successfully as yesterday

Actual Behavior

panic

Steps to Reproduce

  1. terraform plan

Important Factoids

The same configuration ran successfully yesterday; the AWS APIs on the account might be experiencing high usage.

@bflad bflad added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/cloudfront Issues and PRs that pertain to the cloudfront service. labels Feb 28, 2019
@bflad bflad added this to the v2.0.0 milestone Feb 28, 2019
@bflad
Copy link
Member

bflad commented Feb 28, 2019

Hi @felipeclopes 👋 Thanks for reporting this and sorry for the trouble.

The panic is occurring from the aws_cloudfront_distribution resource code as noted in the stacktrace here:

2019-02-28T19:14:21.160Z [DEBUG] plugin.terraform-provider-aws_v1.60.0_x4: panic: interface conversion: interface {} is nil, not string
2019-02-28T19:14:21.161Z [DEBUG] plugin.terraform-provider-aws_v1.60.0_x4: 
2019-02-28T19:14:21.161Z [DEBUG] plugin.terraform-provider-aws_v1.60.0_x4: goroutine 10089 [running]:
2019-02-28T19:14:21.163Z [DEBUG] plugin.terraform-provider-aws_v1.60.0_x4: github.com/terraform-providers/terraform-provider-aws/aws.sortInterfaceSlice(0xc00059b340, 0x7, 0x7, 0xf, 0xc000eeb708, 0x1)
2019-02-28T19:14:21.164Z [DEBUG] plugin.terraform-provider-aws_v1.60.0_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/structure.go:1976 +0x364
2019/02/28 19:14:21 [TRACE] dag/walk: vertex "module.lambdas.module.alerting_api_event_consumer.aws_lambda_function.lambda", waiting for: "module.lambdas.module.alerting_api_event_consumer.var.variables"
2019-02-28T19:14:21.164Z [DEBUG] plugin.terraform-provider-aws_v1.60.0_x4: github.com/terraform-providers/terraform-provider-aws/aws.defaultCacheBehaviorHash(0x329d4e0, 0xc0011ab650, 0x1)
2019-02-28T19:14:21.165Z [DEBUG] plugin.terraform-provider-aws_v1.60.0_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/cloudfront_distribution_configuration_structure.go:233 +0xa67
2019-02-28T19:14:21.165Z [DEBUG] plugin.terraform-provider-aws_v1.60.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.(*Set).hash(0xc0008f8400, 0x329d4e0, 0xc0011ab650, 0x3, 0x2)
2019-02-28T19:14:21.166Z [DEBUG] plugin.terraform-provider-aws_v1.60.0_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/set.go:211 +0x3d

It seems to be related specifically to the default_cache_behavior configuration block allowed_methods argument. Your timing is quite coincidental though, as we just removed the code above in version 2.0.0 released yesterday. Could you double check no configuration changes occurred there or potentially try updating to 2.0.0 to see if the issue still occurs?

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Feb 28, 2019
@felipeclopes
Copy link
Author

It was fixed by upgrading to version ~>2.0

provider "aws" {
  version = "~> 2.0"
  ...
}

Thank you @bflad!

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Feb 28, 2019
@ghost
Copy link

ghost commented Mar 31, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/cloudfront Issues and PRs that pertain to the cloudfront service.
Projects
None yet
Development

No branches or pull requests

2 participants