Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 7 additions & 3 deletions infra/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
# Make will use bash instead of sh
SHELL := /usr/bin/env bash

DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.12
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd
ENABLE_BPMETADATA := 1
export ENABLE_BPMETADATA

# Enter docker container for local development
.PHONY: docker_run
Expand Down Expand Up @@ -68,6 +70,7 @@ docker_test_integration:
.PHONY: docker_test_lint
docker_test_lint:
docker run --rm -it \
-e ENABLE_BPMETADATA \
-e EXCLUDE_LINT_DIRS \
-v "$(CURDIR)":/workspace \
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
Expand All @@ -77,9 +80,10 @@ docker_test_lint:
.PHONY: docker_generate_docs
docker_generate_docs:
docker run --rm -it \
-v "$(CURDIR)":/workspace \
-e ENABLE_BPMETADATA \
-v "$(dir ${CURDIR})":/workspace \
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs'
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs "-d -p infra"'

# Alias for backwards compatibility
.PHONY: generate_docs
Expand Down
66 changes: 66 additions & 0 deletions infra/metadata.display.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright 2023 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.

apiVersion: blueprints.cloud.google.com/v1alpha1
kind: BlueprintMetadata
metadata:
name: terraform-dynamic-python-webapp-display
spec:
info:
title: terraform-dynamic-python-webapp
source:
repo: https://github.com/GoogleCloudPlatform/terraform-dynamic-python-webapp
sourceType: git
ui:
input:
variables:
client_image_host:
name: client_image_host
title: Client Image Host
database_name:
name: database_name
title: Database Name
database_username:
name: database_username
title: Database Username
image_version:
name: image_version
title: Image Version
init:
name: init
title: Init
instance_name:
name: instance_name
title: Instance Name
labels:
name: labels
title: Labels
project_id:
name: project_id
title: Project Id
random_suffix:
name: random_suffix
title: Random Suffix
region:
name: region
title: Region
server_image_host:
name: server_image_host
title: Server Image Host
service_name:
name: service_name
title: Service Name
zone:
name: zone
title: Zone
204 changes: 109 additions & 95 deletions infra/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,99 +19,113 @@ metadata:
annotations:
config.kubernetes.io/local-config: "true"
spec:
title: terraform-dynamic-python-webapp
source:
repo: https://github.com/GoogleCloudPlatform/terraform-dynamic-python-webapp.git
sourceType: git
actuationTool:
type: Terraform
version: '>= 0.13'
description:
tagline: This is an auto-generated module.
detailed: |-
The resources/services/activations/deletions that this module will create/trigger are:
- Cloud Run
- Cloud SQL
- Firebase Hosting
- Secret Manager
- IAM
- Cloud Storage
preDeploy: To deploy this blueprint you must have an active billing account and billing permissions.
documentation:
- title: Hosting a Static Website
url: https://cloud.google.com/storage/docs/hosting-static-website
examples:
- name: simple_example
location: examples/simple_example
variables:
- name: database_name
description: Cloud SQL database name
type: string
default: django
required: false
- name: database_username
description: Cloud SQL database name
type: string
default: server
required: false
- name: image_host_project
description: Google Cloud Project that hosts images
type: string
default: hsa-public/terraform-python-dynamic-webapp
required: false
- name: init
description: Initialize database?
type: bool
default: true
required: false
- name: instance_name
description: Cloud SQL Instance name
type: string
default: psql
required: false
- name: labels
description: A set of key/value label pairs to assign to the resources deployed by this blueprint.
type: map(string)
default: {}
required: false
- name: project_id
description: Google Cloud Project ID
type: string
required: true
- name: random_suffix
description: Add random suffix to VM name
type: string
default: true
required: false
- name: region
description: Google Cloud Region
type: string
default: us-central1
required: false
- name: service_name
description: Cloud Run service name
type: string
default: server
required: false
- name: zone
description: GCP zone for provisioning zonal resources.
type: string
default: us-central1-c
required: false
outputs:
- name: django_admin_password
description: Djando Admin password
- name: django_admin_url
description: Djando Admin URL
- name: firebase_url
description: Firebase URL
- name: usage
description: Next steps for usage
roles:
- level: Project
info:
title: terraform-dynamic-python-webapp
source:
repo: https://github.com/GoogleCloudPlatform/terraform-dynamic-python-webapp
sourceType: git
actuationTool:
flavor: Terraform
version: '>= 0.13'
description:
tagline: This is an auto-generated module.
detailed: |-
The resources/services/activations/deletions that this module will create/trigger are:
- Cloud Run
- Cloud SQL
- Firebase Hosting
- Secret Manager
- IAM
- Cloud Storage
preDeploy: To deploy this blueprint you must have an active billing account and billing permissions.
content:
documentation:
- title: Hosting a Static Website
url: https://cloud.google.com/storage/docs/hosting-static-website
examples:
- name: simple_example
location: examples/simple_example
interfaces:
variables:
- name: client_image_host
description: Container Registry that hosts the client image (PROJECT_ID[/folder])
varType: string
defaultValue: hsa-public/terraform-python-dynamic-webapp
- name: database_name
description: Cloud SQL database name
varType: string
defaultValue: django
- name: database_username
description: Cloud SQL database name
varType: string
defaultValue: server
- name: image_version
description: Version of the Container Registry image to use
varType: string
defaultValue: v1.7.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note for maintainers: we'll want to follow-up this change with a release-please config to update this value.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the avocano version, not the self-version. Updating this is usually manual, are you saying release-please can help with this overhead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-please won't help with this. This should updated in the TF variable when a newer version of the blueprint is released and the metadata will be updated accordingly.

