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

[Bug]: AWS Codebuild envirnment variable is not set properly #39047

Open
rafay-tariq opened this issue Aug 27, 2024 · 1 comment
Open

[Bug]: AWS Codebuild envirnment variable is not set properly #39047

rafay-tariq opened this issue Aug 27, 2024 · 1 comment
Labels
bug Addresses a defect in current functionality. service/codebuild Issues and PRs that pertain to the codebuild service.

Comments

@rafay-tariq
Copy link

Terraform Core Version

1.7.0

AWS Provider Version

5.33.0

Affected Resource(s)

https://registry.terraform.io/providers/hashicorp/aws/4.40.0/docs/resources/codebuild_project.html#environment

resource "aws_codebuild_project" "code_build" {
  name          = var.code_build_project_name
  description   = "CodeBuild project"
  service_role  = aws_iam_role.codebuild_role.arn
  build_timeout = "10"
  source {
    type      = "CODEPIPELINE"
    buildspec = "buildspec.yml"
  }
  artifacts {
    type = "CODEPIPELINE"
  }
  environment {
    compute_type                = "BUILD_GENERAL1_SMALL"
    image                       = "aws/codebuild/amazonlinux2-x86_64-standard:5.0"
    type                        = "LINUX_CONTAINER"
    image_pull_credentials_type = "CODEBUILD"
    
    environment_variable {
      name  = "S3_BUCKET_NAME"
      value = "some value"
      type  = "PLAINTEXT"
    }
    
    }
    }

Expected Behavior

Not adding in the aws code build environment. It should create the environment variable in the codebuild stage in aws but it is not creating it.

Actual Behavior

It should create the code build environment variable there.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

# make sure to add the versions so that future versions may not break the code
terraform {
  required_version = ">= 1.7.0"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.33.0"
    }
  }
}

Steps to Reproduce

resource "aws_codebuild_project" "code_build" {
  name          = var.code_build_project_name
  description   = "CodeBuild project"
  service_role  = aws_iam_role.codebuild_role.arn
  build_timeout = "10"
  source {
    type      = "CODEPIPELINE"
    buildspec = "buildspec.yml"
  }
  artifacts {
    type = "CODEPIPELINE"
  }
  environment {
    compute_type                = "BUILD_GENERAL1_SMALL"
    image                       = "aws/codebuild/amazonlinux2-x86_64-standard:5.0"
    type                        = "LINUX_CONTAINER"
    image_pull_credentials_type = "CODEBUILD"
    
    environment_variable {
      name  = "S3_BUCKET_NAME"
      value = "some value"
      type  = "PLAINTEXT"
    }

    # dynamic "environment_variable" {
    #   for_each = var.codebuild_environment_variables
    #   content {
    #     name  = environment_variable.key
    #     value = environment_variable.value
    #     type  = "PLAINTEXT"
    #   }
    # }
  }
  logs_config {
    cloudwatch_logs {
      group_name  = format("/codebuild/%s", var.AWS_CODE_PIPELINE_NAME)
      stream_name = format("/codebuild/%s", var.AWS_CODE_PIPELINE_NAME)
    }
  }
}

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@rafay-tariq rafay-tariq added the bug Addresses a defect in current functionality. label Aug 27, 2024
@github-actions github-actions bot added the service/codebuild Issues and PRs that pertain to the codebuild service. label Aug 27, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Aug 27, 2024
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/codebuild Issues and PRs that pertain to the codebuild service.
Projects
None yet
Development

No branches or pull requests

2 participants