Skip to content

Commit

Permalink
updating 4-projects
Browse files Browse the repository at this point in the history
  • Loading branch information
caetano-colin committed May 28, 2024
1 parent 640e75c commit 4d5e3d9
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 9 deletions.
17 changes: 17 additions & 0 deletions docs/assets/terraform/4-projects/common.auto.example.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/

remote_state_bucket = "REMOTE_STATE_BUCKET"
19 changes: 19 additions & 0 deletions docs/assets/terraform/4-projects/development.auto.example.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/

location_kms = "us"
location_gcs = "US"
env = "development"
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module "app_infra_artifacts_project" {
secondary_contact = var.secondary_contact
business_code = var.business_code
environment_kms_project_id = var.environment_kms_project_id
project_name = "${var.project_prefix}-${local.env_code}-${var.business_code}${var.artifacts_project_suffix}"
project_name = "${var.project_prefix}-${local.env_code}-${var.business_code}-${var.artifacts_project_suffix}"
prevent_destroy = var.prevent_destroy
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module "app_service_catalog_project" {
secondary_contact = var.secondary_contact
business_code = var.business_code
environment_kms_project_id = var.environment_kms_project_id
project_name = "${var.project_prefix}-${local.env_code}-${var.business_code}${var.service_catalog_project_suffix}"
project_name = "${var.project_prefix}-${local.env_code}-${var.business_code}-${var.service_catalog_project_suffix}"
prevent_destroy = var.prevent_destroy
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ variable "artifacts_project_suffix" {
variable "service_catalog_project_suffix" {
description = "Service Catalog Project Suffix."
type = string
default = "service-catalog"
default = "svc-catalog"
}

variable "service_catalog_application_name" {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/

location_kms = "us"
location_gcs = "US"
env = "non-production"
19 changes: 19 additions & 0 deletions docs/assets/terraform/4-projects/production.auto.example.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/

location_kms = "us"
location_gcs = "US"
env = "production"
22 changes: 22 additions & 0 deletions docs/assets/terraform/4-projects/shared.auto.example.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/

# We suggest you to use the same region from the 0-bootstrap step
default_region = "us-central1"

cloud_source_service_catalog_repo_name = "svc-catalog"

cloud_source_artifacts_repo_name = "publish-artifacts"
63 changes: 57 additions & 6 deletions docs/deploy_on_foundation_v4.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,21 @@ variable "keyring_name" {
}
```

- Edit `gcp-org/envs/shared/outputs.tf` and add the following output:

```terraform
output "key_rings" {
description = "Keyring Names created"
value = module.kms_keyring.key_rings
}
```

Add files to git on `gcp-org`, commit and push code:

```bash
cd ../gcp-org
git add envs/shared/ml_key_rings.tf
git add envs/shared/ml_ops_org_policy.tf
git add envs/shared/remote.tf
git add envs/shared/variables.tf
git add modules
git add .
git commit -m "Add ML org policies and Org-level key"
git push origin production
Expand Down Expand Up @@ -1826,6 +1831,12 @@ cp -r docs/assets/terraform/4-projects/ml_business_unit ../gcp-projects
cp -r docs/assets/terraform/4-projects/modules/* ../gcp-projects/modules
```
- Add `tfvars` to the `gcp-projects` repository.
```bash
cp -r docs/assets/terraform/4-projects/*.example.tfvars ../gcp-projects/modules
```
- Go to `gcp-projects` repository.
```bash
Expand All @@ -1847,13 +1858,31 @@ export GOOGLE_IMPERSONATE_SERVICE_ACCOUNT=$(terraform -chdir="../gcp-bootstrap/e
echo ${GOOGLE_IMPERSONATE_SERVICE_ACCOUNT}
```

- Retrieve cloud build project id
- Retrieve cloud build project id.

```bash
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="../gcp-bootstrap/envs/shared" output -raw cloudbuild_project_id)
echo ${CLOUD_BUILD_PROJECT_ID}
```

- Rename `auto.example.tfvars` to `auto.tfvars`.

```bash
mv common.auto.example.tfvars common.auto.tfvars
mv shared.auto.example.tfvars shared.auto.tfvars
mv development.auto.example.tfvars development.auto.tfvars
mv nonproduction.auto.example.tfvars nonproduction.auto.tfvars
mv production.auto.example.tfvars production.auto.tfvars
```

- Commit the changes.

```bash
git add .
git commit -m "Create ML Business Unit"
```

- Log into gcloud using service account impersonation and then set your configuration:

```bash
Expand Down Expand Up @@ -1881,6 +1910,12 @@ gcloud auth application-default login --impersonate-service-account=${GOOGLE_IMP

This will create the artifacts and service catalog projects under `common` folder and configure the Machine Learning business unit infra pipeline.

Push plan branch to remote.

```bash
git push origin plan
```

### `development` branch on `gcp-projects`

This will create the machine learning development environment. A Machine Learning project will be hosted under a folder.
Expand Down Expand Up @@ -1911,12 +1946,28 @@ cp -r docs/assets/terraform/4-projects/ml_business_unit ../gcp-projects
cp -r docs/assets/terraform/4-projects/modules/* ../gcp-projects/modules
```

- Add `tfvars` to the `gcp-projects` repository.

```bash
cp -r docs/assets/terraform/4-projects/*.example.tfvars ../gcp-projects/modules
```

- Go to `gcp-projects` repository.

```bash
cd ../gcp-projects
```

- Rename `auto.example.tfvars` to `auto.tfvars`.

```bash
mv common.auto.example.tfvars common.auto.tfvars
mv shared.auto.example.tfvars shared.auto.tfvars
mv development.auto.example.tfvars development.auto.tfvars
mv nonproduction.auto.example.tfvars nonproduction.auto.tfvars
mv production.auto.example.tfvars production.auto.tfvars
```

- Update project backend by retrieving it's value from `0-bootstrap` and applying it to `backend.tf`.
```bash
Expand Down

0 comments on commit 4d5e3d9

Please sign in to comment.