使用 AWS Codecommit 的 AWS Codebuild 项目

发布于 2025-01-12 04:38:17 字数 989 浏览 1 评论 0原文

需要社区的一些帮助。我想我几乎已经有了它,但我找不到向我展示如何使用 AWS Codecommit 配置 Codebuild 项目的文档。寻找有人给我一些可以帮助我的链接或对我的代码有一些帮助。

resource "aws_codebuild_project" "cb_test_project" {
    name            = var.cb_name
    description     = var.description
    build_timeout   = var.build_timeout
    service_role    = var.cb_service_role
    source_version  = var.branch_name //set to main by default

    artifacts {
        type = "NO_ARTIFACTS"
    }

    environment {
        compute_type                = var.compute_type
        image                       = var.image
        type                        = var.environment_type
        image_pull_credentials_type = "CODEBUILD"
        privileged_mode             = var.privileged_mode

    }


    source {
        
        type      = "CODECOMMIT"
        location  = "my_codecommit_repo"
        buildspec = var.buildspec

    }
    
}

我的问题是每次运行构建时都会失败。 Terraform Plan 通过了所有检查,但应用只是出错。我不知道语法可能有什么问题,但我希望我只是错过了一些可以通过构建的简单内容。

Need some help from the community. I think I almost have it but I can't find documentation showing me how to configure Codebuild project with AWS Codecommit. Looking for someone to give me a few links that can help or some assistance with my code.

resource "aws_codebuild_project" "cb_test_project" {
    name            = var.cb_name
    description     = var.description
    build_timeout   = var.build_timeout
    service_role    = var.cb_service_role
    source_version  = var.branch_name //set to main by default

    artifacts {
        type = "NO_ARTIFACTS"
    }

    environment {
        compute_type                = var.compute_type
        image                       = var.image
        type                        = var.environment_type
        image_pull_credentials_type = "CODEBUILD"
        privileged_mode             = var.privileged_mode

    }


    source {
        
        type      = "CODECOMMIT"
        location  = "my_codecommit_repo"
        buildspec = var.buildspec

    }
    
}

My issue is it fails every time I run the build. Terraform Plan passes all the checks but the apply just errors out. I have no insight into what may be wrong with the syntax but I am hoping i am just missing something simple that will pass the build.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

翻身的咸鱼 2025-01-19 04:38:17

我提供了用于解决此问题的当前更新配置。

resource "aws_codebuild_project" "cb_test_project" {
    name            = var.cb_name
    description     = var.description
    build_timeout   = var.build_timeout
    service_role    = var.cb_service_role


    artifacts {
        type = "NO_ARTIFACTS"
    }

    environment {
        compute_type                = var.compute_type
        image                       = var.image
        type                        = var.environment_type
        image_pull_credentials_type = "CODEBUILD"
        privileged_mode             = var.privileged_mode

    }


    source {
        
        type            = "CODECOMMIT"
        buildspec       = var.buildspec
        location        = "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/[repo_name]" #MUST BE THE HTTPS URL!!
        git_clone_depth = 0


    }
    
}

正如您所看到的,我错误配置了资源并滥用了其他变量。请访问 GitHub请参阅此的填写样本。

  1. 请注意,您需要具有广泛权限的服务角色才能正常工作
  2. 源位置必须是 Codecommit HTTPS URL,ssh URL 对此不起作用。另外,请删除 URL 中的括号,它们只是作为存储库名称的占位符。
  3. 查看属性,以便您可以了解每一项的价值。

I am providing the current updated configurations that were used to address this issue.

resource "aws_codebuild_project" "cb_test_project" {
    name            = var.cb_name
    description     = var.description
    build_timeout   = var.build_timeout
    service_role    = var.cb_service_role


    artifacts {
        type = "NO_ARTIFACTS"
    }

    environment {
        compute_type                = var.compute_type
        image                       = var.image
        type                        = var.environment_type
        image_pull_credentials_type = "CODEBUILD"
        privileged_mode             = var.privileged_mode

    }


    source {
        
        type            = "CODECOMMIT"
        buildspec       = var.buildspec
        location        = "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/[repo_name]" #MUST BE THE HTTPS URL!!
        git_clone_depth = 0


    }
    
}

As you can see, I had misconfigured the resource and misused other variables. Please visit GitHub to see a filled-out sample of this.

  1. Note you need a Service Role with extensive permissions for this to work
  2. Source Location MUST BE the Codecommit HTTPS URL the ssh URL will not work for this. Also, please remove the brackets from the URL they are just there as a placeholder for your repo name.
  3. Review the properties so you can understand the values for each one.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文