Skip to content

refactor!: gce-container-declaration deprecation#188

Merged
d-costa merged 1 commit into
runatlantis:mainfrom
nosportugal:refactor-gce-containers
Nov 19, 2025
Merged

refactor!: gce-container-declaration deprecation#188
d-costa merged 1 commit into
runatlantis:mainfrom
nosportugal:refactor-gce-containers

Conversation

@d-costa

@d-costa d-costa commented Sep 12, 2025

Copy link
Copy Markdown
Collaborator

Due to the Compute Engine container startup agent deprecation on July 21 2025, GCP recommends now using a startup script or cloud-init to run containers in VMs.

To avoid impacting users that already have startup scripts, this commit uses cloud-init to spin up the container.

Changes:

  • Remove container module
  • Add service responsible for the Atlantis container
  • Changed command and args default values to [] instead of null, since we can't iterate null values

Impact:

  • google_compute_disk.persistent will be updated in-place
  • google_compute_instance_group_manager.default will be updated in-place
  • google_compute_instance_template.default must be replaced

Requires a couple minutes of downtime while the VM is restarted.

Sources:


I tested creating and updating from an existing deployment, and it went as expected. Nonetheless, it would be best if someone else could confirm it 😄

@d-costa d-costa requested a review from a team as a code owner September 12, 2025 12:12
@d-costa d-costa force-pushed the refactor-gce-containers branch from 2f45ee3 to 3e10576 Compare September 12, 2025 12:15
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 12, 2025
@d-costa

d-costa commented Sep 12, 2025

Copy link
Copy Markdown
Collaborator Author

hey @Zurvarian, can you take a look? Let me know if you have any suggestions and whether this works for you 👍

@Zurvarian

Copy link
Copy Markdown

@d-costa I'll try to give it a try when I'm free (Possibly next week)

@d-costa d-costa self-assigned this Sep 15, 2025
@d-costa d-costa force-pushed the refactor-gce-containers branch from 3e10576 to a1696c0 Compare September 15, 2025 09:42
@Zurvarian

Copy link
Copy Markdown

@d-costa I've tested your fork and it worked fine, thanks!

@bschaatsbergen

bschaatsbergen commented Sep 18, 2025

Copy link
Copy Markdown
Contributor

Thanks for working on this!

@d-costa d-costa force-pushed the refactor-gce-containers branch from a1696c0 to c9ee670 Compare October 23, 2025 09:06
@AndreaGiardini

Copy link
Copy Markdown

@d-costa Thank you for your work 🙏

When testing this change i had to add

  command = []
  args = []

to the definition of my module. Otherwise terraform would fail with:

╷
│ Error: Invalid function argument
│ 
│   on .terraform/modules/atlantis/main.tf line 89, in data "cloudinit_config" "config":
│   89:           ExecStart=/usr/bin/docker run -u ${local.atlantis_uid} --rm --publish '0.0.0.0:${local.atlantis_port}:${local.atlantis_port}' -v ${local.atlantis_disk_mount_path}:${local.atlantis_data_dir} %{for key, value in var.env_vars} -e '${key}=${value}'%{endfor} --name=atlantis ${var.image} ${join(" ", var.command)} ${join(" ", var.args)}
│     ├────────────────
│     │ while calling join(separator, lists...)
│     │ var.command is null
│ 
│ Invalid value for "lists" parameter: argument must not be null.
╵
╷
│ Error: Invalid function argument
│ 
│   on .terraform/modules/atlantis/main.tf line 89, in data "cloudinit_config" "config":
│   89:           ExecStart=/usr/bin/docker run -u ${local.atlantis_uid} --rm --publish '0.0.0.0:${local.atlantis_port}:${local.atlantis_port}' -v ${local.atlantis_disk_mount_path}:${local.atlantis_data_dir} %{for key, value in var.env_vars} -e '${key}=${value}'%{endfor} --name=atlantis ${var.image} ${join(" ", var.command)} ${join(" ", var.args)}
│     ├────────────────
│     │ while calling join(separator, lists...)
│     │ var.args is null
│ 
│ Invalid value for "lists" parameter: argument must not be null.
╵

@d-costa d-costa force-pushed the refactor-gce-containers branch 2 times, most recently from 2232206 to 45890e6 Compare November 19, 2025 15:39
Due to the Compute Engine container startup agent deprecation on July
21 2025, GCP recommends now using a startup script or cloud-init to run
containers in VMs.

To avoid impacting users that already have startup scripts, this commit
uses cloud-init to spin up the container.

Changes:

- Remove container module
- Add service responsible for the Atlantis container
- Changed `command` and `args` default values to `[]` instead of null,
  since we can't iterate null values

Impact:

- `google_compute_disk.persistent will be updated in-place`
- `google_compute_instance_group_manager.default` will be updated in-place`
- `google_compute_instance_template.default must be replaced`

**Requires a couple minutes of downtime while the VM is restarted.**

Sources:

- https://cloud.google.com/compute/docs/deprecations/container-startup-agent-on-compute
- https://cloud.google.com/compute/docs/containers/migrate-containers

Signed-off-by: David Costa <33375428+d-costa@users.noreply.github.com>
@d-costa d-costa force-pushed the refactor-gce-containers branch from 45890e6 to ce608fa Compare November 19, 2025 15:47
@d-costa

d-costa commented Nov 19, 2025

Copy link
Copy Markdown
Collaborator Author

thanks for the heads up @AndreaGiardini, I went ahead and changed the default values to [] 👍

@d-costa d-costa merged commit 5079b16 into runatlantis:main Nov 19, 2025
6 checks passed
@d-costa d-costa deleted the refactor-gce-containers branch November 19, 2025 18:21
@kpocius

kpocius commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Let me know if this would rather be discussed on a separate issue than a closed PR, but I have just tried upgrading and after restart the disk is simply not mounted. Same if I create a new instance. I looked everywhere in the module and simply fail to see what is supposed to format and mount the disk.

Please ignore me, just found #195

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate to use Cloud-init instead of StartUp-Script for the startup script

5 participants