Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bf83e89
Update README.md
fernandorubbo Sep 11, 2019
e6bcec8
Moving to terraform 1.0.0
fernandorubbo Jun 10, 2021
d8fc5e5
Update main.tf
nardo-google Sep 27, 2022
5ded46d
Merge pull request #554 from nardo-google/patch-1
fernandorubbo Sep 27, 2022
552f3b9
Update cloudbuild.yaml
nardo-google Sep 27, 2022
742eb87
Merge pull request #555 from nardo-google/patch-2
fernandorubbo Sep 27, 2022
31923ef
Fix typo in cloudbuild.yaml
mc-k1 Feb 2, 2024
dc4cbde
Merge pull request #780 from mc-k1/patch-1
iennae May 4, 2024
b503678
Update project IDs and buckets
Dec 12, 2024
b673ec6
Correction de la cible de pare-feu http
khalidkouttane Dec 12, 2024
1542c73
Update cloudbuild.yaml
khalidkouttane Dec 12, 2024
4f0280f
Update cloudbuild.yaml
khalidkouttane Dec 12, 2024
f35b552
Update cloudbuild.yaml
khalidkouttane Dec 12, 2024
73c0f4b
Update backend.tf
khalidkouttane Dec 12, 2024
c7d8de3
Update backend.tf
khalidkouttane Dec 12, 2024
3290270
Update backend.tf
khalidkouttane Dec 12, 2024
f55439b
Update backend.tf
khalidkouttane Dec 12, 2024
38b9a80
Update backend.tf
khalidkouttane Dec 12, 2024
51cfa2f
Update backend.tf
khalidkouttane Dec 12, 2024
c43ade0
Update backend.tf
khalidkouttane Dec 12, 2024
663d894
Update backend.tf
khalidkouttane Dec 12, 2024
0c55121
Update backend.tf
khalidkouttane Dec 12, 2024
7afd371
Update backend.tf
khalidkouttane Dec 12, 2024
bcdc388
Update backend.tf
khalidkouttane Dec 12, 2024
2a2c781
Update backend.tf
khalidkouttane Dec 12, 2024
9c002ba
Merge pull request #1 from khalidkouttane/fusion1
khalidkouttane Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Configuring your **dev** environment
# Managing infrastructure as code with Terraform, Cloud Build, and GitOps

This is the repo for the [Managing infrastructure as code with Terraform, Cloud Build, and GitOps](https://cloud.google.com/solutions/managing-infrastructure-as-code) tutorial. This tutorial explains how to manage infrastructure as code with Terraform and Cloud Build using the popular GitOps methodology.

## Configuring your **dev** environment

Just for demostration, this step will:
1. Configure an apache2 http server on network '**dev**' and subnet '**dev**-subnet-01'
Expand All @@ -12,7 +16,7 @@ terraform apply
terraform destroy
```

# Promoting your environment to **production**
## Promoting your environment to **production**

Once you have tested your app (in this example an apache2 http server), you can promote your configuration to prodution. This step will:
1. Configure an apache2 http server on network '**prod**' and subnet '**prod**-subnet-01'
Expand Down
18 changes: 10 additions & 8 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


options:
logging: CLOUD_LOGGING_ONLY
steps:
- id: 'branch name'
name: 'alpine'
Expand All @@ -25,7 +25,7 @@ steps:
echo "***********************"

- id: 'tf init'
name: 'hashicorp/terraform:0.11.14'
name: 'hashicorp/terraform:1.0.0'
entrypoint: 'sh'
args:
- '-c'
Expand All @@ -50,7 +50,7 @@ steps:

# [START tf-plan]
- id: 'tf plan'
name: 'hashicorp/terraform:0.11.14'
name: 'hashicorp/terraform:1.0.0'
entrypoint: 'sh'
args:
- '-c'
Expand All @@ -65,7 +65,7 @@ steps:
env=${dir%*/}
env=${env#*/}
echo ""
echo "*************** TERRAFOM PLAN ******************"
echo "*************** TERRAFORM PLAN ******************"
echo "******* At environment: ${env} ********"
echo "*************************************************"
terraform plan || exit 1
Expand All @@ -76,7 +76,7 @@ steps:

# [START tf-apply]
- id: 'tf apply'
name: 'hashicorp/terraform:0.11.14'
name: 'hashicorp/terraform:1.0.0'
entrypoint: 'sh'
args:
- '-c'
Expand All @@ -86,7 +86,9 @@ steps:
terraform apply -auto-approve
else
echo "***************************** SKIPPING APPLYING *******************************"
echo "Branch '$BRANCH_NAME' does not represent an oficial environment."
echo "Branch '$BRANCH_NAME' does not represent an official environment."
echo "*******************************************************************************"
fi
# [END tf-apply]
# [END tf-apply]


2 changes: 1 addition & 1 deletion environments/dev/backend.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

terraform {
backend "gcs" {
bucket = "PROJECT_ID-tfstate"
bucket = "gleaming-mason-444507-t9-tfstate"
prefix = "env/dev"
}
}
2 changes: 1 addition & 1 deletion environments/dev/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


locals {
"env" = "dev"
env = "dev"
}

provider "google" {
Expand Down
2 changes: 1 addition & 1 deletion environments/dev/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
project="PROJECT_ID"
project="gleaming-mason-444507-t9"
2 changes: 1 addition & 1 deletion environments/dev/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@


terraform {
required_version = "~> 0.11.0"
required_version = "~> 1.0.0"
}
2 changes: 1 addition & 1 deletion environments/prod/backend.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

terraform {
backend "gcs" {
bucket = "PROJECT_ID-tfstate"
bucket = "gleaming-mason-444507-t9-tfstate"
prefix = "env/prod"
}
}
2 changes: 1 addition & 1 deletion environments/prod/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


locals {
"env" = "prod"
env = "prod"
}

provider "google" {
Expand Down
2 changes: 1 addition & 1 deletion environments/prod/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
project="PROJECT_ID"
project="gleaming-mason-444507-t9"
2 changes: 1 addition & 1 deletion environments/prod/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@


terraform {
required_version = "~> 0.11.0"
required_version = "~> 1.0.0"
}
2 changes: 1 addition & 1 deletion modules/firewall/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ resource "google_compute_firewall" "allow-http" {
ports = ["80"]
}

target_tags = ["http-server2"]
target_tags = ["http-server"]
source_ranges = ["0.0.0.0/0"]
}
2 changes: 1 addition & 1 deletion modules/firewall/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@


terraform {
required_version = "~> 0.11.0"
required_version = "~> 1.0.0"
}
2 changes: 1 addition & 1 deletion modules/http_server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ resource "google_compute_instance" "http_server" {

boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
image = "debian-cloud/debian-11"
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/http_server/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@


terraform {
required_version = "~> 0.11.0"
required_version = "~> 1.0.0"
}
2 changes: 1 addition & 1 deletion modules/vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

module "vpc" {
source = "terraform-google-modules/network/google"
version = "0.6.0"
version = "3.3.0"

project_id = "${var.project}"
network_name = "${var.env}"
Expand Down
2 changes: 1 addition & 1 deletion modules/vpc/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@


terraform {
required_version = "~> 0.11.0"
required_version = "~> 1.0.0"
}