Coder Social home page Coder Social logo

Comments (10)

krwenholz avatar krwenholz commented on August 23, 2024 2

Hi @gadaldo ,

Yes, this is a limitation of the Google Cloud Storage API. Deployment Manager can only interact with APIs, so there is no declarative way for us to delete bucket contents, hence the suggestion to use a gcloud script like described in our Cloud Container Builder example (linked above).

Best,

Kyle

from deploymentmanager-samples.

krwenholz avatar krwenholz commented on August 23, 2024

Hi Davide,

You could probably hack something into Deployment Manager using a feature we're working on (documentation coming sometime Q4), but uploading objects to Cloud Storage isn't really a supported use case. Your best tool for that is gcloud or the API.

What's your particular use case though? Is this file the same for every deployment? Are you referencing a GCS object in your deployment template?

from deploymentmanager-samples.

davidebelloni avatar davidebelloni commented on August 23, 2024

Hi,
I've a project that hosts golden images for others projects and (in a GCS bucket) their startup scripts.
I'm managing project and bucket with DM and images with Packer.
I can manage this GCS objects with gcloud or gsutil, but with something like DM the overall process should be more clear.

from deploymentmanager-samples.

aljim avatar aljim commented on August 23, 2024

As a workaround you can define a cloud function that does that for you, here is a sample to call a cloud function within DM

https://github.com/GoogleCloudPlatform/deploymentmanager-samples/tree/master/examples/v2/cloud_functions

from deploymentmanager-samples.

katyp avatar katyp commented on August 23, 2024

Closing this issue. Please re-open if more is needed.

from deploymentmanager-samples.

krwenholz avatar krwenholz commented on August 23, 2024

Hi Davide,

In the sample Alejandro linked to, you can see DM calling the raw Cloud Function. If the content you wanted was in your deployment, you could get it into Cloud Storage using their insert API in a similar way:

https://cloud.google.com/storage/docs/json_api/v1/objects/insert

You would need to do some configuring to get rid of that object on deletion of the deployment though (something we don't have docs for yet). Alternatively, you could copy objects between buckets with something like the following

resources:
- # All your existing resources.
...
- name: some-name
  action: gcp-types/storage-v1:storage.objects.copy
  metadata:
    runtimePolicy:
    - CREATE
  properties:
    sourceBucket: my-source-bucket
    sourceObject: object-name
    destinationBucket: us-central1-bucket # Put the proper bucket name here.
    destinationObject: object-name

You would want to also add an action for deleting the object. It would look like the above but use a DELETE runtime policy and call the object delete API. Other acceptable policies are UPDATE_ALWAYS and UPDATE_ON_CHANGE (change of the deployment, not the object).

Hopefully that helps and gets you going in the right direction. Let us know if there's anything else we can do to help.

Happy Monday.

from deploymentmanager-samples.

gadaldo avatar gadaldo commented on August 23, 2024

Hi,

what about deleting a bucket with content in it (such as a previously created staging location)?

Regards

from deploymentmanager-samples.

krwenholz avatar krwenholz commented on August 23, 2024

Hi @gadaldo,

There isn't an API to delete a bucket with content, so you would need to delete the contents first. This can be done via gcloud or the console. If you want to do the whole thing with Deployment Manager, I would recommend looking into running a a Cloud Container Builder script in DM.

Hopefully that helps.

Happy Monday,

Kyle

from deploymentmanager-samples.

gadaldo avatar gadaldo commented on August 23, 2024

Oh so there is not a way of say:

- name: {{ PROJECT_NAME }}-event-dataflow
  type: storage.v1.bucket
  properties:
    location: europe-west2
    storageClass: REGIONAL
    deleteContents: True

cause I am trying but no luck.

Regards

from deploymentmanager-samples.

gadaldo avatar gadaldo commented on August 23, 2024

Ok thank you for replying. We are running out of python so I'll go via gcloud command line for this object deletion in my containerized deployment project. The idea was to have a completely idempotent deployment project with no dependencies (only docker) and as much as declarative as possible.

thank you for your reply

Happy monday

Giuseppe

from deploymentmanager-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.