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

Submodules in AWS CodeBuild projects are not working #18069

Closed
ghost opened this issue Mar 12, 2021 · 3 comments · Fixed by #18843
Closed

Submodules in AWS CodeBuild projects are not working #18069

ghost opened this issue Mar 12, 2021 · 3 comments · Fixed by #18843
Labels
bug Addresses a defect in current functionality. service/codebuild Issues and PRs that pertain to the codebuild service.
Milestone

Comments

@ghost
Copy link

ghost commented Mar 12, 2021

This issue was originally opened by @aichholzer as hashicorp/terraform#28062. It was migrated here as a result of the provider split. The original body of the issue is below.


Trying to enable git_submodules_config for a aws_codebuild_project does not work.

My repository's type is BITBUCKET, the terraform documentation states:

git_submodules_config - (Optional) Information about the Git submodules configuration for an AWS CodeBuild build project. Git submodules config blocks are documented below. This option is only valid when the type is CODECOMMIT, GITHUB or GITHUB_ENTERPRISE.

However, it is possible to manually set enable this on the AWS CodeBuild project's source page.

Why does terraform not apply this change for type = BITBUCKET repositories while it still being possible through the AWS CodeBuild dashboard?

In my particular case, I have some sub-modules and when I run the build with Use Git submodules = false they are not pulled as expected. Once I manually set this in the project's source, it works; they are pulled as they should when the repository is cloned.

I'd like to be able to set this directly through terraform:

source {
  type = "BITBUCKET"
  location = "..."
  git_clone_depth = 1
  report_build_status = true

  git_submodules_config {
    fetch_submodules = true
  }
}

Terraform Version

Terraform v0.14.3
+ provider registry.terraform.io/hashicorp/aws v3.22.0

Terraform Configuration Files

resource aws_codebuild_project build {
  name = "..."
  description = "Image builder."
  build_timeout = "10"
  service_role  = "..."
  badge_enabled = true

  source {
    type = "BITBUCKET"
    location = "..."
    git_clone_depth = 1
    report_build_status = true

    git_submodules_config {
      fetch_submodules = true
    }
}

Expected Behavior

It should enable the Use Git submodules option (checkbox) in the AWS CodeBuild project's source settings.
Screen Shot 2021-03-12 at 1 42 41 pm

Actual Behavior

Running terraform apply acknowledges the change but does not perform it (on yes). Consecutive runs of terraform apply will show the same change again as pending...

@ghost ghost added the bug Addresses a defect in current functionality. label Mar 12, 2021
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. and removed bug Addresses a defect in current functionality. labels Mar 12, 2021
@DrFaust92
Copy link
Collaborator

DrFaust92 commented Mar 14, 2021

seem that the issue stems from this:

// Only valid for CODECOMMIT, GITHUB, GITHUB_ENTERPRISE source types.
if sourceType == codebuild.SourceTypeCodecommit || sourceType == codebuild.SourceTypeGithub || sourceType == codebuild.SourceTypeGithubEnterprise {
if v, ok := data["git_submodules_config"]; ok && len(v.([]interface{})) > 0 {
config := v.([]interface{})[0].(map[string]interface{})
gitSubmodulesConfig := &codebuild.GitSubmodulesConfig{}
if v, ok := config["fetch_submodules"]; ok {
gitSubmodulesConfig.FetchSubmodules = aws.Bool(v.(bool))
}
projectSource.GitSubmodulesConfig = gitSubmodulesConfig
}
}
return projectSource
}

@DrFaust92 DrFaust92 added the service/codebuild Issues and PRs that pertain to the codebuild service. label Mar 14, 2021
@anGie44 anGie44 added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 15, 2021
@github-actions github-actions bot added this to the v3.38.0 milestone Apr 29, 2021
@ghost
Copy link
Author

ghost commented Apr 30, 2021

This has been released in version 3.38.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!

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/codebuild Issues and PRs that pertain to the codebuild service.
Projects
None yet
2 participants