Home

Awesome

Atlantis on Google Compute Engine

Header

This Terraform module deploys various resources to run Atlantis on Google Compute Engine.

Feature highlights

Prerequisites

This module expects that you already own or create the below resources yourself.

If you prefer an example that includes the above resources, see complete example.

Example Usage

Here are some examples to choose from. Look at the prerequisites above to find one that is appropriate for your configuration.

module "atlantis" {
  source  = "runatlantis/atlantis/gce"
  # insert the 7 required variables here
}

How to deploy

See main.tf and the server-atlantis.yaml.

Important

After it's successfully deployed

Once you're done, see Configuring Webhooks for Atlantis

Configuring Atlantis

Atlantis offers the ability to configure everything through environment variables.

The module exposes a variable: var.env_vars where you can pass any environment variable you want.

env_vars = {
  ATLANTIS_EXAMPLE = "example"
}

For an overview of all possible environment variables, see: Atlantis Server Configuration

Setting sensitive environment variables

See secured environment variables for an example on how to deal with sensitive values in environment variables.

Service Account

As Google recommends custom service accounts and permissions granted via IAM Roles. We advice that you bring your own service account.

Note that you must grant the relevant permissions to your service account yourself, e.g. Storage related permissions for the Terraform state bucket and other permissions in order to create resources through Terraform.

Permissions

The roles/logging.logWriter & roles/monitoring.metricWriter roles should be attached to the service account in order to write logs to Cloud Logging and ingest metric data into Cloud Monitoring.

See main.tf

DNS Record

This example uses Cloud DNS to add an A record containing the load balancer IP address. If you don't use Cloud DNS, please add the A record using the load balancer IP address on the platform where you've registered your domain.

It's a requirement to add the A record to the domain record set in order to sucessfully provision the certificate!

Example

If you use Cloud DNS and own a managed zone for your domain, use the IP address that's part of the module output to create the A record.

See main.tf

Identity-Aware Proxy

Google Cloud's Identity-Aware Proxy (IAP) is a service that can be used to secure the Atlantis UI by authenticating users with Google Accounts

Enabling IAP

To enable IAP, you will need to configure the OAuth Consent Screen and create OAuth credentials, as described in the Enabling IAP guide.

Once you have the OAuth credentials, you can set the iap variable to use them.

iap = {
  oauth2_client_id     = data.google_secret_manager_secret_version.atlantis_client_id.secret_data
  oauth2_client_secret = data.google_secret_manager_secret_version.atlantis_client_secret.secret_data
}

What's exactly protected?

With IAP enabled, all requests to Atlantis will be protected, except for those made to the /events path, which is used for webhooks between platforms such as GitHub and BitBucket.

Permissions

To grant a user access to your IAP-protected Atlantis deployment, you will need to give them the roles/iap.httpsResourceAccessor role.

resource "google_iap_web_iam_member" "member" {
  project = "<your-project-id>"
  role = "roles/iap.httpsResourceAccessor"
  member = "user:jane@example.com"
}

FAQ

When sending an HTTP request, I'm receiving an ERR_EMPTY_RESPONSE error

We expect you to use HTTPS because we are not routing or redirecting any HTTP requests.

My VM experienced an outage and is taking some time to restart

It may take up to three minutes for the Managed Instance Group to safely shut down and recreate the VM before it is considered healthy again.

Even though terraform apply worked correctly, I'm receiving an ERR_SSL_VERSION_OR_CIPHER_MISMATCH error

This error indicates that the Google Cloud Managed SSL certificate is not yet fully provisioned. If all configurations are correct, it may take up to 25 minutes for the certificate to be provisioned. You can check the status of the certificate in the Google Cloud Console.

<!-- BEGIN_TF_DOCS -->

Requirements

NameVersion
<a name="requirement_terraform"></a> terraform>= 0.13.0
<a name="requirement_cloudinit"></a> cloudinit>=2.2.0
<a name="requirement_google"></a> google>=4.79.0
<a name="requirement_google-beta"></a> google-beta>=4.79.0
<a name="requirement_random"></a> random>=3.4.3

Providers

NameVersion
<a name="provider_cloudinit"></a> cloudinit>=2.2.0
<a name="provider_google"></a> google>=4.79.0
<a name="provider_google-beta"></a> google-beta>=4.79.0
<a name="provider_random"></a> random>=3.4.3

Modules

NameSourceVersion
<a name="module_container"></a> containerterraform-google-modules/container-vm/google3.1.1

Resources

NameType
google-beta_google_compute_instance_group_manager.defaultresource
google_compute_backend_service.defaultresource
google_compute_backend_service.iapresource
google_compute_firewall.lb_health_checkresource
google_compute_global_address.defaultresource
google_compute_global_forwarding_rule.httpsresource
google_compute_health_check.defaultresource
google_compute_health_check.default_instance_group_managerresource
google_compute_instance_template.defaultresource
google_compute_managed_ssl_certificate.defaultresource
google_compute_route.public_internetresource
google_compute_target_https_proxy.defaultresource
google_compute_url_map.defaultresource
random_string.randomresource
cloudinit_config.configdata source
google_compute_image.cosdata source
google_netblock_ip_ranges.thisdata source

Inputs

