Terraform-provider-google: Container image option in google_compute_instance_template

Created on 9 Aug 2019  ·  5Comments  ·  Source: hashicorp/terraform-provider-google


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

We can simplify application deployment by deploying containers to instances in managed instance groups. This is supported in GCP as here.

New or Affected Resource(s)

  • google_compute_instance_template

Potential Terraform Configuration

resource "google_compute_instance_template" "default" {
...
  // New option: Deploy container from Google Container Registry
  container {
    source_image = "http://us.gcr.io/path_to_image:latest"
  }
  // Create a new boot disk from an image
  disk {
    source_image = "debian-cloud/debian-9"
    auto_delete  = true
    boot         = true
  }
...
}

References

  1. https://cloud.google.com/compute/docs/containers/deploying-containers#managedinstancegroupcontainer
  2. https://www.terraform.io/docs/providers/google/r/compute_instance_template.html

    • #0000
enhancement sizS

Most helpful comment

This is currently possible by using https://registry.terraform.io/modules/terraform-google-modules/container-vm/google/1.0.0 to generate the metadata.

Would rather see it natively though!

All 5 comments

Hi i wanted this feature but I saw this is a beta feature:

https://cloud.google.com/sdk/gcloud/reference/beta/compute/instance-templates/create-with-container

It is posible to add create with container to the google-beta terraform provider?

anyways, I would like to have in addition to container.source_image the following:

container.env

--container-env=[KEY=VALUE, …,…]
Declare environment variables KEY with value VALUE passed to container. Only the last value of KEY is taken when KEY is repeated more than once.
Values, declared with --container-env flag override those with the same KEY from file, provided in --container-env-file.

container.arg

--container-arg=CONTAINER_ARG
Argument to append to container entrypoint or to override container CMD. Each argument must have a separate flag. Arguments are appended in the order of flags. Example:
Assuming the default entry point of the container (or an entry point overridden with --container-command flag) is a Bourne shell-compatible executable, in order to execute 'ls -l' command in the container, the user could use:

and so on.

Thank you very much.

This is currently possible by using https://registry.terraform.io/modules/terraform-google-modules/container-vm/google/1.0.0 to generate the metadata.

Would rather see it natively though!

Hi,

--container-env, --container-arg and --container-image are now appearing in gcloud stable https://cloud.google.com/sdk/gcloud/reference/compute/instance-templates/create-with-container . As such I believe this is no longer blocked on upstream? Can we get these properties added?

There are also multiple other --container-* commands that would be nice to support.

FWIW, https://registry.terraform.io/modules/terraform-google-modules/container-vm/google/2.0.0 is nice, but custom modules add another layer of misdirection and can be hard to customize and understand what you are getting. I think they should be additive on existing working terraform google provider functionality.

@paddycarver Sorry for the ping. Can the upstream label be removed as per my above comment?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pdaborowski-playtech picture pdaborowski-playtech  ·  24Comments

aeneasr picture aeneasr  ·  25Comments

hashibot picture hashibot  ·  30Comments

vncntvandriessche picture vncntvandriessche  ·  26Comments

josephlewis42 picture josephlewis42  ·  33Comments