Enable picking up the artifact name from the buildspec file (it's being picked up from artifact.name field then, see: https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-syntax).
In AWS console go to CodeBuild project -> Edit -> Artifacts to see this option under Name field:
Taken and modified from https://www.terraform.io/docs/providers/aws/r/codebuild_project.html
resource "aws_s3_bucket" "example" {
bucket = "example"
acl = "private"
}
resource "aws_iam_role" "example" {
name = "example"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "codebuild.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
EOF
}
resource "aws_iam_role_policy" "example" {
role = "${aws_iam_role.example.name}"
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Resource": [
"*"
],
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
]
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateNetworkInterface",
"ec2:DescribeDhcpOptions",
"ec2:DescribeNetworkInterfaces",
"ec2:DeleteNetworkInterface",
"ec2:DescribeSubnets",
"ec2:DescribeSecurityGroups",
"ec2:DescribeVpcs"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"${aws_s3_bucket.example.arn}",
"${aws_s3_bucket.example.arn}/*"
]
}
]
}
POLICY
}
resource "aws_codebuild_project" "example" {
name = "test-project"
description = "test_codebuild_project"
build_timeout = "5"
service_role = "${aws_iam_role.example.arn}"
artifacts {
type = "S3"
location = "${aws_s3_bucket.example.bucket}"
packaging = "ZIP"
path = "example_output_path"
enable_semver = true ###### That's the requested feature.
}
environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/standard:1.0"
type = "LINUX_CONTAINER"
image_pull_credentials_type = "CODEBUILD"
}
source {
type = "GITHUB"
location = "https://github.com/mitchellh/packer.git"
git_clone_depth = 1
}
}
Any plans to add this in the near future?
I did a smaller dive into how this can be done.
First the aws/aws-sdk-go project needs to expose such a feature through it's API, currently it does not.
I also checked the official API and it doesn't seem to expose such a flag. :(
Also checked the AWS python SDK and it turns out that is actually the case: https://github.com/boto/botocore/blob/e33dcf8cff1c07f29fb7c9f0f86d302c9717b73f/botocore/data/codebuild/2016-10-06/service-2.json
This feature doesn't seem to be officially exposed on the AWS API. :(
Oh, my bad:
https://docs.aws.amazon.com/codebuild/latest/APIReference/API_ProjectArtifacts.html#CodeBuild-Type-ProjectArtifacts-overrideArtifactName
It's not called "semantic versioning", but it's there. :)
The aws/aws-sdk-go library also exposes that flag: https://github.com/aws/aws-sdk-go/blob/master/service/codebuild/api.go#L2138
Hi folks 👋 Sorry for any confusion here.
There was a previous feature request (https://github.com/terraform-providers/terraform-provider-aws/issues/5908) and pull request (https://github.com/terraform-providers/terraform-provider-aws/pull/7824) for this functionality, which have just been implemented and will release in version 2.22.0 of the Terraform AWS Provider, later this week.
This has been released in version 2.22.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 for triage. Thanks!
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
Hi folks 👋 Sorry for any confusion here.
There was a previous feature request (https://github.com/terraform-providers/terraform-provider-aws/issues/5908) and pull request (https://github.com/terraform-providers/terraform-provider-aws/pull/7824) for this functionality, which have just been implemented and will release in version 2.22.0 of the Terraform AWS Provider, later this week.