Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding terraform and tests #371

Merged
merged 36 commits into from
Jul 12, 2023

Conversation

franklinWhaite
Copy link
Member

No description provided.

Comment on lines 76 to 81
-var="project_id=${PROJECT_ID}" \
-var="storage_project_id=${STORAGE_PROJECT_ID}" \
-var="source_dataset_name=${SOURCE_DATASET_NAME}" \
-var="target_dataset_name=${TARGET_DATASET_NAME}" \
-var="crontab_format=${CRONTAB_FORMAT}" \
-var="seconds_before_expiration=${SECONDS_BEFORE_EXPIRATION}" \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Recommend using a .tfvars file and have the user modify this file with their own values

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Comment on lines 102 to 107
message = {"crontab_format":"0 1 * * *"}
timestamps = []
for i in range(3):
timestamps.append(get_snapshot_timestamp)
time.sleep(1)
print(timestamps)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the purpose of this?

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

# limitations under the License.

terraform {
backend "local" {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Recommend using GCS remote backend

Copy link
Member Author

Choose a reason for hiding this comment

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

done

tools/cloud_functions/bq_table_snapshots/terraform/main.tf Outdated Show resolved Hide resolved
tools/cloud_functions/bq_table_snapshots/terraform/main.tf Outdated Show resolved Hide resolved
# See the License for the specific language governing permissions and
# limitations under the License.

terraform {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Run terraform fmt on all your terraform files

Copy link
Member Author

Choose a reason for hiding this comment

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

done

franklinWhaite and others added 16 commits July 11, 2023 17:19
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
…_tables_names/test_bq_backup_fetch_tables_names.py

Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
…e_snapshots/test_bq_backup_create_snapshots.py

Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
…e_snapshots/test_bq_backup_create_snapshots.py

Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
…e_snapshots/test_bq_backup_create_snapshots.py

Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
…_tables_names/test_bq_backup_fetch_tables_names.py

Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
tools/cloud_functions/bq_table_snapshots/README.md Outdated Show resolved Hide resolved
tools/cloud_functions/bq_table_snapshots/README.md Outdated Show resolved Hide resolved
@@ -37,12 +37,43 @@ The following environemnt variables must be set:
## bq_backup_create_snapshots
The **bq_backup_create_snapshots** cloud function will submit a BigQuery job to create a snapshot for each table in scope. This cloud function will suffix the snapshot name with the snapshot datetime to guarantee a unique name. It will also calculate and set the expiration time of the snapshot based on seconds_before_expiration. Finally, it will determine the snapshot time based on crontab_format.
The following environemnt variables must be set:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Reword this and line 32 as well since it instructs the user to set an environment variable but the Terraform will actually do this.

The following could be an appropriate rewording:
"The Cloud Function uses the following environment variables to determine which BigQuery project to use for compute and which to use for storing your BigQuery snapshots:"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also lines 32 & 39 have typo: environemnt
Fix: environment

Copy link
Collaborator

Choose a reason for hiding this comment

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

Line 16 replace Scheduloer with Scheduler

Copy link
Collaborator

Choose a reason for hiding this comment

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

Line 35 has typo: ame
Fix: name

franklinWhaite and others added 10 commits July 12, 2023 09:35
…vars.tfvars

Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
…vars.tfvars

Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
franklinWhaite and others added 6 commits July 12, 2023 10:38
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
The following environemnt variables must be set:
* `BQ_DATA_PROJECT_ID `id of project used for BQ storage
The **bq_backup_create_snapshots** Cloud Function will submit a BigQuery job to create a snapshot for each table in scope. This Cloud Function will suffix the snapshot name with the snapshot datetime to guarantee a unique name. It will also calculate and set the expiration time of the snapshot based on seconds_before_expiration. Finally, it will determine the snapshot time based on crontab_format.
The following environment variables must be set:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
The following environment variables must be set:
The Cloud Function uses the following environment variables to determine which BigQuery project to use for compute and which to use for storing your BigQuery snapshots:

franklinWhaite and others added 2 commits July 12, 2023 10:56
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
Co-authored-by: Daniel De Leo <danieldeleo@users.noreply.github.com>
@danieldeleo danieldeleo merged commit 532d470 into GoogleCloudPlatform:master Jul 12, 2023
3 checks passed
@danieldeleo danieldeleo mentioned this pull request Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants