Skip to content

Latest commit

 

History

History
105 lines (81 loc) · 3.78 KB

File metadata and controls

105 lines (81 loc) · 3.78 KB

follow on Twitter

Terraform module for Google Container Registry

➡️ Terraform module for Azure Container Registry

➡️ Terraform module for AWS Container Registry

Versions

  • Module tested for Terraform 1.0.1.
  • Google provider version 4.12.0
  • main branch: Provider versions not pinned to keep up with Terraform releases
  • tags releases: Tags are pinned with versions (use in your releases)

Usage

Option 1:

terrafrom init
terraform plan -var='teamid=tryme' -var='prjid=project1'
terraform apply -var='teamid=tryme' -var='prjid=project1'
terraform destroy -var='teamid=tryme' -var='prjid=project1'

Note: With this option please take care of remote state storage

Option 2:

Recommended method (stores remote state in S3 using prjid and teamid to create directory structure):
  • Create python 3.8+ virtual environment
python3 -m venv <venv name>
  • Install package:
pip install tfremote --upgrade
  • Set below environment variables:
export TF_GCLOUD_BUCKET=<remote state bucket name>
export TF_GCLOUD_PREFIX=<remote state bucket prefix>
export TF_GCLOUD_CREDENTIALS=<gcp credentials.json>
  • Updated examples directory with required values.

  • Run and verify the output before deploying:

tf -c=gcloud plan -var='teamid=foo' -var='prjid=bar'
  • Run below to deploy:
tf -c=gcloud apply -var='teamid=foo' -var='prjid=bar'
  • Run below to destroy:
tf -c=gcloud destroy -var='teamid=foo' -var='prjid=bar'

Note: Read more on tfremote

Google Container Registry
module "gcr" {
  source = "../"

  deploy_registry   = true
  gcp_project       = "demo-1000"
  dockerfile_folder = "scripts"
  name              = "test"
  #----------------------------------------------
  # Note: Do not change teamid and prjid once set.
  teamid = var.teamid
  prjid  = var.prjid
}

Please refer to examples directory link for references.

Note

  • Ensure there are executable permissions on scripts/build.sh