Skip to content

[Bug]: Error when creating aws_scheduler_schedule #30306

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

Closed
datngxtiens opened this issue Mar 29, 2023 · 5 comments · Fixed by #30360
Closed

[Bug]: Error when creating aws_scheduler_schedule #30306

datngxtiens opened this issue Mar 29, 2023 · 5 comments · Fixed by #30360
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/scheduler Issues and PRs that pertain to the scheduler service. service/sts Issues and PRs that pertain to the sts service.
Milestone

Comments

@datngxtiens
Copy link

datngxtiens commented Mar 29, 2023

Terraform Core Version

1.4.2

AWS Provider Version

4.56.0

Affected Resource(s)

aws_scheduler_schedule

Expected Behavior

The EventBridge scheduler created successfully.

Actual Behavior

Error creating.

Relevant Error/Panic Output Snippet

Error: Request cancelled
│ 
│   with module.eventbridge["xxx"].aws_scheduler_schedule.this,
│   on .terraform/modules/eventbridge/event_scheduler/main.tf line 11, in resource "aws_scheduler_schedule" "this":
│   11: resource "aws_scheduler_schedule" "this" {
│ 
│ The plugin.(*GRPCProvider).ApplyResourceChange request was cancelled.
╵
Releasing state lock. This may take a few moments...

Stack trace from the terraform-provider-aws_v4.56.0_x5 plugin:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 682 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/scheduler.expandTarget({0x11122afc0, 0x14003b5bb90}, 0x14003bdad50)
        github.com/hashicorp/terraform-provider-aws/internal/service/scheduler/flex.go:615 +0xc58
github.com/hashicorp/terraform-provider-aws/internal/service/scheduler.resourceScheduleCreate({0x11122afc0?, 0x14003b5bb90}, 0x0?, {0x1110e7120?, 0x140003f5400})
        github.com/hashicorp/terraform-provider-aws/internal/service/scheduler/schedule.go:475 +0x8c0
github.com/hashicorp/terraform-provider-aws/internal/provider.wrappedCreateContextFunc.func1({0x11122afc0?, 0x14003b5bb90?}, 0x0?, {0x1110e7120?, 0x140003f5400?})
        github.com/hashicorp/terraform-provider-aws/internal/provider/provider.go:2727 +0x44
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x11122afc0?, {0x11122afc0?, 0x14003b5bb90?}, 0xd?, {0x1110e7120?, 0x140003f5400?})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:702 +0x64
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x140031ebce0, {0x11122afc0, 0x14003b5bb90}, 0x140058c0c30, 0x14005175d00, {0x1110e7120, 0x140003f5400})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:837 +0x86c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x1400000cae0, {0x11122afc0?, 0x14003b5ba70?}, 0x14003475c70)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1021 +0xb70
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ApplyResourceChange({0x140031ddf20, 0x140031ddf80, {0x14004ab95c0, 0x2, 0x2}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
        github.com/hashicorp/[email protected]/tf5muxserver/mux_server_ApplyResourceChange.go:27 +0xdc
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x14001ba0780, {0x11122afc0?, 0x14003b5adb0?}, 0x1400587d570)
        github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:818 +0x3b8
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x110dfc7c0?, 0x14001ba0780}, {0x11122afc0, 0x14003b5adb0}, 0x1400587d500, 0x0)
        github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400433bc20, {0x111239e40, 0x14004bac820}, 0x140058ba5a0, 0x14004b29a10, 0x117850520, 0x0)
        google.golang.org/[email protected]/server.go:1336 +0xb7c
google.golang.org/grpc.(*Server).handleStream(0x1400433bc20, {0x111239e40, 0x14004bac820}, 0x140058ba5a0, 0x0)
        google.golang.org/[email protected]/server.go:1704 +0x82c
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/[email protected]/server.go:965 +0x84
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/[email protected]/server.go:963 +0x290

Error: The terraform-provider-aws_v4.56.0_x5 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Terraform Configuration Files

data "aws_caller_identity" "current" {}

data "aws_region" "current" {}

locals {
  prefix     = "${var.environment}-${var.account}-${var.project}"
  account_id = data.aws_caller_identity.current.account_id
  region     = data.aws_region.current.name
}

resource "aws_scheduler_schedule" "this" {
  name       = "${local.prefix}-${var.name_prefix}-scheduler"
  group_name = var.group_name

  flexible_time_window {
    mode                      = var.window_mode
    maximum_window_in_minutes = var.maximum_window
  }

  schedule_expression          = var.schedule_expression
  schedule_expression_timezone = var.schedule_expression_timezone
  start_date                   = var.start_date
  end_date                     = var.end_date
  state                        = var.scheduler_state

  target {
    arn      = var.target_arn
    role_arn = var.custom_policy != true ? var.default_policy_arn : aws_iam_role.this[0].arn
    input    = var.input

    dead_letter_config {
      arn = var.dead_letter_queue_arn
    }

    retry_policy {
      maximum_event_age_in_seconds = var.maximum_event_age
      maximum_retry_attempts       = var.maximum_retry_attempts
    }
  }
}

Steps to Reproduce

run terraform apply,

output of terraform plan:

# module.eventbridge["xxx"].aws_scheduler_schedule.this will be created
  + resource "aws_scheduler_schedule" "this" {
      + arn                          = (known after apply)
      + group_name                   = "default"
      + id                           = (known after apply)
      + name                         = "xxx"
      + name_prefix                  = (known after apply)
      + schedule_expression          = "cron(0/15 5-10 * * ? *)"
      + schedule_expression_timezone = "Asia/Ho_Chi_Minh"
      + state                        = "ENABLED"

      + flexible_time_window {
          + mode = "OFF"
        }

      + target {
          + arn      = "xxx"
          + input    = jsonencode({})
          + role_arn = "xxx"

          + dead_letter_config {}

          + retry_policy {
              + maximum_event_age_in_seconds = 60
              + maximum_retry_attempts       = 0
            }
        }
    }

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@datngxtiens datngxtiens added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Mar 29, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added crash Results from or addresses a Terraform crash or kernel panic. service/scheduler Issues and PRs that pertain to the scheduler service. service/sts Issues and PRs that pertain to the sts service. labels Mar 29, 2023
@datngxtiens
Copy link
Author

After searching around, I found that before apply, do this command export GODEBUG=asyncpreemptoff=1 seems to fix the problem. Don't know why it helps.

@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Mar 31, 2023
@ewbankkit
Copy link
Contributor

ewbankkit commented Mar 31, 2023

func expandTarget(ctx context.Context, tfMap map[string]interface{}) *types.Target {
if tfMap == nil {
return nil
}
a := &types.Target{}
if v, ok := tfMap["arn"].(string); ok && v != "" {
a.Arn = aws.String(v)
}
if v, ok := tfMap["dead_letter_config"].([]interface{}); ok && len(v) > 0 {
a.DeadLetterConfig = expandDeadLetterConfig(v[0].(map[string]interface{}))
}

@github-actions github-actions bot added this to the v4.62.0 milestone Mar 31, 2023
@github-actions
Copy link

github-actions bot commented Apr 7, 2023

This functionality has been released in v4.62.0 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. Thank you!

@github-actions
Copy link

github-actions bot commented May 8, 2023

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 8, 2023
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/scheduler Issues and PRs that pertain to the scheduler service. service/sts Issues and PRs that pertain to the sts service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants