Skip to content

Conversation

@ivankorn
Copy link
Contributor

@ivankorn ivankorn commented Sep 11, 2019

Fixes #28

Migrated MIG example to TF 0.12 syntax and compatible modules

  • Migrated to TF 0.12 syntax
  • Added provider version restrictions
  • Migrated to TF 0.12 compatible modules
  • Added provision of required resources:
    • network
    • subnetwork
    • router
    • cloud-nat
  • Optimized tag assignment with local variable
  • Added new required variables:
    • service_account
    • network

Please note:

This PR depends on terraform-google-modules/terraform-google-lb-http#52

TO DO (once lb-http PR is merged):

@ivankorn
Copy link
Contributor Author

Example has passed provision:

[19:06][user@host:~/workspace/google/terraform-google-container-vm/examples/managed_instance_group]$ terraform apply -auto-approve
module.gce-container.data.external.spec_as_yaml: Refreshing state...
module.mig_template.data.google_compute_image.image_family: Refreshing state...
module.mig.data.google_compute_zones.available: Refreshing state...
module.gce-container.data.google_compute_image.coreos: Refreshing state...
module.mig_template.data.google_compute_image.image: Refreshing state...
module.http-lb.google_compute_http_health_check.default[0]: Creating...
module.http-lb.google_compute_global_address.default: Creating...
module.cloud-nat.random_string.name_suffix: Creating...
google_compute_firewall.lb-to-instances: Creating...
google_compute_network.default: Creating...
module.cloud-nat.random_string.name_suffix: Creation complete after 0s [id=gh2fso]
module.http-lb.google_compute_global_address.default: Creation complete after 5s [id=mig-test-lb-address]
module.http-lb.google_compute_http_health_check.default[0]: Creation complete after 5s [id=mig-test-lb-backend-0]
google_compute_firewall.lb-to-instances: Still creating... [10s elapsed]
google_compute_network.default: Still creating... [10s elapsed]
google_compute_firewall.lb-to-instances: Creation complete after 17s [id=mig-test-firewall-lb-to-instances]
google_compute_network.default: Still creating... [20s elapsed]
google_compute_network.default: Creation complete after 28s [id=mig-net]
google_compute_router.default: Creating...
google_compute_subnetwork.default: Creating...
module.http-lb.google_compute_firewall.default-hc[0]: Creating...
google_compute_router.default: Creation complete after 4s [id=us-east4/mig-net-gw-group1]
module.cloud-nat.google_compute_router_nat.main: Creating...
google_compute_subnetwork.default: Still creating... [10s elapsed]
module.http-lb.google_compute_firewall.default-hc[0]: Still creating... [10s elapsed]
module.cloud-nat.google_compute_router_nat.main: Still creating... [10s elapsed]
module.http-lb.google_compute_firewall.default-hc[0]: Creation complete after 17s [id=mig-test-lb-hc-0]
google_compute_subnetwork.default: Creation complete after 18s [id=us-east4/mig-net]
module.mig_template.google_compute_instance_template.tpl: Creating...
module.mig_template.google_compute_instance_template.tpl: Creation complete after 4s [id=mig-net-20190912160943893500000001]
module.mig.google_compute_region_instance_group_manager.mig: Creating...
module.cloud-nat.google_compute_router_nat.main: Creation complete after 20s [id=us-east4/mig-net-gw-group1/mig-net-cloud-nat-group1]
module.mig.google_compute_region_instance_group_manager.mig: Still creating... [10s elapsed]
module.mig.google_compute_region_instance_group_manager.mig: Creation complete after 19s [id=gl-ivankorniienko-seed-251912/us-east4/mig-net-mig]
module.http-lb.google_compute_backend_service.default[0]: Creating...
module.http-lb.google_compute_backend_service.default[0]: Creation complete after 9s [id=mig-test-lb-backend-0]
module.http-lb.google_compute_url_map.default[0]: Creating...
module.http-lb.google_compute_url_map.default[0]: Creation complete after 4s [id=mig-test-lb-url-map]
module.http-lb.google_compute_target_http_proxy.default[0]: Creating...
module.http-lb.google_compute_target_http_proxy.default[0]: Creation complete after 5s [id=mig-test-lb-http-proxy]
module.http-lb.google_compute_global_forwarding_rule.http[0]: Creating...
module.http-lb.google_compute_global_forwarding_rule.http[0]: Still creating... [10s elapsed]
module.http-lb.google_compute_global_forwarding_rule.http[0]: Creation complete after 17s [id=mig-test-lb]

Apply complete! Resources: 15 added, 0 changed, 0 destroyed.

Outputs:

container = {
  "image" = "gcr.io/google-samples/hello-app:1.0"
}
http_address = 34.102.227.254
http_port = 80
project_id = gl-ivankorniienko-seed-251912
vm_container_label = cos-stable-76-12239-60-0
volumes = []
[19:10][user@host:~/workspace/google/terraform-google-container-vm/examples/managed_instance_group]$ 

And passed the test after provision as well:

[19:16][user@host:~/workspace/google/terraform-google-container-vm/examples/managed_instance_group]$ curl http://$(terraform output http_address):$(terraform output http_port)
Hello, world!
Version: 1.0.0
Hostname: mig-net-l37q
[19:16][user@host:~/workspace/google/terraform-google-container-vm/examples/managed_instance_group]$ curl http://$(terraform output http_address):$(terraform output http_port)
Hello, world!
Version: 1.0.0
Hostname: mig-net-z4w8
[19:16][user@host:~/workspace/google/terraform-google-container-vm/examples/managed_instance_group]$

@aaron-lane aaron-lane added the enhancement New feature or request label Sep 16, 2019
{
name = "http",
port = var.image_port
}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above RE: moving trailing ] to separate line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is still the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, sorry for that :)

@ivankorn ivankorn force-pushed the 28 branch 2 times, most recently from b6d0f96 to 1c02f6b Compare October 8, 2019 12:15
Copy link
Contributor

@Jberlinsky Jberlinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One style nit-pick, otherwise LGTM!

{
name = "http",
port = var.image_port
}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is still the case?

- Migrated to TF 0.12 syntax
- Added provider version restrictions
- Migrated to TF 0.12 compatible modules
- Added provision of required resources:
  - network
  - submentwork
  - router
  - cloud-nat
- Optimized tag assigment with local variable
- Added new required variables:
  - service_account
  - network
@morgante morgante merged commit c558f42 into terraform-google-modules:master Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update MIG example to use Terraform v0.12 compatible modules

6 participants