Terraform v0.8.7
aws_codebuild_project
resource "aws_codebuild_project" "my_codebuild_project" {
name = "my_codebuild_project"
description = "my_codebuild_project"
timeout = "5"
service_role = "${aws_iam_role.codebuild_role.arn}"
# encryption_key =
source {
type = "GITHUB"
location = "https://github.com/myorg/myurl"
auth { # HERE IS THE BLOCK IN QUESTION
type = "OAUTH"
resource = "AWS CodeBuild" # This line is confusing, see issue #2 mentioned at the bottom. I've tried removing this line and various other strings
}
}
environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/python:3.5.2"
type = "LINUX_CONTAINER"
}
artifacts {
type = "S3"
location = "someplace"
namespace_type = "BUILD_ID"
packaging = "NONE"
}
}
```Error applying plan:
1 error(s) occurred:
### Expected Behavior
Successfully create aws_codebuild_project resource with Github OAuth connection and no errors.
### Actual Behavior
When applying a "aws_codebuild_project" resource with a Github source, I'm able to successfully create a codebuild project if I do NOT include the "auth" block within the "source" block.
However, when attempting to "Start build" in AWS; the project is unable to pull from github. It seems that the "auth" block is required for a codebuild > Github connection.
I added the "auth" block to the "source" block and then received this error when attempting to apply:
```Error applying plan:
1 error(s) occurred:
* aws_codebuild_project.my_codebuild_project: unexpected EOF
Terraform creates the codebuild project in AWS but fails with the error above. However, the codebuild project created DOES run a completely successful build and pull from Github. Because of the error, terraform does not recognize the project's existence in AWS and tries to create it again at the next terraform apply: "+ aws_codebuild_project.my_codebuild_project". Of course, then I receive an error that a duplicate resource exist.
terraform applyPlease note that I have already setup the Github OAuth connection and am able to use it if I edit the existing project resource in the UI.
I have two issues here:
auth {
type = "OAUTH"
}
I have not been able to dive deeper in to this, but I do not consider this solution neat.
@comebackoneyear you think this is solved in 0.8.8?
The crash is fixed, not sure if there is any changes in the documentation clarifying the second question.
@comebackoneyear you think it's worth just linking to the AWS documentation for that specific answer?
@stack72 For now. They aren't precisely clear on this either (from what I remember). But I can update the docs once I understand it better.
k let's close this out for now then :) Thanks for getting back to me so fast
I'm having this same issue. Was this ever fixed?
The EOF error was fixed but the resource still doesn't seem to support authenticating with Github via a token like aws_codepipeline does and thus breaks automation. It looks like AWS don't support this via API as CLI page says
Also, you must connect your AWS account to your GitHub account. To do this, use the AWS CodeBuild console to begin creating a build project
http://docs.aws.amazon.com/cli/latest/reference/codebuild/create-project.html
@comebackoneyear @jurajseffer What version was this fixed in? I'm running TF 0.11.2 and AWS provider 1.8.0 and I'm hitting this error even with my account already authorized via github.
Trying to create a new codebuild resource, If I create it with NO auth block it will work. With an Auth block it will blow up. If I then go into the codedeploy resource manually and connect it to my github repo, it will crash terraform again.
@brianbianco I don't know about the version but I found what you did - have to have no auth block when creating new CodeBuild, then manually connect Github and put the block in when updating it. What I meant was that the error it shows when one uses auth block is different from what I remember, not EOF.
@jurajseffer So I did this an it still blows up for me. Maybe I have the ordering slightly wrong. I think if inbetween adding the auth block and making the manual changes you run terraform it will crash, and basically be hosed forever.
I did this, and it worked like a charm - https://github.com/terraform-providers/terraform-provider-aws/issues/7435#issuecomment-534115342.
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.
Most helpful comment
I'm having this same issue. Was this ever fixed?