-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Provisioning CodeBuild - "Error: cache location is required when cache type is "S3"" #10195
Comments
Exact line in the Terraform code where this is triggered: https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/resource_aws_codebuild_project.go#L579 I have no idea why this happens though. Maybe client side validation should be skipped when dynamic resource tokens are present? |
I figured out a workaround: The S3 bucket resource that I was referencing, had the following structure:
Solution was to replace it with:
|
Want to add my experience, the issue seems to be intermittent when trying to plan/apply AND when trying to delete. A template applied and was unchanged, but can't proceed past refreshing state on a destroy due to identical error:
example of the cache settings on the resource:
|
I ran into the same thing. The following does not work, and it also doesn't work if the resource "aws_s3_bucket" "codebuild" {
bucket = var.codebuild_bucket_name
acl = "private"
}
resource "aws_codebuild_project" "project" {
name = var.name
cache {
type = "S3"
location = "${aws_s3_bucket.codebuild.id}/${var.name}"
}
# ...more stuff
} My workaround was to pass the name directly to the resource "aws_s3_bucket" "codebuild" {
bucket = var.codebuild_bucket_name
acl = "private"
}
resource "aws_codebuild_project" "project" {
name = var.name
cache {
type = "S3"
location = "${var.codebuild_bucket_name}/${var.name}"
}
# ...more stuff
} |
However, using aws_s3_bucket.codebuild.bucket instead of aws_s3_bucket.codebuild.id works. |
We have the same error, we use aws_s3_bucket.codebuild.bucket. I've tried switching from BUCKET to ID and back but always the same error. |
ran into the same issue, seems to work fine when the terraform already has the bucket state. got it to work with commenting out the |
@fruuf I have same aws version and same terraform version. Though, if I comment out the I'm following this tutorial: https://github.com/ashwin9798/node-react-nginx-docker-boilerplate Any insights? ########### My answer was to have inside the
|
@mazzespazze that is not really related to this issue, since this issue is about using S3 cache, and you're using local cache. I get the same issue if using bucket_prefix, but using bucket works fine. It seem like the cache location cannot be dependent on something that is not known until the plan applies. |
Earlier my cache block used to look like below:
my code used to work but all of sudden it stopped working. As of now, I have a workaround, by replacing the above block with the below code block, it started working.
Please let me know if this works for you. |
We've recently hit this issue as well and it appears that it can be triggered when the cache.0.location attribute is computed (creating a bucket in the same terraform root using bucket_prefix will trigger this behaviour).
The following terraform code will reproduce the issue:
Terraform plan will fail with:
Changing the I believe this is an issue with the validation logic here |
This functionality has been released in v3.71.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! |
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. |
Community Note
Terraform Version
Terraform v0.12.7
Affected Resource(s)
Terraform Configuration Files
Downloadable here: https://drive.google.com/file/d/1QM47TzsCFfpNB0KtspWwJoiOZ6uWYbqV/view?usp=sharing
Expected Behavior
CodeBuild is provisioned
Actual Behavior
References
The text was updated successfully, but these errors were encountered: