{"id":18706983,"url":"https://github.com/terraform-google-modules/terraform-google-container-vm","last_synced_at":"2025-11-09T08:30:32.466Z","repository":{"id":33393297,"uuid":"150461691","full_name":"terraform-google-modules/terraform-google-container-vm","owner":"terraform-google-modules","description":"Deploys containers on Compute Engine instances","archived":false,"fork":false,"pushed_at":"2024-12-17T19:32:58.000Z","size":379,"stargazers_count":158,"open_issues_count":8,"forks_count":79,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-12-28T07:18:07.231Z","etag":null,"topics":["cft-terraform","compute","containers"],"latest_commit_sha":null,"homepage":"https://registry.terraform.io/modules/terraform-google-modules/container-vm/google","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terraform-google-modules.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-26T17:06:47.000Z","updated_at":"2024-11-27T13:38:42.000Z","dependencies_parsed_at":"2023-10-05T04:16:02.962Z","dependency_job_id":"f01e6c9e-0898-4397-99e5-4f3e3e004ed7","html_url":"https://github.com/terraform-google-modules/terraform-google-container-vm","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-google-modules%2Fterraform-google-container-vm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-google-modules%2Fterraform-google-container-vm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-google-modules%2Fterraform-google-container-vm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-google-modules%2Fterraform-google-container-vm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terraform-google-modules","download_url":"https://codeload.github.com/terraform-google-modules/terraform-google-container-vm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239571542,"owners_count":19661164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cft-terraform","compute","containers"],"created_at":"2024-11-07T12:16:16.168Z","updated_at":"2025-11-09T08:30:32.416Z","avatar_url":"https://github.com/terraform-google-modules.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform Google Container VM Metadata Module\n\nThis module handles the generation of metadata for [deploying containers on GCE instances](https://cloud.google.com/compute/docs/containers/deploying-containers).\n\nThis module itself does not launch an instance or managed instance group. It\ngenerates the necessary metadata to create an instance or MIG yourself.\nExamples of using this module can be found in the\n[examples/](https://github.com/terraform-google-modules/terraform-google-container-vm/tree/master/examples)\ndirectory.\n\n## Compatibility\nThis module is meant for use with Terraform 0.13+ and tested using Terraform 1.0+. If you find incompatibilities using Terraform \u003e=0.13, please open an issue.\n If you haven't\n[upgraded](https://www.terraform.io/upgrade-guides/0-13.html) and need a Terraform\n0.12.x-compatible version of this module, the last released version\nintended for Terraform 0.12.x is [v2.0.0](https://registry.terraform.io/modules/terraform-google-modules/-container-vm/google/v2.0.0).\n\n## Usage\n\n```hcl\nmodule \"gce-container\" {\n  source = \"terraform-google-modules/container-vm/google\"\n  version = \"~\u003e 3.2\"\n\n  container = {\n    image=\"gcr.io/google-samples/hello-app:1.0\"\n    env = [\n      {\n        name = \"TEST_VAR\"\n        value = \"Hello World!\"\n      }\n    ],\n\n    # Declare volumes to be mounted.\n    # This is similar to how docker volumes are declared.\n    volumeMounts = [\n      {\n        mountPath = \"/cache\"\n        name      = \"tempfs-0\"\n        readOnly  = false\n      },\n      {\n        mountPath = \"/persistent-data\"\n        name      = \"data-disk-0\"\n        readOnly  = false\n      },\n    ]\n  }\n\n  # Declare the Volumes which will be used for mounting.\n  volumes = [\n    {\n      name = \"tempfs-0\"\n\n      emptyDir = {\n        medium = \"Memory\"\n      }\n    },\n    {\n      name = \"data-disk-0\"\n\n      gcePersistentDisk = {\n        pdName = \"data-disk-0\"\n        fsType = \"ext4\"\n      }\n    },\n  ]\n\n  restart_policy = \"Always\"\n}\n```\n\nThen perform the following commands on the root folder:\n\n- `terraform init` to get the plugins\n- `terraform plan` to see the infrastructure plan\n- `terraform apply` to apply the infrastructure build\n- `terraform destroy` to destroy the built infrastructure\n\u003c!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --\u003e\n## Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| container | A description of the container to deploy | `any` | \u003cpre\u003e{\u003cbr\u003e  \"command\": \"ls\",\u003cbr\u003e  \"image\": \"gcr.io/google-containers/busybox\"\u003cbr\u003e}\u003c/pre\u003e | no |\n| cos\\_image\\_family | The COS image family to use (eg: stable, beta, or dev) | `string` | `\"stable\"` | no |\n| cos\\_image\\_name | Name of a specific COS image to use instead of the latest cos family image | `string` | `null` | no |\n| cos\\_project | COS project where the image is located | `string` | `\"cos-cloud\"` | no |\n| restart\\_policy | The restart policy for a Docker container. Defaults to `OnFailure` | `string` | `\"OnFailure\"` | no |\n| volumes | A set of Docker Volumes to configure | `any` | `[]` | no |\n\n## Outputs\n\n| Name | Description |\n|------|-------------|\n| container | The container definition provided |\n| container\\_vm | The complete container VM image object to use for the GCE instance |\n| metadata\\_key | The key to assign `metadata_value` to, so container information is attached to the instance |\n| metadata\\_value | The generated container configuration |\n| restart\\_policy | The restart policy provided |\n| source\\_image | The self\\_link to the COS image to use for the GCE instance. Equivalent to container\\_vm.self\\_link |\n| vm\\_container\\_label | The COS version to deploy to the instance. To be used as the value for the `vm_container_label_key` label key. Equivalent to container\\_vm.name |\n| vm\\_container\\_label\\_key | The label key for the COS version deployed to the instance |\n| volumes | The volume definition provided |\n\n\u003c!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --\u003e\n\n## Container Options\n\nAdvanced container options, as described [here](https://cloud.google.com/compute/docs/containers/configuring-options-to-run-containers), can be passed in as part of the `container` map.\n\nThe `instance_with_advanced_options` example also demonstrates this.\n\n```hcl\nmodule \"gce-advanced-container\" {\n  source = \"terraform-google-modules/container-vm/google\"\n  version = \"~\u003e 2.0\"\n\n  container = {\n    image = \"busybox\"\n    command = [\n      \"tail\"\n    ]\n    args = [\n      \"-f\",\n      \"/dev/null\"\n    ]\n    securityContext = {\n      privileged : true\n    }\n    tty : true\n    env = [\n      {\n        name  = \"EXAMPLE\"\n        value = \"VAR\"\n      }\n    ]\n  }\n\n  restart_policy = \"OnFailure\"\n}\n```\n\n## Requirements\n### Terraform plugins\n- [Terraform](https://www.terraform.io/downloads.html) \u003e= 0.13.0\n- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) plugin v1.8.0\n\n### Python Libraries\n- [terraform_external_data](https://github.com/operatingops/terraform_external_data)\n\n### Configure a Service Account\nIn order to execute this module you must have a Service Account with the following:\n\n#### Permissions\n- `compute.disks.*` on the project\n- `compute.diskTypes.get` on the project\n- `compute.diskTypes.list` on the project\n\n### Enable API's\nIn order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:\n\n- Compute Engine API - compute.googleapis.com\n\n## Install\n\n### Terraform\nBe sure you have the correct Terraform version (0.10.x), you can choose the binary here:\n- https://releases.hashicorp.com/terraform/\n\n## File structure\nThe project has the following folders and files:\n\n- /: root folder\n- /examples: Examples for using this module\n- /helpers: Scripts that the module invokes\n- /test: Folders with files for testing the module (see Testing section of this file)\n- /main.tf: main file for this module, contains all the resources to create\n- /variables.tf: all the variables for the module\n- /output.tf: the outputs of the module\n- /readme.md: this file\n\n## Testing\n\n### Requirements\n- [docker](https://www.docker.com/)\n- [terraform-docs](https://github.com/segmentio/terraform-docs/releases) 0.3.0\n\n### Autogeneration of documentation from .tf files\nRun\n```\nmake generate_docs\n```\n\n### Integration test\n\n#### Terraform integration tests\nThe integration tests for this module leverage [kitchen-terraform](https://github.com/newcontext-oss/kitchen-terraform) and [kitchen-inspec](https://github.com/inspec/kitchen-inspec), and run entirely within `docker` containers.\n\nThe tests will do the following:\n- Perform `bundle install` command\n  - Installs `kitchen-terraform` and `kitchen-inspec` gems\n- Perform `kitchen create` command\n  - Performs a `terraform init`\n- Perform `kitchen converge` command\n  - Performs a `terraform apply -auto-approve`\n- Perform `kitchen validate` command\n  - Performs inspec tests.\n    - Shell out to `gcloud` to validate expected resources in GCP.\n    - Log into deployed resources to validate Docker configuration.\n    - Make HTTP requests to endpoints that are expected to be online.\n- Perform `kitchen destroy` command\n  - Performs a `terraform destroy -force`\n\nBefore running integration tests, you need to configure `terraform.tfvars` for your particular environment editing `test/fixtures/shared/terraform.tfvars` to reflect your testing environment.\n\nYou can then use the following command to run the integration test in the root folder\n\n  `make test_integration_docker`\n\n### Linting\nThe makefile in this project will lint or sometimes just format any shell,\nPython, golang, Terraform. The linters will only be run if\nthe makefile finds files with the appropriate file extension.\n\nAll of the linter checks are in the default make target, so you just have to\nrun\n\n```\nmake -s\n```\n\nThe -s is for 'silent'. Successful output looks like below and exists with 0 exit code.\n\n```\n$ make -s\nRunning shellcheck\nRunning flake8\nRunning go fmt and go vet\nRunning terraform fmt\nterraform fmt -diff -check=true -write=false .\nterraform fmt -diff -check=true -write=false ./examples/instance_with_attached_disk\nterraform fmt -diff -check=true -write=false ./examples/simple_instance\nterraform fmt -diff -check=true -write=false ./modules/cos-coredns\nterraform fmt -diff -check=true -write=false ./modules/cos-generic\nterraform fmt -diff -check=true -write=false ./modules/cos-mysql\nterraform fmt -diff -check=true -write=false ./test/fixtures/instance_with_attached_disk\nterraform fmt -diff -check=true -write=false ./test/fixtures/shared\nterraform fmt -diff -check=true -write=false ./test/fixtures/simple_instance\nRunning terraform validate\nhelpers/terraform_validate .\n\nInitializing provider plugins...\n\nThe following providers do not have any version constraints in configuration,\nso the latest version was installed.\n\nTo prevent automatic upgrades to new major versions that may contain breaking\nchanges, it is recommended to add version = \"...\" constraints to the\ncorresponding provider blocks in configuration, with the constraint strings\nsuggested below.\n\n* provider.external: version = \"~\u003e 1.2\"\n* provider.google: version = \"~\u003e 2.12\"\n\nTerraform has been successfully initialized!\n\nYou may now begin working with Terraform. Try running \"terraform plan\" to see\nany changes that are required for your infrastructure. All Terraform commands\nshould now work.\n\nIf you ever set or change modules or backend configuration for Terraform,\nrerun this command to reinitialize your working directory. If you forget, other\ncommands will detect it and remind you to do so if necessary.\nSuccess! The configuration is valid.\n\nhelpers/terraform_validate ./examples/instance_with_attached_disk\nInitializing modules...\n\nInitializing provider plugins...\n\nThe following providers do not have any version constraints in configuration,\nso the latest version was installed.\n\nTo prevent automatic upgrades to new major versions that may contain breaking\nchanges, it is recommended to add version = \"...\" constraints to the\ncorresponding provider blocks in configuration, with the constraint strings\nsuggested below.\n\n* provider.external: version = \"~\u003e 1.2\"\n* provider.google: version = \"~\u003e 2.12\"\n\nTerraform has been successfully initialized!\n\nYou may now begin working with Terraform. Try running \"terraform plan\" to see\nany changes that are required for your infrastructure. All Terraform commands\nshould now work.\n\nIf you ever set or change modules or backend configuration for Terraform,\nrerun this command to reinitialize your working directory. If you forget, other\ncommands will detect it and remind you to do so if necessary.\nSuccess! The configuration is valid.\n\nhelpers/terraform_validate ./examples/simple_instance\nInitializing modules...\n\nInitializing provider plugins...\n\nThe following providers do not have any version constraints in configuration,\nso the latest version was installed.\n\nTo prevent automatic upgrades to new major versions that may contain breaking\nchanges, it is recommended to add version = \"...\" constraints to the\ncorresponding provider blocks in configuration, with the constraint strings\nsuggested below.\n\n* provider.external: version = \"~\u003e 1.2\"\n* provider.google: version = \"~\u003e 2.12\"\n* provider.random: version = \"~\u003e 2.2\"\n\nTerraform has been successfully initialized!\n\nYou may now begin working with Terraform. Try running \"terraform plan\" to see\nany changes that are required for your infrastructure. All Terraform commands\nshould now work.\n\nIf you ever set or change modules or backend configuration for Terraform,\nrerun this command to reinitialize your working directory. If you forget, other\ncommands will detect it and remind you to do so if necessary.\nSuccess! The configuration is valid.\n\nhelpers/terraform_validate ./modules/cos-coredns\n\nInitializing provider plugins...\n\nThe following providers do not have any version constraints in configuration,\nso the latest version was installed.\n\nTo prevent automatic upgrades to new major versions that may contain breaking\nchanges, it is recommended to add version = \"...\" constraints to the\ncorresponding provider blocks in configuration, with the constraint strings\nsuggested below.\n\n* provider.google: version = \"~\u003e 2.12\"\n* provider.template: version = \"~\u003e 2.1\"\n\nTerraform has been successfully initialized!\n\nYou may now begin working with Terraform. Try running \"terraform plan\" to see\nany changes that are required for your infrastructure. All Terraform commands\nshould now work.\n\nIf you ever set or change modules or backend configuration for Terraform,\nrerun this command to reinitialize your working directory. If you forget, other\ncommands will detect it and remind you to do so if necessary.\nSuccess! The configuration is valid.\n\nhelpers/terraform_validate ./modules/cos-generic\n\nInitializing provider plugins...\n\nThe following providers do not have any version constraints in configuration,\nso the latest version was installed.\n\nTo prevent automatic upgrades to new major versions that may contain breaking\nchanges, it is recommended to add version = \"...\" constraints to the\ncorresponding provider blocks in configuration, with the constraint strings\nsuggested below.\n\n* provider.google: version = \"~\u003e 2.12\"\n* provider.template: version = \"~\u003e 2.1\"\n\nTerraform has been successfully initialized!\n\nYou may now begin working with Terraform. Try running \"terraform plan\" to see\nany changes that are required for your infrastructure. All Terraform commands\nshould now work.\n\nIf you ever set or change modules or backend configuration for Terraform,\nrerun this command to reinitialize your working directory. If you forget, other\ncommands will detect it and remind you to do so if necessary.\nSuccess! The configuration is valid.\n\nhelpers/terraform_validate ./modules/cos-mysql\n\nInitializing provider plugins...\n\nThe following providers do not have any version constraints in configuration,\nso the latest version was installed.\n\nTo prevent automatic upgrades to new major versions that may contain breaking\nchanges, it is recommended to add version = \"...\" constraints to the\ncorresponding provider blocks in configuration, with the constraint strings\nsuggested below.\n\n* provider.google: version = \"~\u003e 2.12\"\n* provider.random: version = \"~\u003e 2.2\"\n* provider.template: version = \"~\u003e 2.1\"\n\nTerraform has been successfully initialized!\n\nYou may now begin working with Terraform. Try running \"terraform plan\" to see\nany changes that are required for your infrastructure. All Terraform commands\nshould now work.\n\nIf you ever set or change modules or backend configuration for Terraform,\nrerun this command to reinitialize your working directory. If you forget, other\ncommands will detect it and remind you to do so if necessary.\nSuccess! The configuration is valid.\n\nhelpers/terraform_validate ./test/fixtures/instance_with_attached_disk\nInitializing modules...\n\nInitializing provider plugins...\n\nThe following providers do not have any version constraints in configuration,\nso the latest version was installed.\n\nTo prevent automatic upgrades to new major versions that may contain breaking\nchanges, it is recommended to add version = \"...\" constraints to the\ncorresponding provider blocks in configuration, with the constraint strings\nsuggested below.\n\n* provider.external: version = \"~\u003e 1.2\"\n* provider.google: version = \"~\u003e 2.12\"\n* provider.local: version = \"~\u003e 1.3\"\n* provider.random: version = \"~\u003e 2.2\"\n* provider.tls: version = \"~\u003e 2.0\"\n\nTerraform has been successfully initialized!\n\nYou may now begin working with Terraform. Try running \"terraform plan\" to see\nany changes that are required for your infrastructure. All Terraform commands\nshould now work.\n\nIf you ever set or change modules or backend configuration for Terraform,\nrerun this command to reinitialize your working directory. If you forget, other\ncommands will detect it and remind you to do so if necessary.\nSuccess! The configuration is valid.\n\nhelpers/terraform_validate ./test/fixtures/simple_instance\nInitializing modules...\n\nInitializing provider plugins...\n\nThe following providers do not have any version constraints in configuration,\nso the latest version was installed.\n\nTo prevent automatic upgrades to new major versions that may contain breaking\nchanges, it is recommended to add version = \"...\" constraints to the\ncorresponding provider blocks in configuration, with the constraint strings\nsuggested below.\n\n* provider.external: version = \"~\u003e 1.2\"\n* provider.google: version = \"~\u003e 2.12\"\n* provider.random: version = \"~\u003e 2.2\"\n\nTerraform has been successfully initialized!\n\nYou may now begin working with Terraform. Try running \"terraform plan\" to see\nany changes that are required for your infrastructure. All Terraform commands\nshould now work.\n\nIf you ever set or change modules or backend configuration for Terraform,\nrerun this command to reinitialize your working directory. If you forget, other\ncommands will detect it and remind you to do so if necessary.\nSuccess! The configuration is valid.\n\nChecking for required files LICENSE README.md\nTesting the validity of the header check\n..\n----------------------------------------------------------------------\nRan 2 tests in 0.014s\n\nOK\nChecking file headers\nChecking for trailing whitespace\nGenerating markdown docs with terraform-docs\nSkipping ./test/fixtures/instance_with_attached_disk because README.md does not exist.\nSkipping ./test/fixtures/shared because README.md does not exist.\nSkipping ./test/fixtures/simple_instance because README.md does not exist.\n$ echo $?\n0\n```\n\nThe linters are as follows:\n* Shell - shellcheck. Can be found in homebrew\n* Python - flake8. Can be installed with 'pip install flake8'\n* Golang - gofmt. gofmt comes with the standard golang installation. golang is a compiled language so there is no standard linter.\n* Terraform (built-in):\n  - `terraform fmt`\n  - `terraform validate`.\n* File headers\n* Trailing whitespaces\n\n## Known limitations\nManaged instance group\n[example](https://github.com/terraform-google-modules/terraform-google-container-vm/tree/master/examples/managed_instance_group/main.tf)\nis not migrated to Terraform 0.12.\nThis is tracked as issue [`#28`](https://github.com/terraform-google-modules/terraform-google-container-vm/issues/28)\nLinters and integrations tests skip this example and associated tests for now.\n\n[0.3.0]: https://registry.terraform.io/modules/terraform-google-modules/container-vm/google/0.3.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterraform-google-modules%2Fterraform-google-container-vm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterraform-google-modules%2Fterraform-google-container-vm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterraform-google-modules%2Fterraform-google-container-vm/lists"}