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

aws_codepipeline_webhook terraform crashed #17482

Closed
ghost opened this issue Feb 5, 2021 · 4 comments
Closed

aws_codepipeline_webhook terraform crashed #17482

ghost opened this issue Feb 5, 2021 · 4 comments
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/codepipeline Issues and PRs that pertain to the codepipeline service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.

Comments

@ghost
Copy link

ghost commented Feb 5, 2021

This issue was originally opened by @monisha6791 as hashicorp/terraform#27690. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.12.28
+ provider.aws v3.26.0
+ provider.github v4.3.2
+ provider.template v2.2.0

Upgraded it to 0.13 and it still does not work and crashes

Terraform Configuration Files


resource "aws_codebuild_source_credential" "token" {
  auth_type   = "PERSONAL_ACCESS_TOKEN"
  server_type = "GITHUB"
  token       = var.token
}

resource "aws_codebuild_project" "static_web_build" {
.
.
.
}

resource "aws_codepipeline" "static_web_pipeline" {
.
.
.
}

resource "aws_codebuild_webhook" "webhook" {
  project_name = aws_codebuild_project.static_web_build.name

  filter_group {
    filter {
      type    = "EVENT"
      pattern = "PULL_REQUEST_MERGED"
    }

    filter {
      type    = "HEAD_REF"
      pattern = "master"
    }
  }
}

resource "aws_codepipeline_webhook" "codepipeline_webhook" {
  authentication  = "GITHUB_HMAC"
  name            = "codepipeline-webhook"
  target_action   = "Source"
  target_pipeline = aws_codepipeline.static_web_pipeline.name

  authentication_configuration {
    secret_token = aws_codebuild_webhook.webhook.secret
  }

  filter {
    json_path    = "$.ref"
    match_equals = "refs/heads/{Branch}"
  }
  tags = {}
}

provider "github" {
#  token = "var.token"
}

resource "github_repository_webhook" "github_hook" {
  repository = "beacon-ja"
  events     = ["pullrequest","push"]


  configuration {
    url          = aws_codepipeline_webhook.codepipeline_webhook.url
    insecure_ssl = "0"
    content_type = "json"
    secret       = aws_codebuild_webhook.webhook.secret
  }
}

Debug Output

Error: POST https://api.github.com/repos//apis/hooks: 404 Not Found []

Error: POST https://api.github.com/user/repos: 401 Requires authentication []

Error: POST https://api.github.com/repos/monisha6791/beacon-ja/hooks: 404 Not Found []

Error: Error creating webhook: ValidationException: 1 validation error detected: Value at 'webhook.authenticationConfiguration.secretToken' failed to satisfy constraint: Member must have length less than or equal to 100

The errors stopped after I removed the statefiles and destroyed and recreated but terraform crashes and asked me to report it. I have added the output of crash.log below

Crash Output

https://gist.github.com/monisha6791/d67c81a15d4964056d351de90f0d2747

Expected Behavior

I should be able to pull code and push it to s3, as I am setting up a website on s3

Actual Behavior

The webhook on github shows 200 but I get the above errors. I am unable to push to the repository in an organization. It looks for a repository in my username instead going to the organization

Steps to Reproduce

  1. terraform init
  2. terraform plan
  3. terraform apply - errors when I apply

https://stackoverflow.com/questions/65147393/how-to-avoid-double-slash-in-github-repo-url

-->

@ghost ghost added the bug Addresses a defect in current functionality. label Feb 5, 2021
@ghost ghost added service/codebuild Issues and PRs that pertain to the codebuild service. service/codepipeline Issues and PRs that pertain to the codepipeline service. labels Feb 5, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Feb 5, 2021
@monisha6791
Copy link

Hello,

I wanted to update that, I do not see the errors I posted in Debug output anymore. I do see the code build and code pipeline are created in my AWS account but I dont think it is clean. The result I see is "TERRAFORM CRASHES" . I have updated the gist above with the latest crash.log
The error I see is after the "yes" in the apply command

@ewbankkit
Copy link
Contributor

ewbankkit commented Feb 5, 2021

Relevant section of the crash log:

021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: panic: interface conversion: interface {} is nil, not map[string]interface {}
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: 
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: goroutine 205 [running]:
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsCodePipelineWebhookCreate(0xc001786900, 0x66ec4c0, 0xc00131a100, 0x1, 0xffffffffffffffff)
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/hashicorp/terraform-provider-aws/aws/resource_aws_codepipeline_webhook.go:139 +0x9a7
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc0008d3a40, 0x7e34860, 0xc001e04180, 0xc001786900, 0x66ec4c0, 0xc00131a100, 0x0, 0x0, 0x0)
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:278 +0x88
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0008d3a40, 0x7e34860, 0xc001e04180, 0xc001836b60, 0xc001c815c0, 0x66ec4c0, 0xc00131a100, 0x0, 0x0, 0x0, ...)
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:396 +0x65b
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0010eafe0, 0x7e34860, 0xc001e04180, 0xc000b1eb90, 0xc001e04180, 0x0, 0x7e60280)
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:955 +0x8cf
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ApplyResourceChange(0xc0012a1e20, 0x7e34860, 0xc001e04180, 0xc001836a10, 0xc0012a1e20, 0xc000ff5260, 0xc001cd0ba0)
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/server/server.go:332 +0xae
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x71dd0a0, 0xc0012a1e20, 0x7e34920, 0xc000ff5260, 0xc0007301e0, 0x0, 0x7e34920, 0xc000ff5260, 0xc00067c000, 0x23e)
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x214
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: google.golang.org/grpc.(*Server).processUnaryRPC(0xc00080ae00, 0x7e57a00, 0xc000638180, 0xc00182a500, 0xc000ff44e0, 0xb24b6a0, 0x0, 0x0, 0x0)
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:1194 +0x522
2021-02-04T18:06:04.055-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: google.golang.org/grpc.(*Server).handleStream(0xc00080ae00, 0x7e57a00, 0xc000638180, 0xc00182a500, 0x0)
2021-02-04T18:06:04.056-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:1517 +0xd05
2021-02-04T18:06:04.056-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000f26ec0, 0xc00080ae00, 0x7e57a00, 0xc000638180, 0xc00182a500)
2021-02-04T18:06:04.056-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:859 +0xa5
2021-02-04T18:06:04.056-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: created by google.golang.org/grpc.(*Server).serveStreams.func1
2021-02-04T18:06:04.056-0500 [DEBUG] plugin.terraform-provider-aws_v3.26.0_x5: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:857 +0x1fd

func resourceAwsCodePipelineWebhookCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).codepipelineconn
authType := d.Get("authentication").(string)
var authConfig map[string]interface{}
if v, ok := d.GetOk("authentication_configuration"); ok {
l := v.([]interface{})
authConfig = l[0].(map[string]interface{})
}

@ewbankkit ewbankkit added crash Results from or addresses a Terraform crash or kernel panic. and removed needs-triage Waiting for first response or review from a maintainer. service/codebuild Issues and PRs that pertain to the codebuild service. labels Feb 5, 2021
@github-actions
Copy link

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Jan 26, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 25, 2023
@github-actions
Copy link

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 Mar 28, 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/codepipeline Issues and PRs that pertain to the codepipeline service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.
Projects
None yet
Development

No branches or pull requests

2 participants