This example illustrates how to deploy a container to a managed instance group in GCP. Also includes SSH key configuration, so a user can be provisioned on the fly for future logins.
This example requires that some python libraries be installed, as outlined in requirements.txt
. Depending on your environment, you should be able to run pip install -r requirements.txt
to satisfy these requirements.
Name | Description | Type | Default | Required |
---|---|---|---|---|
additional_metadata | Additional metadata to attach to the instance | map(any) |
{} |
no |
image | The Docker image to deploy to GCE instances | string |
"gcr.io/google-samples/hello-app:1.0" |
no |
image_port | The port the image exposes for HTTP requests | number |
8080 |
no |
mig_instance_count | The number of instances to place in the managed instance group | string |
"2" |
no |
mig_name | The desired name to assign to the deployed managed instance group | string |
"mig-test" |
no |
network | The GCP network | string |
"mig-net" |
no |
project_id | The project ID to deploy resource into | string |
n/a | yes |
region | The GCP region to deploy instances into | string |
n/a | yes |
service_account | n/a | object({ |
{ |
no |
subnetwork | The name of the subnetwork to deploy instances into | string |
"mig-subnet" |
no |
Name | Description |
---|---|
container | The container metadata provided to the module |
http_address | The IP address on which the HTTP service is exposed |
http_port | The port on which the HTTP service is exposed |
vm_container_label | The instance label containing container configuration |
volumes | The volume metadata provided to the module |
To provision this example, run the following from within this directory:
terraform init
to get pluginsterraform plan
to dry-run the infrastructure changesterraform apply
to apply the infrastructure changesterraform destroy
to tear down the created infrastructure