NameDescriptionTypeDefaultRequired
<a name="input_block_project_ssh_keys_enabled"></a> block_project_ssh_keys_enabledBlocks the use of project-wide publich SSH keysboolfalseno
<a name="input_default_backend_security_policy"></a> default_backend_security_policyName of the security policy to apply to the default backend servicestringnullno
<a name="input_disk_kms_key_self_link"></a> disk_kms_key_self_linkThe self link of the encryption key that is stored in Google Cloud KMSstringnullno
<a name="input_domain"></a> domainDomain to associate Atlantis with and to request a managed SSL certificate for. Without https://stringn/ayes
<a name="input_enable_confidential_vm"></a> enable_confidential_vmEnable Confidential VM. If true, on host maintenance will be set to TERMINATEboolfalseno
<a name="input_enable_oslogin"></a> enable_osloginEnables OS Login service on the VMboolfalseno
<a name="input_env_vars"></a> env_varsKey-value pairs representing environment variables and their respective valuesmap(any)n/ayes
<a name="input_expose_healthz_publicly"></a> expose_healthz_publiclyExposes the /healthz endpoint publicly even if Atlantis is protected by IAPboolfalseno
<a name="input_expose_metrics_publicly"></a> expose_metrics_publiclyExposes the /metrics endpoint publicly even if Atlantis is protected by IAPboolfalseno
<a name="input_google_logging_enabled"></a> google_logging_enabledEnable Google Cloud Loggingbooltrueno
<a name="input_google_logging_use_fluentbit"></a> google_logging_use_fluentbitEnable Google Cloud Logging using Fluent Bitboolfalseno
<a name="input_google_monitoring_enabled"></a> google_monitoring_enabledEnable Google Cloud Monitoringbooltrueno
<a name="input_iap"></a> iapSettings for enabling Cloud Identity Aware Proxy to protect the Atlantis UI<pre>object({<br> oauth2_client_id = string<br> oauth2_client_secret = string<br> })</pre>nullno
<a name="input_iap_backend_security_policy"></a> iap_backend_security_policyName of the security policy to apply to the IAP backend servicestringnullno
<a name="input_image"></a> imageDocker image. This is most often a reference to a container located in a container registrystring"ghcr.io/runatlantis/atlantis:latest"no
<a name="input_labels"></a> labelsKey-value pairs representing labels attaching to instance & instance templatemap(any){}no
<a name="input_machine_image"></a> machine_imageThe machine image to create VMs with, if not specified, latest cos_cloud/cos_stable is usedstringnullno
<a name="input_machine_type"></a> machine_typeThe machine type to run Atlantis onstring"n2-standard-2"no
<a name="input_name"></a> nameCustom name that's used during resource creationstringn/ayes
<a name="input_network"></a> networkName of the networkstringn/ayes
<a name="input_persistent_disk_size_gb"></a> persistent_disk_size_gbThe size of the persistent disk that Atlantis uses to store its data onnumber50no
<a name="input_persistent_disk_type"></a> persistent_disk_typeThe type of persistent disk that Atlantis uses to store its data onstring"pd-ssd"no
<a name="input_project"></a> projectThe ID of the project in which the resource belongsstringnullno
<a name="input_region"></a> regionThe region that resources should be created instringn/ayes
<a name="input_service_account"></a> service_accountService account to attach to the instance running Atlantis<pre>object({<br> email = string,<br> scopes = list(string)<br> })</pre><pre>{<br> "email": "",<br> "scopes": [<br> "cloud-platform"<br> ]<br>}</pre>no
<a name="input_shared_vpc"></a> shared_vpcWhether to deploy within a shared VPC<pre>object({<br> host_project_id = string<br> })</pre>nullno
<a name="input_shielded_instance_config"></a> shielded_instance_configShielded VM provides verifiable integrity to prevent against malware and rootkits<pre>object({<br> enable_integrity_monitoring = optional(bool)<br> enable_vtpm = optional(bool)<br> enable_secure_boot = optional(bool)<br> })</pre><pre>{<br> "enable_integrity_monitoring": true,<br> "enable_secure_boot": true,<br> "enable_vtpm": true<br>}</pre>no
<a name="input_spot_machine_enabled"></a> spot_machine_enabledA Spot VM is discounted Compute Engine capacity that may be preemptively stopped or deleted by Compute Engine if the capacity is neededboolfalseno
<a name="input_ssl_policy"></a> ssl_policyThe SSL policy name that the certificate must followstringnullno
<a name="input_startup_script"></a> startup_scriptA startup script that runs during the boot cycle when you first launch an instancestringnullno
<a name="input_subnetwork"></a> subnetworkName of the subnetwork to attach a network interface tostringn/ayes
<a name="input_tags"></a> tagsTags to attach to the instance running Atlantislist(string)[]no
<a name="input_zone"></a> zoneThe zone that instances should be created instringn/ayes

Outputs

NameDescription
<a name="output_cos_image_id"></a> cos_image_idThe unique identifier of the Container-Optimized OS image used to create the Compute Engine instance.
<a name="output_iap_backend_service_name"></a> iap_backend_service_nameName of the optional IAP-enabled backend service
<a name="output_ip_address"></a> ip_addressThe IPv4 address of the load balancer
<a name="output_managed_ssl_certificate_certificate_id"></a> managed_ssl_certificate_certificate_idThe unique identifier of the Google Managed SSL certificate
<a name="output_managed_ssl_certificate_expire_time"></a> managed_ssl_certificate_expire_timeExpire time of the Google Managed SSL certificate
<!-- END_TF_DOCS -->