- name: init
description: Initialize database?
varType: bool
defaultValue: true
- name: instance_name
description: Cloud SQL Instance name
varType: string
defaultValue: psql
- name: labels
description: A set of key/value label pairs to assign to the resources deployed by this blueprint.
varType: map(string)
defaultValue: {}
- name: project_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Do these variables need to be manually synchronized with the terraform variables, or is something automatic going to happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are updated automatically with the TF variables defined for the blueprint.

description: Google Cloud Project ID
varType: string
required: true
- name: random_suffix
description: Add random suffix to VM name
varType: string
defaultValue: true
- name: region
description: Google Cloud Region
varType: string
defaultValue: us-central1
- name: server_image_host
description: Container Registry that hosts the server image (PROJECT_ID[/folder])
varType: string
defaultValue: hsa-public/terraform-python-dynamic-webapp
- name: service_name
description: Cloud Run service name
varType: string
defaultValue: server
- name: zone
description: GCP zone for provisioning zonal resources.
varType: string
defaultValue: us-central1-c
outputs:
- name: django_admin_password
description: Djando Admin password
- name: django_admin_url
description: Djando Admin URL
- name: firebase_url
description: Firebase URL
- name: neos_toc_url
description: Neos Tutorial URL
- name: usage
description: Next steps for usage
requirements:
roles:
- roles/owner
services:
- cloudresourcemanager.googleapis.com
- storage-api.googleapis.com
- serviceusage.googleapis.com
- level: Project
roles:
- roles/cloudsql.admin
- roles/compute.admin
- roles/compute.networkAdmin
- roles/firebase.managementServiceAgent
- roles/firebasehosting.admin
- roles/iam.serviceAccountAdmin
- roles/iam.serviceAccountUser
- roles/resourcemanager.projectIamAdmin
- roles/run.admin
- roles/secretmanager.admin
- roles/storage.admin
Comment on lines +115 to +127
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: I compared these to https://github.com/GoogleCloudPlatform/terraform-dynamic-python-webapp/blob/main/infra/test/setup/iam.tf#L17 and they appear to be the same. Seems like we will need to keep them manually in sync, unless we can parse the values from this config into the iam.tf.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infra/test/setup/iam.tf is the source for this as you rightly point out and will be updated automatically. I don't follow your comment "we will need to keep them manually in sync". Is there's another config you're keeping these roles in?

services:
- cloudresourcemanager.googleapis.com
- storage-api.googleapis.com
- serviceusage.googleapis.com
Comment on lines +129 to +131
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I see only three services listed here, shouldn't this include all the services needed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these are the services required to invoke terraform, which will then itself enable the other services. They're similar to the services avocano gets you to manually enable before running the script

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source for this is the activate_apis variable to the project factory module under test/.