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

Create google_cloudbuild resource #6604

Closed
salrashid123 opened this issue Jun 16, 2020 · 3 comments
Closed

Create google_cloudbuild resource #6604

salrashid123 opened this issue Jun 16, 2020 · 3 comments

Comments

@salrashid123
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

Create a new CloudBuild resource that allows users to define submit an actual cloud build job.

The existing google_cloudbuild_trigger allows a user to create a trigger but theres no way to define a build step and submit the job.

eg, in gcloud cli, you can define and submit a job

  • cloudbuild.yaml
steps:
- name: gcr.io/cloud-builders/curl
  id: httpbin
  args: ['-v', 'https://httpbin.org/get']
gcloud builds submit  --config cloudbuild.yaml

New or Affected Resource(s)

  • google_cloudbuild

Potential Terraform Configuration

  provider "google" {}

  resource "google_cloudbuild" "test-build" {
    build  {
        step  {
            name = "gcr.io/cloud-builders/gcloud"
            entrypoint = "sh"
            args = ["-c", "echo hi"]
        }
    }  
  }

References

Note, the existing google_cloudbuild_trigger includes parsing logic for the Build structure in resource_cloud_build_trigger

https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.triggers/create
   >>   
 "build": {
    object (Build)
  },

which is the build structure used while defining and submitting a job

@salrashid123
Copy link
Contributor Author

salrashid123 commented Jun 30, 2021

i've gotten a very basic sample working here after adding in a new "resource" type to the existing google_cloudbuild_trigger. Basically, resource type will submit a job like this

resource "google_cloudbuild_builds" "builder" {
  provider = google-beta-local
  project = var.project_id
  location = "global"

  steps {    
        name = "gcr.io/cloud-builders/curl"
        id = "fetch"
        args = ["-v", "-H", "Metadata-Flavor: Google", "https://httpbin.org/get"]
  }
  steps {    
        name = "gcr.io/cloud-builders/docker"
        id = "buildstep"
        args = ["build", "-t", "gcr.io/$PROJECT_ID/testimage", "."]
        wait_for = ["fetch"]
  }
  images = ["gcr.io/$PROJECT_ID/testimage"]
  
  
  source {
    storage_source {
      bucket = google_storage_bucket.build-bucket.name
      object = google_storage_bucket_object.archive.name
    }
  }
   
}

however, the usecase i had is really very unique: i just wanted to create an automated tutorial which creates actual resources (project,vm, etc) and then build some code vial cloud builder andthen deploy it to a VM. At the moment, i used local_exec to submit gcloud commands.

in the end, though i submitted this FR, its for this usecase only and i can't think of really any other use for making terraform manage cloud builds (its not a 'resource' terraform should manage).

If you do have other usecases for this, pls add it to this FR since i'm unsure if this should be kept open after all.

modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Oct 14, 2022
* Support ability to create "non-custom" services

Allow users to create various Service Monitoring services: App Engine,
Cloud Run, etc.

hashicorp#11935

* Specify BasicService is immutable

* Responding to review comments.

* Add test; make service_id required

* labels still need input: true; remove encoder

* Correct typo

* Ignore service fields in SLO import test

* Correct test

* Make id_format and import_format the same

* Remove custom code

* Correct test typo

* service is actually input-only

* Add resource test

Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician added a commit that referenced this issue Oct 14, 2022
* Support ability to create "non-custom" services

Allow users to create various Service Monitoring services: App Engine,
Cloud Run, etc.

#11935

* Specify BasicService is immutable

* Responding to review comments.

* Add test; make service_id required

* labels still need input: true; remove encoder

* Correct typo

* Ignore service fields in SLO import test

* Correct test

* Make id_format and import_format the same

* Remove custom code

* Correct test typo

* service is actually input-only

* Add resource test

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
@melinath
Copy link
Collaborator

Closing this, as it seems to be a job resource.

@melinath melinath closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2023
@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 Mar 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants