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

provider/aws: Use proper Set for source.Auth in resource_aws_codebuild_project #11741

Merged
merged 2 commits into from
Feb 16, 2017
Merged

Conversation

comebackoneyear
Copy link
Contributor

@comebackoneyear comebackoneyear commented Feb 7, 2017

The code was trying to store the auth part of the source as a map[string]interface{} but it was a TypeSet in the schema.

2017/02/07 13:51:00 [DEBUG] plugin: terraform: panic: interface conversion: interface {} is map[string]interface {}, not *schema.Set
2017/02/07 13:51:00 [DEBUG] plugin: terraform:
2017/02/07 13:51:00 [DEBUG] plugin: terraform: goroutine 1615 [running]:
2017/02/07 13:51:00 [DEBUG] plugin: terraform: panic(0x32591a0, 0xc4223d5fc0)
2017/02/07 13:51:00 [DEBUG] plugin: terraform:  /usr/local/Cellar/go/1.7.4_1/libexec/src/runtime/panic.go:500 +0x1a1
2017/02/07 13:51:00 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*MapFieldWriter).setSet(0xc4247e6660, 0xc42017b710, 0x3, 0x3, 0x31d38e0, 0xc42017b650, 0xc422d13c20, 0x0, 0x1)
2017/02/07 13:51:00 [DEBUG] plugin: terraform:  /Users/ejansson/.go/src/github.com/hashicorp/terraform/helper/schema/field_writer_map.go:311 +0x4ca
2017/02/07 13:51:00 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*MapFieldWriter).set(0xc4247e6660, 0xc42017b710, 0x3, 0x3, 0x31d38e0, 0xc42017b650, 0x0, 0x0)
2017/02/07 13:51:00 [DEBUG] plugin: terraform:  /Users/ejansson/.go/src/github.com/hashicorp/terraform/helper/schema/field_writer_map.go:94 +0x404
2017/02/07 13:51:00 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*MapFieldWriter).setObject(0xc4247e6660, 0xc4247e6be0, 0x2, 0x2, 0x31d38e0, 0xc42017b620, 0xc4242620f0, 0xc42017b680, 0xc42425d320)
2017/02/07 13:51:00 [DEBUG] plugin: terraform:  /Users/ejansson/.go/src/github.com/hashicorp/terraform/helper/schema/field_writer_map.go:200 +0x245
2017/02/07 13:51:00 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*MapFieldWriter).set(0xc4247e6660, 0xc4247e6be0, 0x2, 0x2, 0x31d38e0, 0xc42017b620, 0x6, 0x1)
2017/02/07 13:51:00 [DEBUG] plugin: terraform:  /Users/ejansson/.go/src/github.com/hashicorp/terraform/helper/schema/field_writer_map.go:96 +0x383
2017/02/07 13:51:00 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*MapFieldWriter).setSet(0xc4247e6660, 0xc422e9ef10, 0x1, 0x1, 0x37eb120, 0xc4247e6bc0, 0xc422d14690, 0x1, 0x6)
2017/02/07 13:51:00 [DEBUG] plugin: terraform:  /Users/ejansson/.go/src/github.com/hashicorp/terraform/helper/schema/field_writer_map.go:312 +0x2b7
2017/02/07 13:51:00 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*MapFieldWriter).set(0xc4247e6660, 0xc422e9ef10, 0x1, 0x1, 0x37eb120, 0xc4247e6bc0, 0x1, 0x0)
2017/02/07 13:51:00 [DEBUG] plugin: terraform:  /Users/ejansson/.go/src/github.com/hashicorp/terraform/helper/schema/field_writer_map.go:94 +0x404
2017/02/07 13:51:00 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*MapFieldWriter).WriteField(0xc4247e6660, 0xc422e9ef10, 0x1, 0x1, 0x37eb120, 0xc4247e6bc0, 0x0, 0x0)
2017/02/07 13:51:00 [DEBUG] plugin: terraform:  /Users/ejansson/.go/src/github.com/hashicorp/terraform/helper/schema/field_writer_map.go:76 +0x182
2017/02/07 13:51:00 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*ResourceData).Set(0xc42454c540, 0x3953e1d, 0x6, 0x37eb120, 0xc4247e6bc0, 0x0, 0x0)
2017/02/07 13:51:00 [DEBUG] plugin: terraform:  /Users/ejansson/.go/src/github.com/hashicorp/terraform/helper/schema/resource_data.go:169 +0x13a
2017/02/07 13:51:00 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/builtin/providers/aws.resourceAwsCodeBuildProjectRead(0xc42454c540, 0x2dc03a0, 0xc422a44380, 0x0, 0x15)
2017/02/07 13:51:00 [DEBUG] plugin: terraform:  /Users/ejansson/.go/src/github.com/hashicorp/terraform/builtin/providers/aws/resource_aws_codebuild_project.go:364 +0x2b1

Not 100% sure this is the proper way to fix this.

@catsby
Copy link
Contributor

catsby commented Feb 7, 2017

Hey @comebackoneyear – do you have a demo configuration, minus any sensitive information, that I could use to reproduce this? I'm curious if the flattenAwsCodebuildProjectSource method itself needs to be adjusted in a different way. Thanks!

@comebackoneyear
Copy link
Contributor Author

comebackoneyear commented Feb 7, 2017

@catsby It's a bit intertwined but this is an attempt of cleaning it up.

The part different from the code in the test is this:

auth = {
      type = "OAUTH"
    }

Which I need to add for the git checkout to work.
https://docs.aws.amazon.com/codebuild/latest/APIReference/API_SourceAuth.html

"Full config":


resource "aws_iam_role" "codebuild_role" {
  name = "test"

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

resource "aws_codebuild_project" "main" {
  name         = "test"
  description  = "test"
  timeout      = "5"
  service_role = "${aws_iam_role.codebuild_role.id}"

  artifacts {
    type = "NO_ARTIFACTS"
  }

  environment {
    compute_type = "BUILD_GENERAL1_SMALL"
    image        = "aws/codebuild/docker:1.12.1"
    type         = "LINUX_CONTAINER"

    environment_variable = {
      "name"  = "SOME_KEY"
      "value" = "SOME_VALUE"
    }
  }

  source {
    type = "GITHUB"

    auth = {
      type = "OAUTH"
    }

    location = "https://github.com/lifesum/test.git"
  }

  tags {
    "Environment" = "test"
  }
}

@comebackoneyear
Copy link
Contributor Author

@catsby I added the failing part to the unit test now.

@stack72
Copy link
Contributor

stack72 commented Feb 16, 2017

LGTM! This has been confirmed by @liamjbennett - the author of the original resource :)

@stack72 stack72 merged commit 1f40e23 into hashicorp:master Feb 16, 2017
stack72 pushed a commit that referenced this pull request Feb 16, 2017
…d_project (#11741)

* provider/aws: Use proper Set for Source.Auth

* Adding auth to source in test
@ghost
Copy link

ghost commented Apr 16, 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 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.

@ghost ghost locked and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants